Changeset 103264 in webkit
- Timestamp:
- Dec 19, 2011, 1:45:43 PM (14 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r103262 r103264 1 2011-12-19 Iain Merrick <husky@google.com> 2 3 [chromium] Accelerated canvas broken in threaded compositing mode 4 https://bugs.webkit.org/show_bug.cgi?id=72738 5 6 We were flushing the Skia canvas in updateCompositorResources, which 7 is illegal as it runs on the wrong thread. Moved to paintContentsIfDirty 8 instead. For correct rendering on the compositor thread, we make a copy 9 of the canvas texture in updateCompositorResources. 10 11 Removed m_textureId and pushPropertiesTo from CanvasLayerChromium, as 12 it's no longer common between Canvas2DLayerChromium and 13 WebGLLayerChromium. WebGL changes do not change functionality. 14 15 Reviewed by James Robinson. 16 17 * platform/graphics/chromium/Canvas2DLayerChromium.cpp: 18 (WebCore::Canvas2DLayerChromium::create): 19 (WebCore::Canvas2DLayerChromium::Canvas2DLayerChromium): 20 (WebCore::Canvas2DLayerChromium::~Canvas2DLayerChromium): 21 (WebCore::Canvas2DLayerChromium::setTextureId): 22 (WebCore::Canvas2DLayerChromium::contentChanged): 23 (WebCore::Canvas2DLayerChromium::drawsContent): 24 (WebCore::Canvas2DLayerChromium::paintContentsIfDirty): 25 (WebCore::Canvas2DLayerChromium::setLayerTreeHost): 26 (WebCore::Canvas2DLayerChromium::setTextureManager): 27 (WebCore::Canvas2DLayerChromium::updateCompositorResources): 28 (WebCore::Canvas2DLayerChromium::pushPropertiesTo): 29 (WebCore::Canvas2DLayerChromium::unreserveContentsTexture): 30 (WebCore::Canvas2DLayerChromium::cleanupResources): 31 * platform/graphics/chromium/Canvas2DLayerChromium.h: 32 * platform/graphics/chromium/CanvasLayerChromium.cpp: 33 (WebCore::CanvasLayerChromium::CanvasLayerChromium): 34 * platform/graphics/chromium/CanvasLayerChromium.h: 35 * platform/graphics/chromium/WebGLLayerChromium.cpp: 36 (WebCore::WebGLLayerChromium::WebGLLayerChromium): 37 (WebCore::WebGLLayerChromium::pushPropertiesTo): 38 * platform/graphics/chromium/WebGLLayerChromium.h: 39 (WebCore::WebGLLayerChromium::textureId): 40 (WebCore::WebGLLayerChromium::setTextureId): 41 * platform/graphics/chromium/cc/CCCanvasLayerImpl.h: 42 (WebCore::CCCanvasLayerImpl::textureId): 43 * platform/graphics/skia/ImageBufferSkia.cpp: 44 (WebCore::createAcceleratedCanvas): 45 1 46 2011-12-19 Mike Reed <reed@google.com> 2 47 -
trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp
r101623 r103264 35 35 #include "Canvas2DLayerChromium.h" 36 36 37 #include "cc/CCCanvasLayerImpl.h" 38 #include "cc/CCLayerTreeHost.h" 39 #include "cc/CCTextureUpdater.h" 37 40 #include "Extensions3DChromium.h" 38 41 #include "GraphicsContext3D.h" 39 #include " cc/CCLayerTreeHost.h"42 #include "LayerRendererChromium.h" // For the GLC() macro 40 43 41 44 #if USE(SKIA) … … 45 48 namespace WebCore { 46 49 47 PassRefPtr<Canvas2DLayerChromium> Canvas2DLayerChromium::create(GraphicsContext3D* context )50 PassRefPtr<Canvas2DLayerChromium> Canvas2DLayerChromium::create(GraphicsContext3D* context, const IntSize& size) 48 51 { 49 return adoptRef(new Canvas2DLayerChromium(context ));52 return adoptRef(new Canvas2DLayerChromium(context, size)); 50 53 } 51 54 52 Canvas2DLayerChromium::Canvas2DLayerChromium(GraphicsContext3D* context )55 Canvas2DLayerChromium::Canvas2DLayerChromium(GraphicsContext3D* context, const IntSize& size) 53 56 : CanvasLayerChromium(0) 54 57 , m_context(context) 58 , m_size(size) 59 , m_backTextureId(0) 60 , m_fbo(0) 55 61 { 62 GLC(m_context, m_fbo = m_context->createFramebuffer()); 56 63 } 57 64 58 65 Canvas2DLayerChromium::~Canvas2DLayerChromium() 59 66 { 67 GLC(m_context, m_context->deleteFramebuffer(m_fbo)); 60 68 } 61 69 62 bool Canvas2DLayerChromium::drawsContent() const 70 void Canvas2DLayerChromium::setTextureId(unsigned textureId) 63 71 { 64 return m_textureId && (m_context 65 && (m_context->getExtensions()->getGraphicsResetStatusARB() == GraphicsContext3D::NO_ERROR)); 66 } 67 68 void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&) 69 { 70 if (!m_needsDisplay || !drawsContent()) 71 return; 72 73 if (m_context) { 74 #if USE(SKIA) 75 GrContext* grContext = m_context->grContext(); 76 if (grContext) { 77 m_context->makeContextCurrent(); 78 grContext->flush(); 79 } 80 #endif 81 m_context->flush(); 82 } 83 84 m_updateRect = FloatRect(FloatPoint(), bounds()); 85 m_needsDisplay = false; 72 m_backTextureId = textureId; 73 setNeedsCommit(); 86 74 } 87 75 … … 90 78 if (layerTreeHost()) 91 79 layerTreeHost()->startRateLimiter(m_context); 80 81 setNeedsDisplay(); 82 } 83 84 bool Canvas2DLayerChromium::drawsContent() const 85 { 86 return m_backTextureId && !m_size.isEmpty() 87 && m_context && (m_context->getExtensions()->getGraphicsResetStatusARB() == GraphicsContext3D::NO_ERROR); 88 } 89 90 void Canvas2DLayerChromium::paintContentsIfDirty() 91 { 92 if (!drawsContent()) 93 return; 94 95 m_frontTexture->reserve(m_size, GraphicsContext3D::RGBA); 96 97 if (!needsDisplay()) 98 return; 99 100 m_needsDisplay = false; 101 102 bool success = m_context->makeContextCurrent(); 103 ASSERT_UNUSED(success, success); 104 105 #if USE(SKIA) 106 GrContext* grContext = m_context->grContext(); 107 if (grContext) 108 grContext->flush(); 109 #endif 110 111 m_context->flush(); 112 } 113 114 void Canvas2DLayerChromium::setLayerTreeHost(CCLayerTreeHost* host) 115 { 116 if (layerTreeHost() != host) 117 setTextureManager(host ? host->contentsTextureManager() : 0); 118 119 CanvasLayerChromium::setLayerTreeHost(host); 120 } 121 122 void Canvas2DLayerChromium::setTextureManager(TextureManager* textureManager) 123 { 124 if (textureManager) 125 m_frontTexture = ManagedTexture::create(textureManager); 126 else 127 m_frontTexture.clear(); 128 } 129 130 void Canvas2DLayerChromium::updateCompositorResources(GraphicsContext3D* context, CCTextureUpdater& updater) 131 { 132 if (!m_backTextureId || !m_frontTexture->isValid(m_size, GraphicsContext3D::RGBA)) 133 return; 134 135 m_frontTexture->bindTexture(context, updater.allocator()); 136 137 GLC(context, context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo)); 138 GLC(context, context->framebufferTexture2D(GraphicsContext3D::FRAMEBUFFER, GraphicsContext3D::COLOR_ATTACHMENT0, GraphicsContext3D::TEXTURE_2D, m_backTextureId, 0)); 139 GLC(context, context->copyTexImage2D(GraphicsContext3D::TEXTURE_2D, 0, GraphicsContext3D::RGBA, 0, 0, m_size.width(), m_size.height(), 0)); 140 GLC(context, context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, 0)); 141 GLC(context, context->flush()); 142 } 143 144 void Canvas2DLayerChromium::pushPropertiesTo(CCLayerImpl* layer) 145 { 146 CanvasLayerChromium::pushPropertiesTo(layer); 147 148 CCCanvasLayerImpl* canvasLayer = static_cast<CCCanvasLayerImpl*>(layer); 149 canvasLayer->setTextureId(m_frontTexture->textureId()); 150 } 151 152 void Canvas2DLayerChromium::unreserveContentsTexture() 153 { 154 m_frontTexture->unreserve(); 155 } 156 157 void Canvas2DLayerChromium::cleanupResources() 158 { 159 m_frontTexture.clear(); 92 160 } 93 161 94 162 } 163 95 164 #endif // USE(ACCELERATED_COMPOSITING) -
trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h
r98471 r103264 36 36 37 37 #include "CanvasLayerChromium.h" 38 #include "ManagedTexture.h" 38 39 39 40 namespace WebCore { … … 44 45 class Canvas2DLayerChromium : public CanvasLayerChromium { 45 46 public: 46 static PassRefPtr<Canvas2DLayerChromium> create(GraphicsContext3D* );47 static PassRefPtr<Canvas2DLayerChromium> create(GraphicsContext3D*, const IntSize&); 47 48 virtual ~Canvas2DLayerChromium(); 48 virtual bool drawsContent() const; 49 v irtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&);49 50 void setTextureId(unsigned); 50 51 51 52 virtual void contentChanged(); 52 53 54 virtual bool drawsContent() const; 55 virtual void paintContentsIfDirty(); 56 57 virtual void setLayerTreeHost(CCLayerTreeHost*); 58 virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&); 59 virtual void pushPropertiesTo(CCLayerImpl*); 60 virtual void unreserveContentsTexture(); 61 virtual void cleanupResources(); 62 53 63 private: 54 explicit Canvas2DLayerChromium(GraphicsContext3D*); 64 Canvas2DLayerChromium(GraphicsContext3D*, const IntSize&); 65 66 // Visible for testing so we can bypass setLayerTreeHost. 67 friend class Canvas2DLayerChromiumTest; 68 void setTextureManager(TextureManager*); 69 55 70 GraphicsContext3D* m_context; 71 IntSize m_size; 72 unsigned m_backTextureId; 73 Platform3DObject m_fbo; 74 OwnPtr<ManagedTexture> m_frontTexture; 56 75 }; 57 76 -
trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp
r95901 r103264 43 43 CanvasLayerChromium::CanvasLayerChromium(CCLayerDelegate* delegate) 44 44 : LayerChromium(delegate) 45 , m_hasAlpha(true)46 , m_premultipliedAlpha(true)47 , m_textureId(0)48 {49 }50 51 CanvasLayerChromium::~CanvasLayerChromium()52 45 { 53 46 } … … 58 51 } 59 52 60 void CanvasLayerChromium::pushPropertiesTo(CCLayerImpl* layer)61 {62 LayerChromium::pushPropertiesTo(layer);63 64 CCCanvasLayerImpl* canvasLayer = static_cast<CCCanvasLayerImpl*>(layer);65 canvasLayer->setTextureId(textureId());66 canvasLayer->setHasAlpha(m_hasAlpha);67 canvasLayer->setPremultipliedAlpha(m_premultipliedAlpha);68 }69 70 53 } 71 54 #endif // USE(ACCELERATED_COMPOSITING) -
trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.h
r95901 r103264 42 42 class CanvasLayerChromium : public LayerChromium { 43 43 public: 44 virtual ~CanvasLayerChromium();45 46 44 virtual PassRefPtr<CCLayerImpl> createCCLayerImpl(); 47 48 virtual void pushPropertiesTo(CCLayerImpl*);49 unsigned textureId() const { return m_textureId; }50 void setTextureId(unsigned textureId) { m_textureId = textureId; }51 45 52 46 protected: 53 47 explicit CanvasLayerChromium(CCLayerDelegate*); 54 55 bool m_hasAlpha;56 bool m_premultipliedAlpha;57 unsigned m_textureId;58 48 }; 59 49 -
trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp
r101623 r103264 50 50 WebGLLayerChromium::WebGLLayerChromium(CCLayerDelegate* delegate) 51 51 : CanvasLayerChromium(delegate) 52 , m_hasAlpha(true) 53 , m_premultipliedAlpha(true) 54 , m_textureId(0) 52 55 , m_textureChanged(true) 53 56 , m_textureUpdated(false) … … 94 97 m_textureUpdated = false; 95 98 } 99 } 100 101 void WebGLLayerChromium::pushPropertiesTo(CCLayerImpl* layer) 102 { 103 CanvasLayerChromium::pushPropertiesTo(layer); 104 105 CCCanvasLayerImpl* canvasLayer = static_cast<CCCanvasLayerImpl*>(layer); 106 canvasLayer->setTextureId(m_textureId); 107 canvasLayer->setHasAlpha(m_hasAlpha); 108 canvasLayer->setPremultipliedAlpha(m_premultipliedAlpha); 96 109 } 97 110 -
trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h
r100032 r103264 50 50 virtual ~WebGLLayerChromium(); 51 51 52 unsigned textureId() const { return m_textureId; } 53 void setTextureId(unsigned textureId) { m_textureId = textureId; } 54 52 55 virtual bool drawsContent() const; 53 56 virtual void updateCompositorResources(GraphicsContext3D*, CCTextureUpdater&); 57 virtual void pushPropertiesTo(CCLayerImpl*); 54 58 virtual void contentChanged(); 55 59 bool paintRenderedResultsToCanvas(ImageBuffer*); … … 65 69 GraphicsContext3D* layerRendererContext(); 66 70 71 bool m_hasAlpha; 72 bool m_premultipliedAlpha; 73 unsigned m_textureId; 67 74 bool m_textureChanged; 68 75 bool m_textureUpdated; -
trunk/Source/WebCore/platform/graphics/chromium/cc/CCCanvasLayerImpl.h
r95901 r103264 47 47 virtual void dumpLayerProperties(TextStream&, int indent) const; 48 48 49 unsigned textureId() const { return m_textureId; } 49 50 void setTextureId(unsigned id) { m_textureId = id; } 50 51 void setHasAlpha(bool hasAlpha) { m_hasAlpha = hasAlpha; } -
trunk/Source/WebCore/platform/graphics/skia/ImageBufferSkia.cpp
r102782 r103264 88 88 data->m_platformContext.setGraphicsContext3D(context3D); 89 89 #if USE(ACCELERATED_COMPOSITING) 90 data->m_platformLayer = Canvas2DLayerChromium::create(context3D );90 data->m_platformLayer = Canvas2DLayerChromium::create(context3D, size); 91 91 data->m_platformLayer->setTextureId(texture.get()->getTextureHandle()); 92 92 #endif -
trunk/Source/WebKit/chromium/ChangeLog
r103263 r103264 1 2011-12-19 Iain Merrick <husky@google.com> 2 3 [chromium] Accelerated canvas broken in threaded compositing mode 4 https://bugs.webkit.org/show_bug.cgi?id=72738 5 6 We were flushing the Skia canvas in updateCompositorResources, which 7 is illegal as it runs on the wrong thread. Moved to paintContentsIfDirty 8 instead. For correct rendering on the compositor thread, we make a copy 9 of the canvas texture in updateCompositorResources. 10 11 Removed m_textureId and pushPropertiesTo from CanvasLayerChromium, as 12 it's no longer common between Canvas2DLayerChromium and 13 WebGLLayerChromium. WebGL changes do not change functionality. 14 15 Reviewed by James Robinson. 16 17 * WebKit.gypi: 18 * tests/Canvas2DLayerChromiumTest.cpp: Added. 19 (WebCore::Canvas2DLayerChromiumTest::setTextureManager): 20 1 21 2011-12-19 Ryosuke Niwa <rniwa@webkit.org> 2 22 -
trunk/Source/WebKit/chromium/WebKit.gypi
r103150 r103264 55 55 'tests/ArenaTestHelpers.h', 56 56 'tests/AssociatedURLLoaderTest.cpp', 57 'tests/Canvas2DLayerChromiumTest.cpp', 57 58 'tests/CCDamageTrackerTest.cpp', 58 59 'tests/CCDelayBasedTimeSourceTest.cpp',
Note:
See TracChangeset
for help on using the changeset viewer.