| OLD | NEW |
| 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/quad_sink.h" | 7 #include "cc/quad_sink.h" |
| 8 #include "cc/solid_color_draw_quad.h" | 8 #include "cc/solid_color_draw_quad.h" |
| 9 | 9 |
| 10 namespace cc { | 10 namespace cc { |
| 11 | 11 |
| 12 SolidColorLayerImpl::SolidColorLayerImpl(LayerTreeImpl* treeImpl, int id) | 12 SolidColorLayerImpl::SolidColorLayerImpl(LayerTreeImpl* treeImpl, int id) |
| 13 : LayerImpl(treeImpl, id) | 13 : LayerImpl(treeImpl, id) |
| 14 , m_tileSize(256) | 14 , m_tileSize(256) |
| 15 { | 15 { |
| 16 } | 16 } |
| 17 | 17 |
| 18 SolidColorLayerImpl::~SolidColorLayerImpl() | 18 SolidColorLayerImpl::~SolidColorLayerImpl() |
| 19 { | 19 { |
| 20 } | 20 } |
| 21 | 21 |
| 22 scoped_ptr<LayerImpl> SolidColorLayerImpl::createLayerImpl(LayerTreeImpl* treeIm
pl) |
| 23 { |
| 24 return SolidColorLayerImpl::create(treeImpl, id()).PassAs<LayerImpl>(); |
| 25 } |
| 26 |
| 22 void SolidColorLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appen
dQuadsData) | 27 void SolidColorLayerImpl::appendQuads(QuadSink& quadSink, AppendQuadsData& appen
dQuadsData) |
| 23 { | 28 { |
| 24 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ
uadState()); | 29 SharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQ
uadState()); |
| 25 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); | 30 appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData); |
| 26 | 31 |
| 27 // We create a series of smaller quads instead of just one large one so that
the | 32 // We create a series of smaller quads instead of just one large one so that
the |
| 28 // culler can reduce the total pixels drawn. | 33 // culler can reduce the total pixels drawn. |
| 29 int width = contentBounds().width(); | 34 int width = contentBounds().width(); |
| 30 int height = contentBounds().height(); | 35 int height = contentBounds().height(); |
| 31 for (int x = 0; x < width; x += m_tileSize) { | 36 for (int x = 0; x < width; x += m_tileSize) { |
| 32 for (int y = 0; y < height; y += m_tileSize) { | 37 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)); | 38 gfx::Rect solidTileRect(x, y, std::min(width - x, m_tileSize), std::
min(height - y, m_tileSize)); |
| 34 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); | 39 scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create(); |
| 35 quad->SetNew(sharedQuadState, solidTileRect, backgroundColor()); | 40 quad->SetNew(sharedQuadState, solidTileRect, backgroundColor()); |
| 36 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); | 41 quadSink.append(quad.PassAs<DrawQuad>(), appendQuadsData); |
| 37 } | 42 } |
| 38 } | 43 } |
| 39 } | 44 } |
| 40 | 45 |
| 41 const char* SolidColorLayerImpl::layerTypeAsString() const | 46 const char* SolidColorLayerImpl::layerTypeAsString() const |
| 42 { | 47 { |
| 43 return "SolidColorLayer"; | 48 return "SolidColorLayer"; |
| 44 } | 49 } |
| 45 | 50 |
| 46 } // namespace cc | 51 } // namespace cc |
| OLD | NEW |