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

Side by Side Diff: cc/layers/solid_color_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: final merge 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
« no previous file with comments | « cc/layers/solid_color_layer_impl.h ('k') | cc/resources/picture_pile.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/solid_color_layer_impl.h" 5 #include "cc/layers/solid_color_layer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "cc/quads/solid_color_draw_quad.h" 9 #include "cc/quads/solid_color_draw_quad.h"
10 #include "cc/trees/occlusion_tracker.h" 10 #include "cc/trees/occlusion_tracker.h"
11 11
12 namespace cc { 12 namespace cc {
13 13
14 namespace {
15 const int kSolidQuadTileSize = 256;
16 }
17
14 SolidColorLayerImpl::SolidColorLayerImpl(LayerTreeImpl* tree_impl, int id) 18 SolidColorLayerImpl::SolidColorLayerImpl(LayerTreeImpl* tree_impl, int id)
15 : LayerImpl(tree_impl, id), 19 : LayerImpl(tree_impl, id) {
16 tile_size_(256) {} 20 }
17 21
18 SolidColorLayerImpl::~SolidColorLayerImpl() {} 22 SolidColorLayerImpl::~SolidColorLayerImpl() {}
19 23
20 scoped_ptr<LayerImpl> SolidColorLayerImpl::CreateLayerImpl( 24 scoped_ptr<LayerImpl> SolidColorLayerImpl::CreateLayerImpl(
21 LayerTreeImpl* tree_impl) { 25 LayerTreeImpl* tree_impl) {
22 return SolidColorLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>(); 26 return SolidColorLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>();
23 } 27 }
24 28
25 void SolidColorLayerImpl::AppendQuads( 29 void SolidColorLayerImpl::AppendSolidQuads(
26 RenderPass* render_pass, 30 RenderPass* render_pass,
27 const OcclusionTracker<LayerImpl>& occlusion_tracker, 31 const OcclusionTracker<LayerImpl>& occlusion_tracker,
28 AppendQuadsData* append_quads_data) { 32 SharedQuadState* shared_quad_state,
29 SharedQuadState* shared_quad_state = 33 const gfx::Size& content_bounds,
30 render_pass->CreateAndAppendSharedQuadState(); 34 const gfx::Transform& target_space_transform,
31 PopulateSharedQuadState(shared_quad_state); 35 SkColor color) {
32 36 Occlusion occlusion =
33 AppendDebugBorderQuad( 37 occlusion_tracker.GetCurrentOcclusionForLayer(target_space_transform);
34 render_pass, content_bounds(), shared_quad_state, append_quads_data);
35
36 Occlusion occlusion = occlusion_tracker.GetCurrentOcclusionForLayer(
37 draw_properties().target_space_transform);
38 38
39 // We create a series of smaller quads instead of just one large one so that 39 // We create a series of smaller quads instead of just one large one so that
40 // the culler can reduce the total pixels drawn. 40 // the culler can reduce the total pixels drawn.
41 int width = content_bounds().width(); 41 int width = content_bounds.width();
42 int height = content_bounds().height(); 42 int height = content_bounds.height();
43 for (int x = 0; x < width; x += tile_size_) { 43 for (int x = 0; x < width; x += kSolidQuadTileSize) {
44 for (int y = 0; y < height; y += tile_size_) { 44 for (int y = 0; y < height; y += kSolidQuadTileSize) {
45 gfx::Rect quad_rect(x, 45 gfx::Rect quad_rect(x,
46 y, 46 y,
47 std::min(width - x, tile_size_), 47 std::min(width - x, kSolidQuadTileSize),
48 std::min(height - y, tile_size_)); 48 std::min(height - y, kSolidQuadTileSize));
49 gfx::Rect visible_quad_rect = 49 gfx::Rect visible_quad_rect =
50 occlusion.GetUnoccludedContentRect(quad_rect); 50 occlusion.GetUnoccludedContentRect(quad_rect);
51 if (visible_quad_rect.IsEmpty()) 51 if (visible_quad_rect.IsEmpty())
52 continue; 52 continue;
53 53
54 SolidColorDrawQuad* quad = 54 SolidColorDrawQuad* quad =
55 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>(); 55 render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
56 quad->SetNew(shared_quad_state, 56 quad->SetNew(
57 quad_rect, 57 shared_quad_state, quad_rect, visible_quad_rect, color, false);
58 visible_quad_rect,
59 background_color(),
60 false);
61 } 58 }
62 } 59 }
63 } 60 }
64 61
62 void SolidColorLayerImpl::AppendQuads(
63 RenderPass* render_pass,
64 const OcclusionTracker<LayerImpl>& occlusion_tracker,
65 AppendQuadsData* append_quads_data) {
66 SharedQuadState* shared_quad_state =
67 render_pass->CreateAndAppendSharedQuadState();
68 PopulateSharedQuadState(shared_quad_state);
69
70 AppendDebugBorderQuad(
71 render_pass, content_bounds(), shared_quad_state, append_quads_data);
72
73 AppendSolidQuads(render_pass,
74 occlusion_tracker,
75 shared_quad_state,
76 content_bounds(),
77 draw_properties().target_space_transform,
78 background_color());
79 }
80
65 const char* SolidColorLayerImpl::LayerTypeAsString() const { 81 const char* SolidColorLayerImpl::LayerTypeAsString() const {
66 return "cc::SolidColorLayerImpl"; 82 return "cc::SolidColorLayerImpl";
67 } 83 }
68 84
69 } // namespace cc 85 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/solid_color_layer_impl.h ('k') | cc/resources/picture_pile.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698