summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/graphics/android/context/GraphicsOperationCollection.cpp
blob: 9e6208d4b7df0dc3f59c8b9805f42c8945dece67 (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
54
55
56
57
58
59
60
61
62
63
#define LOG_TAG "GraphicsOperationCollection"
#define LOG_NDEBUG 1

#include "config.h"
#include "GraphicsOperationCollection.h"

#include "AndroidLog.h"
#include "GraphicsContext.h"
#include "PlatformGraphicsContext.h"
#include "PlatformGraphicsContextRecording.h"

#if USE(ACCELERATED_COMPOSITING)

namespace WebCore {

GraphicsOperationCollection::GraphicsOperationCollection(const IntRect& drawArea)
    : m_drawArea(drawArea)
{
}

GraphicsOperationCollection::~GraphicsOperationCollection()
{
    for (unsigned int i = 0; i < m_operations.size(); i++)
        SkSafeUnref(m_operations[i]);
}

void GraphicsOperationCollection::apply(PlatformGraphicsContext* context)
{
    ALOGD("\nApply GraphicsOperationCollection %x, %d operations", this, m_operations.size());
    for (unsigned int i = 0; i < m_operations.size(); i++) {
        ALOGD("[%d] (%x) %s %s", i, this, m_operations[i]->name().ascii().data(),
              m_operations[i]->parameters().ascii().data());
        m_operations[i]->apply(context);
    }
}

void GraphicsOperationCollection::append(GraphicsOperation::Operation* operation)
{
    m_operations.append(operation);
}

bool GraphicsOperationCollection::isEmpty()
{
    return !m_operations.size();
}

AutoGraphicsOperationCollection::AutoGraphicsOperationCollection(const IntRect& area)
{
    m_graphicsOperationCollection = new GraphicsOperationCollection(area);
    m_platformGraphicsContext = new PlatformGraphicsContextRecording(m_graphicsOperationCollection);
    m_graphicsContext = new GraphicsContext(m_platformGraphicsContext);
}

AutoGraphicsOperationCollection::~AutoGraphicsOperationCollection()
{
    SkSafeUnref(m_graphicsOperationCollection);
    delete m_graphicsContext;
    delete m_platformGraphicsContext;
}

} // namespace WebCore

#endif // USE(ACCELERATED_COMPOSITING)