Adding a logging class to cast.
[chromium-blink-merge.git] / cc / layers / tiled_layer.h
bloba7bd9f7be50f6b97b76b622ba002f72a3bff2361
1 // Copyright 2011 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.
5 #ifndef CC_LAYERS_TILED_LAYER_H_
6 #define CC_LAYERS_TILED_LAYER_H_
8 #include "cc/base/cc_export.h"
9 #include "cc/layers/contents_scaling_layer.h"
10 #include "cc/resources/layer_tiling_data.h"
11 #include "cc/resources/resource_format.h"
13 namespace cc {
14 class LayerUpdater;
15 class PrioritizedResourceManager;
16 class PrioritizedResource;
17 class UpdatableTile;
19 class CC_EXPORT TiledLayer : public ContentsScalingLayer {
20 public:
21 enum TilingOption {
22 ALWAYS_TILE,
23 NEVER_TILE,
24 AUTO_TILE,
27 // Layer implementation.
28 virtual void SetIsMask(bool is_mask) OVERRIDE;
29 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE;
30 virtual bool DrawsContent() const OVERRIDE;
31 virtual void ReduceMemoryUsage() OVERRIDE;
32 virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) OVERRIDE;
33 virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE;
34 virtual void SetTexturePriorities(const PriorityCalculator& priority_calc)
35 OVERRIDE;
36 virtual Region VisibleContentOpaqueRegion() const OVERRIDE;
37 virtual bool Update(ResourceUpdateQueue* queue,
38 const OcclusionTracker* occlusion) OVERRIDE;
39 virtual void OnOutputSurfaceCreated() OVERRIDE;
41 protected:
42 TiledLayer();
43 virtual ~TiledLayer();
45 void UpdateTileSizeAndTilingOption();
46 void UpdateBounds();
48 // Exposed to subclasses for testing.
49 void SetTileSize(gfx::Size size);
50 void SetTextureFormat(ResourceFormat texture_format) {
51 texture_format_ = texture_format;
53 void SetBorderTexelOption(LayerTilingData::BorderTexelOption option);
54 size_t NumPaintedTiles() { return tiler_->tiles().size(); }
56 virtual LayerUpdater* Updater() const = 0;
57 virtual void CreateUpdaterIfNeeded() = 0;
59 // Set invalidations to be potentially repainted during Update().
60 void InvalidateContentRect(gfx::Rect content_rect);
62 // Reset state on tiles that will be used for updating the layer.
63 void ResetUpdateState();
65 // After preparing an update, returns true if more painting is needed.
66 bool NeedsIdlePaint();
67 gfx::Rect IdlePaintRect();
69 bool SkipsDraw() const { return skips_draw_; }
71 // Virtual for testing
72 virtual PrioritizedResourceManager* ResourceManager();
73 const LayerTilingData* TilerForTesting() const { return tiler_.get(); }
74 const PrioritizedResource* ResourceAtForTesting(int i, int j) const;
76 private:
77 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl)
78 OVERRIDE;
80 void CreateTilerIfNeeded();
81 void set_tiling_option(TilingOption tiling_option) {
82 tiling_option_ = tiling_option;
85 bool TileOnlyNeedsPartialUpdate(UpdatableTile* tile);
86 bool TileNeedsBufferedUpdate(UpdatableTile* tile);
88 void MarkOcclusionsAndRequestTextures(int left,
89 int top,
90 int right,
91 int bottom,
92 const OcclusionTracker* occlusion);
94 bool UpdateTiles(int left,
95 int top,
96 int right,
97 int bottom,
98 ResourceUpdateQueue* queue,
99 const OcclusionTracker* occlusion,
100 bool* did_paint);
101 bool HaveTexturesForTiles(int left,
102 int top,
103 int right,
104 int bottom,
105 bool ignore_occlusions);
106 gfx::Rect MarkTilesForUpdate(int left,
107 int top,
108 int right,
109 int bottom,
110 bool ignore_occlusions);
111 void UpdateTileTextures(gfx::Rect paint_rect,
112 int left,
113 int top,
114 int right,
115 int bottom,
116 ResourceUpdateQueue* queue,
117 const OcclusionTracker* occlusion);
118 void UpdateScrollPrediction();
120 UpdatableTile* TileAt(int i, int j) const;
121 UpdatableTile* CreateTile(int i, int j);
123 bool IsSmallAnimatedLayer() const;
125 ResourceFormat texture_format_;
126 bool skips_draw_;
127 bool failed_update_;
129 // Used for predictive painting.
130 gfx::Vector2d predicted_scroll_;
131 gfx::Rect predicted_visible_rect_;
132 gfx::Rect previous_visible_rect_;
133 gfx::Size previous_content_bounds_;
135 TilingOption tiling_option_;
136 scoped_ptr<LayerTilingData> tiler_;
138 DISALLOW_COPY_AND_ASSIGN(TiledLayer);
141 } // namespace cc
143 #endif // CC_LAYERS_TILED_LAYER_H_