|
Lines 54-61
Canvas2DLayerChromium::Canvas2DLayerChromium(DrawingBuffer* drawingBuffer, Graph
a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp_sec1
|
| 54 |
|
54 |
|
| 55 |
Canvas2DLayerChromium::~Canvas2DLayerChromium() |
55 |
Canvas2DLayerChromium::~Canvas2DLayerChromium() |
| 56 |
{ |
56 |
{ |
| 57 |
if (m_textureId) |
|
|
| 58 |
layerRendererContext()->deleteTexture(m_textureId); |
| 59 |
if (m_drawingBuffer && layerRenderer()) |
57 |
if (m_drawingBuffer && layerRenderer()) |
| 60 |
layerRenderer()->removeChildContext(m_drawingBuffer->graphicsContext3D().get()); |
58 |
layerRenderer()->removeChildContext(m_drawingBuffer->graphicsContext3D().get()); |
| 61 |
} |
59 |
} |
|
Lines 72-98
void Canvas2DLayerChromium::updateCompositorResources()
a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp_sec2
|
| 72 |
{ |
70 |
{ |
| 73 |
if (!m_contentsDirty || !drawsContent()) |
71 |
if (!m_contentsDirty || !drawsContent()) |
| 74 |
return; |
72 |
return; |
| 75 |
if (m_textureChanged) { // We have to generate a new backing texture. |
|
|
| 76 |
GraphicsContext3D* context = layerRendererContext(); |
| 77 |
if (m_textureId) |
| 78 |
context->deleteTexture(m_textureId); |
| 79 |
m_textureId = context->createTexture(); |
| 80 |
context->activeTexture(GraphicsContext3D::TEXTURE0); |
| 81 |
context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId); |
| 82 |
IntSize size = m_drawingBuffer->size(); |
| 83 |
context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, size.width(), size.height(), 0, GraphicsContext3D::RGBA, GraphicsContext3D::UNSIGNED_BYTE); |
| 84 |
// Set the min-mag filters to linear and wrap modes to GraphicsContext3D::CLAMP_TO_EDGE |
| 85 |
// to get around NPOT texture limitations of GLES. |
| 86 |
context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MIN_FILTER, GraphicsContext3D::LINEAR); |
| 87 |
context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_MAG_FILTER, GraphicsContext3D::LINEAR); |
| 88 |
context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_S, GraphicsContext3D::CLAMP_TO_EDGE); |
| 89 |
context->texParameteri(GraphicsContext3D::TEXTURE_2D, GraphicsContext3D::TEXTURE_WRAP_T, GraphicsContext3D::CLAMP_TO_EDGE); |
| 90 |
m_textureChanged = false; |
| 91 |
// The flush() here is required because we have to make sure that the texture created in this |
| 92 |
// context (the compositor context) is actually created by the service side before the child context |
| 93 |
// attempts to use it (in publishToPlatformLayer). |
| 94 |
context->flush(); |
| 95 |
} |
| 96 |
// Update the contents of the texture used by the compositor. |
73 |
// Update the contents of the texture used by the compositor. |
| 97 |
if (m_contentsDirty) { |
74 |
if (m_contentsDirty) { |
| 98 |
m_drawingBuffer->publishToPlatformLayer(); |
75 |
m_drawingBuffer->publishToPlatformLayer(); |
|
Lines 100-113
void Canvas2DLayerChromium::updateCompositorResources()
a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp_sec3
|
| 100 |
} |
77 |
} |
| 101 |
} |
78 |
} |
| 102 |
|
79 |
|
| 103 |
void Canvas2DLayerChromium::setTextureChanged() |
|
|
| 104 |
{ |
| 105 |
m_textureChanged = true; |
| 106 |
} |
| 107 |
|
| 108 |
unsigned Canvas2DLayerChromium::textureId() const |
80 |
unsigned Canvas2DLayerChromium::textureId() const |
| 109 |
{ |
81 |
{ |
| 110 |
return m_textureId; |
82 |
return m_drawingBuffer ? m_drawingBuffer->platformColorBuffer() : 0; |
| 111 |
} |
83 |
} |
| 112 |
|
84 |
|
| 113 |
void Canvas2DLayerChromium::setDrawingBuffer(DrawingBuffer* drawingBuffer) |
85 |
void Canvas2DLayerChromium::setDrawingBuffer(DrawingBuffer* drawingBuffer) |
|
Lines 117-123
void Canvas2DLayerChromium::setDrawingBuffer(DrawingBuffer* drawingBuffer)
a/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp_sec4
|
| 117 |
layerRenderer()->removeChildContext(m_drawingBuffer->graphicsContext3D().get()); |
89 |
layerRenderer()->removeChildContext(m_drawingBuffer->graphicsContext3D().get()); |
| 118 |
|
90 |
|
| 119 |
m_drawingBuffer = drawingBuffer; |
91 |
m_drawingBuffer = drawingBuffer; |
| 120 |
m_textureChanged = true; |
|
|
| 121 |
|
92 |
|
| 122 |
if (drawingBuffer && layerRenderer()) |
93 |
if (drawingBuffer && layerRenderer()) |
| 123 |
layerRenderer()->addChildContext(m_drawingBuffer->graphicsContext3D().get()); |
94 |
layerRenderer()->addChildContext(m_drawingBuffer->graphicsContext3D().get()); |