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

Side by Side Diff: cc/solid_color_layer_impl.cc

Issue 11649005: cc: Support anti-aliasing for solid color layers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and add DrawQuad::AntiAliasing struct. Created 7 years, 11 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 | Annotate | Revision Log
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/solid_color_layer_impl.h" 5 #include "cc/solid_color_layer_impl.h"
6 6
7 #include "cc/math_util.h"
7 #include "cc/quad_sink.h" 8 #include "cc/quad_sink.h"
8 #include "cc/solid_color_draw_quad.h" 9 #include "cc/solid_color_draw_quad.h"
10 #include "ui/gfx/quad_f.h"
9 11
10 namespace cc { 12 namespace cc {
11 13
12 SolidColorLayerImpl::SolidColorLayerImpl(LayerTreeImpl* treeImpl, int id) 14 SolidColorLayerImpl::SolidColorLayerImpl(LayerTreeImpl* treeImpl, int id)
13 : LayerImpl(treeImpl, id) 15 : LayerImpl(treeImpl, id)
14 , m_tileSize(256) 16 , m_tileSize(256)
15 { 17 {
16 } 18 }
17 19
18 SolidColorLayerImpl::~SolidColorLayerImpl() 20 SolidColorLayerImpl::~SolidColorLayerImpl()
19 { 21 {
20 } 22 }
21 23
22 void SolidColorLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appen dQuadsData) 24 void SolidColorLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appen dQuadsData)
23 { 25 {
24 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ uadState()); 26 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ uadState());
25 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); 27 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData);
26 28
27 // We create a series of smaller quads instead of just one large one so that the 29 // We create a series of smaller quads instead of just one large one so that the
28 // culler can reduce the total pixels drawn. 30 // culler can reduce the total pixels drawn.
29 int width = contentBounds().width(); 31 int width = contentBounds().width();
30 int height = contentBounds().height(); 32 int height = contentBounds().height();
31 for (int x = 0; x < width; x += m_tileSize) { 33 for (int x = 0; x < width; x += m_tileSize) {
32 for (int y = 0; y < height; y += m_tileSize) { 34 for (int y = 0; y < height; y += m_tileSize) {
33 gfx::Rect solidTileRect(x, y, std::min(width - x, m_tileSize), std:: min(height - y, m_tileSize)); 35 gfx::Rect solidTileRect(x, y, std::min(width - x, m_tileSize), std:: min(height - y, m_tileSize));
36
37 bool clipped = false;
38 gfx::QuadF visibleContentInTargetQuad = MathUtil::mapQuad(drawTransf orm(), gfx::QuadF(visibleContentRect()), clipped);
39 bool isAxisAlignedInTarget = !clipped && visibleContentInTargetQuad. IsRectilinear();
40 bool useAA = !isAxisAlignedInTarget;
41
42 bool leftEdgeAA = !x && useAA;
43 bool topEdgeAA = !y && useAA;
44 bool rightEdgeAA = x >= width - m_tileSize && useAA;
45 bool bottomEdgeAA = y >= height - m_tileSize && useAA;
46
34 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); 47 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
35 quad->SetNew(sharedQuadState, solidTileRect, backgroundColor()); 48 quad->SetNew(sharedQuadState, solidTileRect, DrawQuad::AntiAliasing( leftEdgeAA, topEdgeAA, rightEdgeAA, bottomEdgeAA), backgroundColor());
36 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); 49 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData);
37 } 50 }
38 } 51 }
39 } 52 }
40 53
41 const char* SolidColorLayerImpl::layerTypeAsString() const 54 const char* SolidColorLayerImpl::layerTypeAsString() const
42 { 55 {
43 return "SolidColorLayer"; 56 return "SolidColorLayer";
44 } 57 }
45 58
46 } // namespace cc 59 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698