OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/layers/tiled_layer_impl.h" | 5 #include "cc/layers/tiled_layer_impl.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/debug/trace_event_argument.h" | 8 #include "base/debug/trace_event_argument.h" |
9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
10 #include "cc/base/math_util.h" | 10 #include "cc/base/math_util.h" |
11 #include "cc/base/simple_enclosed_region.h" | 11 #include "cc/base/simple_enclosed_region.h" |
12 #include "cc/debug/debug_colors.h" | 12 #include "cc/debug/debug_colors.h" |
13 #include "cc/layers/append_quads_data.h" | 13 #include "cc/layers/append_quads_data.h" |
14 #include "cc/quads/checkerboard_draw_quad.h" | 14 #include "cc/quads/checkerboard_draw_quad.h" |
15 #include "cc/quads/debug_border_draw_quad.h" | 15 #include "cc/quads/debug_border_draw_quad.h" |
16 #include "cc/quads/solid_color_draw_quad.h" | 16 #include "cc/quads/solid_color_draw_quad.h" |
17 #include "cc/quads/tile_draw_quad.h" | 17 #include "cc/quads/tile_draw_quad.h" |
18 #include "cc/resources/layer_tiling_data.h" | 18 #include "cc/resources/layer_tiling_data.h" |
19 #include "cc/trees/occlusion_tracker.h" | 19 #include "cc/trees/occlusion.h" |
20 #include "third_party/khronos/GLES2/gl2.h" | 20 #include "third_party/khronos/GLES2/gl2.h" |
21 #include "third_party/skia/include/core/SkColor.h" | 21 #include "third_party/skia/include/core/SkColor.h" |
22 #include "ui/gfx/quad_f.h" | 22 #include "ui/gfx/quad_f.h" |
23 | 23 |
24 namespace cc { | 24 namespace cc { |
25 | 25 |
26 class DrawableTile : public LayerTilingData::Tile { | 26 class DrawableTile : public LayerTilingData::Tile { |
27 public: | 27 public: |
28 static scoped_ptr<DrawableTile> Create() { | 28 static scoped_ptr<DrawableTile> Create() { |
29 return make_scoped_ptr(new DrawableTile()); | 29 return make_scoped_ptr(new DrawableTile()); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 bool TiledLayerImpl::WillDraw(DrawMode draw_mode, | 149 bool TiledLayerImpl::WillDraw(DrawMode draw_mode, |
150 ResourceProvider* resource_provider) { | 150 ResourceProvider* resource_provider) { |
151 if (!tiler_ || tiler_->has_empty_bounds() || | 151 if (!tiler_ || tiler_->has_empty_bounds() || |
152 visible_content_rect().IsEmpty() || | 152 visible_content_rect().IsEmpty() || |
153 draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) | 153 draw_mode == DRAW_MODE_RESOURCELESS_SOFTWARE) |
154 return false; | 154 return false; |
155 return LayerImpl::WillDraw(draw_mode, resource_provider); | 155 return LayerImpl::WillDraw(draw_mode, resource_provider); |
156 } | 156 } |
157 | 157 |
158 void TiledLayerImpl::AppendQuads( | 158 void TiledLayerImpl::AppendQuads(RenderPass* render_pass, |
159 RenderPass* render_pass, | 159 const Occlusion& occlusion_in_content_space, |
160 const OcclusionTracker<LayerImpl>& occlusion_tracker, | 160 AppendQuadsData* append_quads_data) { |
161 AppendQuadsData* append_quads_data) { | |
162 DCHECK(tiler_); | 161 DCHECK(tiler_); |
163 DCHECK(!tiler_->has_empty_bounds()); | 162 DCHECK(!tiler_->has_empty_bounds()); |
164 DCHECK(!visible_content_rect().IsEmpty()); | 163 DCHECK(!visible_content_rect().IsEmpty()); |
165 | 164 |
166 gfx::Rect content_rect = visible_content_rect(); | 165 gfx::Rect content_rect = visible_content_rect(); |
167 SharedQuadState* shared_quad_state = | 166 SharedQuadState* shared_quad_state = |
168 render_pass->CreateAndAppendSharedQuadState(); | 167 render_pass->CreateAndAppendSharedQuadState(); |
169 PopulateSharedQuadState(shared_quad_state); | 168 PopulateSharedQuadState(shared_quad_state); |
170 | 169 |
171 AppendDebugBorderQuad( | 170 AppendDebugBorderQuad( |
(...skipping 25 matching lines...) Expand all Loading... |
197 visible_tile_rect, | 196 visible_tile_rect, |
198 border_color, | 197 border_color, |
199 border_width); | 198 border_width); |
200 } | 199 } |
201 } | 200 } |
202 } | 201 } |
203 | 202 |
204 if (skips_draw_) | 203 if (skips_draw_) |
205 return; | 204 return; |
206 | 205 |
207 Occlusion occlusion = | |
208 occlusion_tracker.GetCurrentOcclusionForLayer(draw_transform()); | |
209 for (int j = top; j <= bottom; ++j) { | 206 for (int j = top; j <= bottom; ++j) { |
210 for (int i = left; i <= right; ++i) { | 207 for (int i = left; i <= right; ++i) { |
211 DrawableTile* tile = TileAt(i, j); | 208 DrawableTile* tile = TileAt(i, j); |
212 gfx::Rect tile_rect = tiler_->tile_bounds(i, j); | 209 gfx::Rect tile_rect = tiler_->tile_bounds(i, j); |
213 gfx::Rect display_rect = tile_rect; | 210 gfx::Rect display_rect = tile_rect; |
214 tile_rect.Intersect(content_rect); | 211 tile_rect.Intersect(content_rect); |
215 | 212 |
216 // Skip empty tiles. | 213 // Skip empty tiles. |
217 if (tile_rect.IsEmpty()) | 214 if (tile_rect.IsEmpty()) |
218 continue; | 215 continue; |
219 | 216 |
220 gfx::Rect visible_tile_rect = | 217 gfx::Rect visible_tile_rect = |
221 occlusion.GetUnoccludedContentRect(tile_rect); | 218 occlusion_in_content_space.GetUnoccludedContentRect(tile_rect); |
222 if (visible_tile_rect.IsEmpty()) | 219 if (visible_tile_rect.IsEmpty()) |
223 continue; | 220 continue; |
224 | 221 |
225 if (!tile || !tile->resource_id()) { | 222 if (!tile || !tile->resource_id()) { |
226 SkColor checker_color; | 223 SkColor checker_color; |
227 if (ShowDebugBorders()) { | 224 if (ShowDebugBorders()) { |
228 checker_color = | 225 checker_color = |
229 tile ? DebugColors::InvalidatedTileCheckerboardColor() | 226 tile ? DebugColors::InvalidatedTileCheckerboardColor() |
230 : DebugColors::EvictedTileCheckerboardColor(); | 227 : DebugColors::EvictedTileCheckerboardColor(); |
231 } else { | 228 } else { |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 303 |
307 void TiledLayerImpl::ReleaseResources() { | 304 void TiledLayerImpl::ReleaseResources() { |
308 tiler_->reset(); | 305 tiler_->reset(); |
309 } | 306 } |
310 | 307 |
311 const char* TiledLayerImpl::LayerTypeAsString() const { | 308 const char* TiledLayerImpl::LayerTypeAsString() const { |
312 return "cc::TiledLayerImpl"; | 309 return "cc::TiledLayerImpl"; |
313 } | 310 } |
314 | 311 |
315 } // namespace cc | 312 } // namespace cc |
OLD | NEW |