Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Side by Side Diff: cc/layers/layer_impl.cc

Issue 519583003: Use the solid color detection to create solid layers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Passed the right color to the quad Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/layer_impl.h" 5 #include "cc/layers/layer_impl.h"
6 6
7 #include "base/debug/trace_event.h" 7 #include "base/debug/trace_event.h"
8 #include "base/debug/trace_event_argument.h" 8 #include "base/debug/trace_event_argument.h"
9 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
11 #include "cc/animation/animation_registrar.h" 11 #include "cc/animation/animation_registrar.h"
12 #include "cc/animation/scrollbar_animation_controller.h" 12 #include "cc/animation/scrollbar_animation_controller.h"
13 #include "cc/base/math_util.h" 13 #include "cc/base/math_util.h"
14 #include "cc/base/simple_enclosed_region.h" 14 #include "cc/base/simple_enclosed_region.h"
15 #include "cc/debug/debug_colors.h" 15 #include "cc/debug/debug_colors.h"
16 #include "cc/debug/layer_tree_debug_state.h" 16 #include "cc/debug/layer_tree_debug_state.h"
17 #include "cc/debug/micro_benchmark_impl.h" 17 #include "cc/debug/micro_benchmark_impl.h"
18 #include "cc/debug/traced_value.h" 18 #include "cc/debug/traced_value.h"
19 #include "cc/input/layer_scroll_offset_delegate.h" 19 #include "cc/input/layer_scroll_offset_delegate.h"
20 #include "cc/layers/layer_utils.h" 20 #include "cc/layers/layer_utils.h"
21 #include "cc/layers/painted_scrollbar_layer_impl.h" 21 #include "cc/layers/painted_scrollbar_layer_impl.h"
22 #include "cc/output/copy_output_request.h" 22 #include "cc/output/copy_output_request.h"
23 #include "cc/quads/debug_border_draw_quad.h" 23 #include "cc/quads/debug_border_draw_quad.h"
24 #include "cc/quads/render_pass.h" 24 #include "cc/quads/render_pass.h"
25 #include "cc/quads/solid_color_draw_quad.h"
25 #include "cc/trees/layer_tree_host_common.h" 26 #include "cc/trees/layer_tree_host_common.h"
26 #include "cc/trees/layer_tree_impl.h" 27 #include "cc/trees/layer_tree_impl.h"
27 #include "cc/trees/layer_tree_settings.h" 28 #include "cc/trees/layer_tree_settings.h"
29 #include "cc/trees/occlusion_tracker.h"
28 #include "cc/trees/proxy.h" 30 #include "cc/trees/proxy.h"
29 #include "ui/gfx/box_f.h" 31 #include "ui/gfx/box_f.h"
30 #include "ui/gfx/geometry/vector2d_conversions.h" 32 #include "ui/gfx/geometry/vector2d_conversions.h"
31 #include "ui/gfx/point_conversions.h" 33 #include "ui/gfx/point_conversions.h"
32 #include "ui/gfx/quad_f.h" 34 #include "ui/gfx/quad_f.h"
33 #include "ui/gfx/rect_conversions.h" 35 #include "ui/gfx/rect_conversions.h"
34 #include "ui/gfx/size_conversions.h" 36 #include "ui/gfx/size_conversions.h"
35 37
38 namespace {
39 const int kSolidQuadTileSize = 256;
40 }
41
36 namespace cc { 42 namespace cc {
37 LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id) 43 LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id)
38 : parent_(NULL), 44 : parent_(NULL),
39 scroll_parent_(NULL), 45 scroll_parent_(NULL),
40 clip_parent_(NULL), 46 clip_parent_(NULL),
41 mask_layer_id_(-1), 47 mask_layer_id_(-1),
42 replica_layer_id_(-1), 48 replica_layer_id_(-1),
43 layer_id_(id), 49 layer_id_(id),
44 layer_tree_impl_(tree_impl), 50 layer_tree_impl_(tree_impl),
45 scroll_offset_delegate_(NULL), 51 scroll_offset_delegate_(NULL),
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
293 if (masks_to_bounds_) { 299 if (masks_to_bounds_) {
294 *color = DebugColors::MaskingLayerBorderColor(); 300 *color = DebugColors::MaskingLayerBorderColor();
295 *width = DebugColors::MaskingLayerBorderWidth(layer_tree_impl()); 301 *width = DebugColors::MaskingLayerBorderWidth(layer_tree_impl());
296 return; 302 return;
297 } 303 }
298 304
299 *color = DebugColors::ContainerLayerBorderColor(); 305 *color = DebugColors::ContainerLayerBorderColor();
300 *width = DebugColors::ContainerLayerBorderWidth(layer_tree_impl()); 306 *width = DebugColors::ContainerLayerBorderWidth(layer_tree_impl());
301 } 307 }
302 308
309 void LayerImpl::AppendSolidQuads(
310 RenderPass* render_pass,
311 const OcclusionTracker<LayerImpl>& occlusion_tracker,
312 AppendQuadsData* append_quads_data,
313 SkColor color) {
314 SharedQuadState* shared_quad_state =
315 render_pass->CreateAndAppendSharedQuadState();
316 PopulateSharedQuadState(shared_quad_state);
317
318 AppendDebugBorderQuad(
319 render_pass, content_bounds(), shared_quad_state, append_quads_data);
320
321 // We create a series of smaller quads instead of just one large one so that
322 // the culler can reduce the total pixels drawn.
323 int width = content_bounds().width();
324 int height = content_bounds().height();
325 for (int x = 0; x < width; x += kSolidQuadTileSize) {
326 for (int y = 0; y < height; y += kSolidQuadTileSize) {
327 gfx::Rect quad_rect(x,
328 y,
329 std::min(width - x, kSolidQuadTileSize),
330 std::min(height - y, kSolidQuadTileSize));
331 gfx::Rect visible_quad_rect = occlusion_tracker.UnoccludedContentRect(
332 quad_rect, draw_properties().target_space_transform);
333 if (visible_quad_rect.IsEmpty())
334 continue;
335
336 SolidColorDrawQuad* quad =
337 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
338 quad->SetNew(
339 shared_quad_state, quad_rect, visible_quad_rect, color, false);
340 }
341 }
342 }
343
303 void LayerImpl::AppendDebugBorderQuad( 344 void LayerImpl::AppendDebugBorderQuad(
304 RenderPass* render_pass, 345 RenderPass* render_pass,
305 const gfx::Size& content_bounds, 346 const gfx::Size& content_bounds,
306 const SharedQuadState* shared_quad_state, 347 const SharedQuadState* shared_quad_state,
307 AppendQuadsData* append_quads_data) const { 348 AppendQuadsData* append_quads_data) const {
308 SkColor color; 349 SkColor color;
309 float width; 350 float width;
310 GetDebugBorderProperties(&color, &width); 351 GetDebugBorderProperties(&color, &width);
311 AppendDebugBorderQuad(render_pass, 352 AppendDebugBorderQuad(render_pass,
312 content_bounds, 353 content_bounds,
(...skipping 1225 matching lines...) Expand 10 before | Expand all | Expand 10 after
1538 } 1579 }
1539 1580
1540 void LayerImpl::NotifyAnimationFinished( 1581 void LayerImpl::NotifyAnimationFinished(
1541 base::TimeTicks monotonic_time, 1582 base::TimeTicks monotonic_time,
1542 Animation::TargetProperty target_property) { 1583 Animation::TargetProperty target_property) {
1543 if (target_property == Animation::ScrollOffset) 1584 if (target_property == Animation::ScrollOffset)
1544 layer_tree_impl_->InputScrollAnimationFinished(); 1585 layer_tree_impl_->InputScrollAnimationFinished();
1545 } 1586 }
1546 1587
1547 } // namespace cc 1588 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/layer_impl.h ('k') | cc/layers/picture_layer.h » ('j') | cc/layers/picture_layer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698