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_TILED_LAYER_H_ | |
6 #define CC_TILED_LAYER_H_ | |
7 | |
8 #include "cc/base/cc_export.h" | |
9 #include "cc/contents_scaling_layer.h" | |
10 #include "cc/resources/layer_tiling_data.h" | |
11 | |
12 namespace cc { | |
13 class LayerUpdater; | |
14 class PrioritizedResourceManager; | |
15 class PrioritizedResource; | |
16 class UpdatableTile; | |
17 | |
18 class CC_EXPORT TiledLayer : public ContentsScalingLayer { | |
19 public: | |
20 enum TilingOption { | |
21 ALWAYS_TILE, | |
22 NEVER_TILE, | |
23 AUTO_TILE, | |
24 }; | |
25 | |
26 // Layer implementation. | |
27 virtual void SetIsMask(bool is_mask) OVERRIDE; | |
28 virtual void PushPropertiesTo(LayerImpl* layer) OVERRIDE; | |
29 virtual bool BlocksPendingCommit() const OVERRIDE; | |
30 virtual bool DrawsContent() const OVERRIDE; | |
31 virtual void SetNeedsDisplayRect(const gfx::RectF& dirty_rect) OVERRIDE; | |
32 virtual void SetLayerTreeHost(LayerTreeHost* layer_tree_host) OVERRIDE; | |
33 virtual void SetTexturePriorities(const PriorityCalculator& priority_calc) | |
34 OVERRIDE; | |
35 virtual Region VisibleContentOpaqueRegion() const OVERRIDE; | |
36 virtual void Update(ResourceUpdateQueue* queue, | |
37 const OcclusionTracker* occlusion, | |
38 RenderingStats* stats) OVERRIDE; | |
39 | |
40 protected: | |
41 TiledLayer(); | |
42 virtual ~TiledLayer(); | |
43 | |
44 void UpdateTileSizeAndTilingOption(); | |
45 void UpdateBounds(); | |
46 | |
47 // Exposed to subclasses for testing. | |
48 void SetTileSize(gfx::Size size); | |
49 void SetTextureFormat(unsigned texture_format) { | |
50 texture_format_ = texture_format; | |
51 } | |
52 void SetBorderTexelOption(LayerTilingData::BorderTexelOption option); | |
53 size_t NumPaintedTiles() { return tiler_->tiles().size(); } | |
54 | |
55 virtual LayerUpdater* Updater() const = 0; | |
56 virtual void CreateUpdaterIfNeeded() = 0; | |
57 | |
58 // Set invalidations to be potentially repainted during Update(). | |
59 void InvalidateContentRect(gfx::Rect content_rect); | |
60 | |
61 // Reset state on tiles that will be used for updating the layer. | |
62 void ResetUpdateState(); | |
63 | |
64 // After preparing an update, returns true if more painting is needed. | |
65 bool NeedsIdlePaint(); | |
66 gfx::Rect IdlePaintRect(); | |
67 | |
68 bool SkipsDraw() const { return skips_draw_; } | |
69 | |
70 // Virtual for testing | |
71 virtual PrioritizedResourceManager* ResourceManager() const; | |
72 const LayerTilingData* TilerForTesting() const { return tiler_.get(); } | |
73 const PrioritizedResource* ResourceAtForTesting(int i, int j) const; | |
74 | |
75 private: | |
76 virtual scoped_ptr<LayerImpl> CreateLayerImpl(LayerTreeImpl* tree_impl) | |
77 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(int left, | |
88 int top, | |
89 int right, | |
90 int bottom, | |
91 const OcclusionTracker* occlusion); | |
92 | |
93 bool UpdateTiles(int left, | |
94 int top, | |
95 int right, | |
96 int bottom, | |
97 ResourceUpdateQueue* queue, | |
98 const OcclusionTracker* occlusion, | |
99 RenderingStats* stats, | |
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 RenderingStats* stats); | |
119 void UpdateScrollPrediction(); | |
120 | |
121 UpdatableTile* TileAt(int i, int j) const; | |
122 UpdatableTile* CreateTile(int i, int j); | |
123 | |
124 bool IsSmallAnimatedLayer() const; | |
125 | |
126 unsigned texture_format_; | |
127 bool skips_draw_; | |
128 bool failed_update_; | |
129 | |
130 // Used for predictive painting. | |
131 gfx::Vector2d predicted_scroll_; | |
132 gfx::Rect predicted_visible_rect_; | |
133 gfx::Rect previous_visible_rect_; | |
134 gfx::Size previous_content_bounds_; | |
135 | |
136 TilingOption tiling_option_; | |
137 scoped_ptr<LayerTilingData> tiler_; | |
138 | |
139 DISALLOW_COPY_AND_ASSIGN(TiledLayer); | |
140 }; | |
141 | |
142 } | |
143 #endif // CC_TILED_LAYER_H_ | |
OLD | NEW |