OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef CC_LAYERS_TILED_LAYER_H_ | |
6 #define CC_LAYERS_TILED_LAYER_H_ | |
7 | |
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" | |
12 | |
13 namespace cc { | |
14 class LayerUpdater; | |
15 class PrioritizedResourceManager; | |
16 class PrioritizedResource; | |
17 class UpdatableTile; | |
18 | |
19 class CC_EXPORT TiledLayer : public ContentsScalingLayer { | |
20 public: | |
21 enum TilingOption { | |
22 ALWAYS_TILE, | |
23 NEVER_TILE, | |
24 AUTO_TILE, | |
25 }; | |
26 | |
27 // Layer implementation. | |
28 void SetIsMask(bool is_mask) override; | |
29 void PushPropertiesTo(LayerImpl* layer) override; | |
30 void ReduceMemoryUsage() override; | |
31 void SetNeedsDisplayRect(const gfx::Rect& dirty_rect) override; | |
32 void SetLayerTreeHost(LayerTreeHost* layer_tree_host) override; | |
33 void SetTexturePriorities(const PriorityCalculator& priority_calc) override; | |
34 SimpleEnclosedRegion VisibleContentOpaqueRegion() const override; | |
35 bool Update(ResourceUpdateQueue* queue, | |
36 const OcclusionTracker<Layer>* occlusion) override; | |
37 void OnOutputSurfaceCreated() override; | |
38 | |
39 protected: | |
40 TiledLayer(); | |
41 ~TiledLayer() override; | |
42 | |
43 void UpdateTileSizeAndTilingOption(); | |
44 void UpdateBounds(); | |
45 | |
46 // Exposed to subclasses for testing. | |
47 void SetTileSize(const gfx::Size& size); | |
48 void SetTextureFormat(ResourceFormat texture_format) { | |
49 texture_format_ = texture_format; | |
50 } | |
51 void SetBorderTexelOption(LayerTilingData::BorderTexelOption option); | |
52 size_t NumPaintedTiles() { return tiler_->tiles().size(); } | |
53 | |
54 virtual LayerUpdater* Updater() const = 0; | |
55 virtual void CreateUpdaterIfNeeded() = 0; | |
56 | |
57 // Set invalidations to be potentially repainted during Update(). | |
58 void InvalidateContentRect(const gfx::Rect& content_rect); | |
59 | |
60 // Reset state on tiles that will be used for updating the layer. | |
61 void ResetUpdateState(); | |
62 | |
63 // After preparing an update, returns true if more painting is needed. | |
64 bool NeedsIdlePaint(); | |
65 gfx::Rect IdlePaintRect(); | |
66 | |
67 bool SkipsDraw() const { return skips_draw_; } | |
68 | |
69 bool HasDrawableContent() const override; | |
70 | |
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; | |
75 | |
76 private: | |
77 scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) override; | |
78 | |
79 void CreateTilerIfNeeded(); | |
80 void set_tiling_option(TilingOption tiling_option) { | |
81 tiling_option_ = tiling_option; | |
82 } | |
83 | |
84 bool TileOnlyNeedsPartialUpdate(UpdatableTile* tile); | |
85 bool TileNeedsBufferedUpdate(UpdatableTile* tile); | |
86 | |
87 void MarkOcclusionsAndRequestTextures( | |
88 int left, | |
89 int top, | |
90 int right, | |
91 int bottom, | |
92 const OcclusionTracker<Layer>* occlusion); | |
93 | |
94 bool UpdateTiles(int left, | |
95 int top, | |
96 int right, | |
97 int bottom, | |
98 ResourceUpdateQueue* queue, | |
99 const OcclusionTracker<Layer>* occlusion, | |
100 bool* did_paint); | |
101 bool HaveTexturesForTiles(int left, | |
102 int top, | |
103 int right, | |
104 int bottom, | |
105 bool ignore_occlusions); | |
106 void MarkTilesForUpdate(gfx::Rect* update_rect, | |
107 gfx::Rect* paint_rect, | |
108 int left, | |
109 int top, | |
110 int right, | |
111 int bottom, | |
112 bool ignore_occlusions); | |
113 void UpdateTileTextures(const gfx::Rect& update_rect, | |
114 const gfx::Rect& paint_rect, | |
115 int left, | |
116 int top, | |
117 int right, | |
118 int bottom, | |
119 ResourceUpdateQueue* queue, | |
120 const OcclusionTracker<Layer>* occlusion); | |
121 void UpdateScrollPrediction(); | |
122 | |
123 UpdatableTile* TileAt(int i, int j) const; | |
124 UpdatableTile* CreateTile(int i, int j); | |
125 | |
126 bool IsSmallAnimatedLayer() const; | |
127 | |
128 ResourceFormat texture_format_; | |
129 bool skips_draw_; | |
130 bool failed_update_; | |
131 | |
132 // Used for predictive painting. | |
133 gfx::Vector2d predicted_scroll_; | |
134 gfx::Rect predicted_visible_rect_; | |
135 gfx::Rect previous_visible_rect_; | |
136 gfx::Size previous_content_bounds_; | |
137 | |
138 TilingOption tiling_option_; | |
139 scoped_ptr<LayerTilingData> tiler_; | |
140 | |
141 DISALLOW_COPY_AND_ASSIGN(TiledLayer); | |
142 }; | |
143 | |
144 } // namespace cc | |
145 | |
146 #endif // CC_LAYERS_TILED_LAYER_H_ | |
OLD | NEW |