summaryrefslogtreecommitdiffstats
path: root/cc/CCSolidColorLayerImpl.cpp
blob: abf8d489336feb59f17339056bf524a377c787e5 (plain)
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
// 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 "config.h"

#if USE(ACCELERATED_COMPOSITING)

#include "CCSolidColorLayerImpl.h"

#include "CCQuadSink.h"
#include "CCSolidColorDrawQuad.h"
#include <wtf/MathExtras.h>

using namespace std;
using WebKit::WebTransformationMatrix;

namespace cc {

CCSolidColorLayerImpl::CCSolidColorLayerImpl(int id)
    : CCLayerImpl(id)
    , m_tileSize(256)
{
}

CCSolidColorLayerImpl::~CCSolidColorLayerImpl()
{
}

void CCSolidColorLayerImpl::appendQuads(CCQuadSink& quadSink, CCAppendQuadsData& appendQuadsData)
{
    CCSharedQuadState* sharedQuadState = quadSink.useSharedQuadState(createSharedQuadState());
    appendDebugBorderQuad(quadSink, sharedQuadState, appendQuadsData);

    // 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 = contentBounds().width();
    int height = contentBounds().height();
    for (int x = 0; x < width; x += m_tileSize) {
        for (int y = 0; y < height; y += m_tileSize) {
            IntRect solidTileRect(x, y, min(width - x, m_tileSize), min(height - y, m_tileSize));
            quadSink.append(CCSolidColorDrawQuad::create(sharedQuadState, solidTileRect, backgroundColor()).PassAs<CCDrawQuad>(), appendQuadsData);
        }
    }
}

const char* CCSolidColorLayerImpl::layerTypeAsString() const
{
    return "SolidColorLayer";
}

} // namespace cc
#endif // USE(ACCELERATED_COMPOSITING)