1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "cc/layers/solid_color_layer_impl.h"
#include <algorithm>
#include "cc/layers/quad_sink.h"
#include "cc/quads/solid_color_draw_quad.h"
namespace cc {
SolidColorLayerImpl::SolidColorLayerImpl(LayerTreeImpl* tree_impl, int id)
: LayerImpl(tree_impl, id),
tile_size_(256) {}
SolidColorLayerImpl::~SolidColorLayerImpl() {}
scoped_ptr<LayerImpl> SolidColorLayerImpl::CreateLayerImpl(
LayerTreeImpl* tree_impl) {
return SolidColorLayerImpl::Create(tree_impl, id()).PassAs<LayerImpl>();
}
void SolidColorLayerImpl::AppendQuads(QuadSink* quad_sink,
AppendQuadsData* append_quads_data) {
SharedQuadState* shared_quad_state =
quad_sink->UseSharedQuadState(CreateSharedQuadState());
AppendDebugBorderQuad(quad_sink, 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 += tile_size_) {
for (int y = 0; y < height; y += tile_size_) {
gfx::Rect quad_rect(x,
y,
std::min(width - x, tile_size_),
std::min(height - y, tile_size_));
gfx::Rect visible_quad_rect(quad_rect);
scoped_ptr<SolidColorDrawQuad> quad = SolidColorDrawQuad::Create();
quad->SetNew(shared_quad_state,
quad_rect,
visible_quad_rect,
background_color(),
false);
quad_sink->Append(quad.PassAs<DrawQuad>());
}
}
}
const char* SolidColorLayerImpl::LayerTypeAsString() const {
return "cc::SolidColorLayerImpl";
}
} // namespace cc
|