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