Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp

Issue 7274032: Merge 89635 - 2011-06-23 John Bates <jbates@google.com> (Closed) Base URL: http://svn.webkit.org/repository/webkit/branches/chromium/782/
Patch Set: Created 9 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 17 matching lines...) Expand all
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 32
33 #if USE(ACCELERATED_COMPOSITING) 33 #if USE(ACCELERATED_COMPOSITING)
34 34
35 #include "Canvas2DLayerChromium.h" 35 #include "Canvas2DLayerChromium.h"
36 36
37 #include "DrawingBuffer.h" 37 #include "DrawingBuffer.h"
38 #include "Extensions3DChromium.h"
38 #include "GraphicsContext3D.h" 39 #include "GraphicsContext3D.h"
39 #include "LayerRendererChromium.h" 40 #include "LayerRendererChromium.h"
40 41
41 namespace WebCore { 42 namespace WebCore {
42 43
43 PassRefPtr<Canvas2DLayerChromium> Canvas2DLayerChromium::create(DrawingBuffer* d rawingBuffer, GraphicsLayerChromium* owner) 44 PassRefPtr<Canvas2DLayerChromium> Canvas2DLayerChromium::create(DrawingBuffer* d rawingBuffer, GraphicsLayerChromium* owner)
44 { 45 {
45 return adoptRef(new Canvas2DLayerChromium(drawingBuffer, owner)); 46 return adoptRef(new Canvas2DLayerChromium(drawingBuffer, owner));
46 } 47 }
47 48
48 Canvas2DLayerChromium::Canvas2DLayerChromium(DrawingBuffer* drawingBuffer, Graph icsLayerChromium* owner) 49 Canvas2DLayerChromium::Canvas2DLayerChromium(DrawingBuffer* drawingBuffer, Graph icsLayerChromium* owner)
49 : CanvasLayerChromium(owner) 50 : CanvasLayerChromium(owner)
50 , m_drawingBuffer(drawingBuffer) 51 , m_drawingBuffer(drawingBuffer)
51 { 52 {
52 } 53 }
53 54
54 Canvas2DLayerChromium::~Canvas2DLayerChromium() 55 Canvas2DLayerChromium::~Canvas2DLayerChromium()
55 { 56 {
56 if (m_textureId) 57 if (m_textureId)
57 layerRendererContext()->deleteTexture(m_textureId); 58 layerRendererContext()->deleteTexture(m_textureId);
58 if (m_drawingBuffer && layerRenderer()) 59 if (m_drawingBuffer && layerRenderer())
59 layerRenderer()->removeChildContext(m_drawingBuffer->graphicsContext3D() .get()); 60 layerRenderer()->removeChildContext(m_drawingBuffer->graphicsContext3D() .get());
60 } 61 }
61 62
63 bool Canvas2DLayerChromium::drawsContent() const
64 {
65 GraphicsContext3D* context;
66 return (m_drawingBuffer
67 && (context = m_drawingBuffer->graphicsContext3D().get())
68 && (context->getExtensions()->getGraphicsResetStatusARB() == Graphic sContext3D::NO_ERROR));
69 }
70
62 void Canvas2DLayerChromium::updateCompositorResources() 71 void Canvas2DLayerChromium::updateCompositorResources()
63 { 72 {
64 if (!m_contentsDirty || !m_drawingBuffer) 73 if (!m_contentsDirty || !drawsContent())
65 return; 74 return;
66 if (m_textureChanged) { // We have to generate a new backing texture. 75 if (m_textureChanged) { // We have to generate a new backing texture.
67 GraphicsContext3D* context = layerRendererContext(); 76 GraphicsContext3D* context = layerRendererContext();
68 if (m_textureId) 77 if (m_textureId)
69 context->deleteTexture(m_textureId); 78 context->deleteTexture(m_textureId);
70 m_textureId = context->createTexture(); 79 m_textureId = context->createTexture();
71 context->activeTexture(GraphicsContext3D::TEXTURE0); 80 context->activeTexture(GraphicsContext3D::TEXTURE0);
72 context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId); 81 context->bindTexture(GraphicsContext3D::TEXTURE_2D, m_textureId);
73 IntSize size = m_drawingBuffer->size(); 82 IntSize size = m_drawingBuffer->size();
74 context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, Graphi csContext3D::RGBA, size.width(), size.height(), 0, GraphicsContext3D::RGBA, Grap hicsContext3D::UNSIGNED_BYTE); 83 context->texImage2DResourceSafe(GraphicsContext3D::TEXTURE_2D, 0, Graphi csContext3D::RGBA, size.width(), size.height(), 0, GraphicsContext3D::RGBA, Grap hicsContext3D::UNSIGNED_BYTE);
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 if (newLayerRenderer) 135 if (newLayerRenderer)
127 newLayerRenderer->addChildContext(m_drawingBuffer->graphicsConte xt3D().get()); 136 newLayerRenderer->addChildContext(m_drawingBuffer->graphicsConte xt3D().get());
128 } 137 }
129 138
130 LayerChromium::setLayerRenderer(newLayerRenderer); 139 LayerChromium::setLayerRenderer(newLayerRenderer);
131 } 140 }
132 } 141 }
133 142
134 } 143 }
135 #endif // USE(ACCELERATED_COMPOSITING) 144 #endif // USE(ACCELERATED_COMPOSITING)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698