1// Copyright 2010 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CC_LAYERS_CONTENT_LAYER_H_
6#define CC_LAYERS_CONTENT_LAYER_H_
7
8#include "base/basictypes.h"
9#include "cc/base/cc_export.h"
10#include "cc/layers/tiled_layer.h"
11#include "cc/resources/layer_painter.h"
12
13class SkCanvas;
14
15namespace cc {
16
17class ContentLayerClient;
18class ContentLayerUpdater;
19
20class CC_EXPORT ContentLayerPainter : public LayerPainter {
21 public:
22  static scoped_ptr<ContentLayerPainter> Create(ContentLayerClient* client);
23
24  virtual void Paint(SkCanvas* canvas, const gfx::Rect& content_rect) OVERRIDE;
25
26 private:
27  explicit ContentLayerPainter(ContentLayerClient* client);
28
29  ContentLayerClient* client_;
30
31  DISALLOW_COPY_AND_ASSIGN(ContentLayerPainter);
32};
33
34// A layer that renders its contents into an SkCanvas.
35class CC_EXPORT ContentLayer : public TiledLayer {
36 public:
37  static scoped_refptr<ContentLayer> Create(ContentLayerClient* client);
38
39  void ClearClient();
40
41  virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE;
42  virtual void SetTexturePriorities(const PriorityCalculator& priority_calc)
43      OVERRIDE;
44  virtual bool Update(ResourceUpdateQueue* queue,
45                      const OcclusionTracker<Layer>* occlusion) OVERRIDE;
46  virtual bool NeedMoreUpdates() OVERRIDE;
47
48  virtual void SetContentsOpaque(bool contents_opaque) OVERRIDE;
49
50  virtual bool SupportsLCDText() const OVERRIDE;
51
52  virtual skia::RefPtr<SkPicture> GetPicture() const OVERRIDE;
53
54  virtual void OnOutputSurfaceCreated() OVERRIDE;
55
56 protected:
57  explicit ContentLayer(ContentLayerClient* client);
58  virtual ~ContentLayer();
59
60  virtual bool HasDrawableContent() const OVERRIDE;
61
62  // TiledLayer implementation.
63  virtual LayerUpdater* Updater() const OVERRIDE;
64
65 private:
66  // TiledLayer implementation.
67  virtual void CreateUpdaterIfNeeded() OVERRIDE;
68
69  void UpdateCanUseLCDText();
70
71  ContentLayerClient* client_;
72  scoped_refptr<ContentLayerUpdater> updater_;
73  bool can_use_lcd_text_last_frame_;
74
75  DISALLOW_COPY_AND_ASSIGN(ContentLayer);
76};
77
78}  // namespace cc
79#endif  // CC_LAYERS_CONTENT_LAYER_H_
80