• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #define LOG_TAG "GraphicsOperationCollection"
2 #define LOG_NDEBUG 1
3 
4 #include "config.h"
5 #include "GraphicsOperationCollection.h"
6 
7 #include "AndroidLog.h"
8 #include "GraphicsContext.h"
9 #include "PlatformGraphicsContext.h"
10 #include "PlatformGraphicsContextRecording.h"
11 
12 #if USE(ACCELERATED_COMPOSITING)
13 
14 namespace WebCore {
15 
GraphicsOperationCollection(const IntRect & drawArea)16 GraphicsOperationCollection::GraphicsOperationCollection(const IntRect& drawArea)
17     : m_drawArea(drawArea)
18 {
19 }
20 
~GraphicsOperationCollection()21 GraphicsOperationCollection::~GraphicsOperationCollection()
22 {
23     for (unsigned int i = 0; i < m_operations.size(); i++)
24         SkSafeUnref(m_operations[i]);
25 }
26 
apply(PlatformGraphicsContext * context)27 void GraphicsOperationCollection::apply(PlatformGraphicsContext* context)
28 {
29     ALOGD("\nApply GraphicsOperationCollection %x, %d operations", this, m_operations.size());
30     for (unsigned int i = 0; i < m_operations.size(); i++) {
31         ALOGD("[%d] (%x) %s %s", i, this, m_operations[i]->name().ascii().data(),
32               m_operations[i]->parameters().ascii().data());
33         m_operations[i]->apply(context);
34     }
35 }
36 
append(GraphicsOperation::Operation * operation)37 void GraphicsOperationCollection::append(GraphicsOperation::Operation* operation)
38 {
39     m_operations.append(operation);
40 }
41 
isEmpty()42 bool GraphicsOperationCollection::isEmpty()
43 {
44     return !m_operations.size();
45 }
46 
AutoGraphicsOperationCollection(const IntRect & area)47 AutoGraphicsOperationCollection::AutoGraphicsOperationCollection(const IntRect& area)
48 {
49     m_graphicsOperationCollection = new GraphicsOperationCollection(area);
50     m_platformGraphicsContext = new PlatformGraphicsContextRecording(m_graphicsOperationCollection);
51     m_graphicsContext = new GraphicsContext(m_platformGraphicsContext);
52 }
53 
~AutoGraphicsOperationCollection()54 AutoGraphicsOperationCollection::~AutoGraphicsOperationCollection()
55 {
56     SkSafeUnref(m_graphicsOperationCollection);
57     delete m_graphicsContext;
58     delete m_platformGraphicsContext;
59 }
60 
61 } // namespace WebCore
62 
63 #endif // USE(ACCELERATED_COMPOSITING)
64