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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: cc/layers/layer_impl.cc
diff --git a/cc/layers/layer_impl.cc b/cc/layers/layer_impl.cc
index 2d444a1545717e2fab6c6dc257a41f26fd8300dc..4a593324b0fc6140d2f176f8402e5711cf274b35 100644
--- a/cc/layers/layer_impl.cc
+++ b/cc/layers/layer_impl.cc
@@ -22,9 +22,11 @@
#include "cc/output/copy_output_request.h"
#include "cc/quads/debug_border_draw_quad.h"
#include "cc/quads/render_pass.h"
+#include "cc/quads/solid_color_draw_quad.h"
#include "cc/trees/layer_tree_host_common.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/layer_tree_settings.h"
+#include "cc/trees/occlusion_tracker.h"
#include "cc/trees/proxy.h"
#include "ui/gfx/box_f.h"
#include "ui/gfx/geometry/vector2d_conversions.h"
@@ -33,6 +35,10 @@
#include "ui/gfx/rect_conversions.h"
#include "ui/gfx/size_conversions.h"
+namespace {
+const int kSolidQuadTileSize = 256;
+}
+
namespace cc {
LayerImpl::LayerImpl(LayerTreeImpl* tree_impl, int id)
: parent_(NULL),
@@ -300,6 +306,41 @@ void LayerImpl::GetDebugBorderProperties(SkColor* color, float* width) const {
*width = DebugColors::ContainerLayerBorderWidth(layer_tree_impl());
}
+void LayerImpl::AppendSolidQuads(
+ RenderPass* render_pass,
+ const OcclusionTracker<LayerImpl>& occlusion_tracker,
+ AppendQuadsData* append_quads_data,
+ SkColor color) {
+ SharedQuadState* shared_quad_state =
+ render_pass->CreateAndAppendSharedQuadState();
+ PopulateSharedQuadState(shared_quad_state);
+
+ AppendDebugBorderQuad(
+ render_pass, content_bounds(), shared_quad_state, append_quads_data);
+
+ // We create a series of smaller quads instead of just one large one so that
+ // the culler can reduce the total pixels drawn.
+ int width = content_bounds().width();
+ int height = content_bounds().height();
+ for (int x = 0; x < width; x += kSolidQuadTileSize) {
+ for (int y = 0; y < height; y += kSolidQuadTileSize) {
+ gfx::Rect quad_rect(x,
+ y,
+ std::min(width - x, kSolidQuadTileSize),
+ std::min(height - y, kSolidQuadTileSize));
+ gfx::Rect visible_quad_rect = occlusion_tracker.UnoccludedContentRect(
+ quad_rect, draw_properties().target_space_transform);
+ if (visible_quad_rect.IsEmpty())
+ continue;
+
+ SolidColorDrawQuad* quad =
+ render_pass->CreateAndAppendDrawQuad<SolidColorDrawQuad>();
+ quad->SetNew(
+ shared_quad_state, quad_rect, visible_quad_rect, color, false);
+ }
+ }
+}
+
void LayerImpl::AppendDebugBorderQuad(
RenderPass* render_pass,
const gfx::Size& content_bounds,
« 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