Changeset 92520 in webkit
- Timestamp:
- Aug 5, 2011 3:14:37 PM (13 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 added
- 24 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r92499 r92520 1 2011-08-05 James Robinson <jamesr@chromium.org> 2 3 [chromium] Accelerated canvas breaks when moving canvases or resources between Pages 4 https://bugs.webkit.org/show_bug.cgi?id=65402 5 6 Reviewed by Stephen White. 7 8 Use one shared GraphicsContext3D for the whole process instead of one per Page as canvases can move between 9 pages and directly draw into contexts in different pages. Also switches DrawingBufferChromium over to use a 10 directly shared the color attachment instead of copying it to a separate texture and removes the now-unnecessary 11 DrawingBuffer::didReset() call and WillPublishCallback mechanism. 12 13 * page/Page.cpp: 14 (WebCore::Page::sharedGraphicsContext3D): 15 * page/Page.h: 16 * platform/graphics/chromium/Canvas2DLayerChromium.cpp: 17 (WebCore::Canvas2DLayerChromium::~Canvas2DLayerChromium): 18 (WebCore::Canvas2DLayerChromium::updateCompositorResources): 19 (WebCore::Canvas2DLayerChromium::textureId): 20 (WebCore::Canvas2DLayerChromium::setDrawingBuffer): 21 * platform/graphics/chromium/CanvasLayerChromium.cpp: 22 (WebCore::CanvasLayerChromium::CanvasLayerChromium): 23 * platform/graphics/chromium/CanvasLayerChromium.h: 24 * platform/graphics/chromium/DrawingBufferChromium.cpp: 25 (WebCore::DrawingBuffer::DrawingBuffer): 26 (WebCore::DrawingBuffer::publishToPlatformLayer): 27 * platform/graphics/chromium/Extensions3DChromium.h: 28 * platform/graphics/chromium/WebGLLayerChromium.cpp: 29 (WebCore::WebGLLayerChromium::WebGLLayerChromium): 30 * platform/graphics/chromium/WebGLLayerChromium.h: 31 1 32 2011-08-05 Anders Carlsson <andersca@apple.com> 2 33 -
trunk/Source/WebCore/WebCore.gypi
r92500 r92520 3651 3651 'platform/graphics/gpu/Shader.cpp', 3652 3652 'platform/graphics/gpu/Shader.h', 3653 'platform/graphics/gpu/SharedGraphicsContext3D.cpp', 3654 'platform/graphics/gpu/SharedGraphicsContext3D.h', 3653 3655 'platform/graphics/gpu/Texture.cpp', 3654 3656 'platform/graphics/gpu/Texture.h', -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.cpp
r91638 r92520 67 67 #include "DrawingBuffer.h" 68 68 #include "FrameView.h" 69 #include "SharedGraphicsContext3D.h" 69 70 #if USE(ACCELERATED_COMPOSITING) 70 71 #include "RenderLayer.h" … … 142 143 #if ENABLE(DASHBOARD_SUPPORT) 143 144 , m_usesDashboardCompatibilityMode(usesDashboardCompatibilityMode) 144 #endif145 #if ENABLE(ACCELERATED_2D_CANVAS)146 , m_context3D(0)147 145 #endif 148 146 { … … 196 194 #if ENABLE(ACCELERATED_2D_CANVAS) 197 195 if (m_context3D) 198 return m_context3D-> paintsIntoCanvasBuffer();196 return m_context3D->context()->paintsIntoCanvasBuffer(); 199 197 #endif 200 198 return true; … … 2051 2049 if (!m_context3D) { 2052 2050 Page* page = canvas()->document()->page(); 2053 m_context3D = page->sharedGraphicsContext3D();2051 m_context3D = SharedGraphicsContext3D::create(page->chrome()); 2054 2052 if (!m_context3D) { 2055 2053 clearAcceleration(); … … 2064 2062 } 2065 2063 } else { 2066 m_drawingBuffer = m_context3D->c reateDrawingBuffer(canvas()->size());2064 m_drawingBuffer = m_context3D->context()->createDrawingBuffer(canvas()->size()); 2067 2065 if (!m_drawingBuffer) { 2068 2066 clearAcceleration(); … … 2071 2069 } 2072 2070 2073 ctx->setGraphicsContext3D(m_context3D .get(), m_drawingBuffer.get(), canvas()->size());2071 ctx->setGraphicsContext3D(m_context3D->context(), m_drawingBuffer.get(), canvas()->size()); 2074 2072 } 2075 2073 #endif -
trunk/Source/WebCore/html/canvas/CanvasRenderingContext2D.h
r91599 r92520 37 37 #include <wtf/Vector.h> 38 38 39 40 39 #if USE(ACCELERATED_COMPOSITING) 41 40 #include "GraphicsLayer.h" … … 57 56 #if ENABLE(ACCELERATED_2D_CANVAS) 58 57 class DrawingBuffer; 59 class GraphicsContext3D;58 class SharedGraphicsContext3D; 60 59 #endif 61 60 … … 309 308 #if ENABLE(ACCELERATED_2D_CANVAS) 310 309 RefPtr<DrawingBuffer> m_drawingBuffer; 311 RefPtr< GraphicsContext3D> m_context3D;310 RefPtr<SharedGraphicsContext3D> m_context3D; 312 311 #endif 313 312 }; -
trunk/Source/WebCore/page/Page.cpp
r92492 r92520 75 75 #include <wtf/text/StringHash.h> 76 76 77 #if ENABLE(ACCELERATED_2D_CANVAS)78 #include "GraphicsContext3D.h"79 #endif80 81 77 #if ENABLE(DOM_STORAGE) 82 78 #include "StorageArea.h" … … 747 743 } 748 744 749 GraphicsContext3D* Page::sharedGraphicsContext3D()750 {751 #if ENABLE(ACCELERATED_2D_CANVAS)752 if (!m_sharedGraphicsContext3D) {753 GraphicsContext3D::Attributes attr;754 attr.depth = false;755 attr.stencil = true;756 attr.antialias = false;757 attr.canRecoverFromContextLoss = false; // Canvas contexts can not handle lost contexts.758 m_sharedGraphicsContext3D = GraphicsContext3D::create(attr, chrome());759 }760 return m_sharedGraphicsContext3D.get();761 #else // !ENABLE(ACCELERATED_2D_CANVAS)762 return 0;763 #endif764 }765 766 745 #if ENABLE(DOM_STORAGE) 767 746 StorageNamespace* Page::sessionStorage(bool optionalCreate) -
trunk/Source/WebCore/page/Page.h
r92492 r92520 80 80 class ScrollableArea; 81 81 class Settings; 82 class GraphicsContext3D;83 82 class SpeechInput; 84 83 class SpeechInputClient; … … 260 259 static void visitedStateChanged(PageGroup*, LinkHash visitedHash); 261 260 262 GraphicsContext3D* sharedGraphicsContext3D();263 264 261 #if ENABLE(DOM_STORAGE) 265 262 StorageNamespace* sessionStorage(bool optionalCreate = true); … … 318 315 OwnPtr<DragCaretController> m_dragCaretController; 319 316 320 #if ENABLE(ACCELERATED_2D_CANVAS)321 RefPtr<GraphicsContext3D> m_sharedGraphicsContext3D;322 #endif323 324 317 #if ENABLE(DRAG_SUPPORT) 325 318 OwnPtr<DragController> m_dragController; -
trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.cpp
r91736 r92520 55 55 Canvas2DLayerChromium::~Canvas2DLayerChromium() 56 56 { 57 if (m_textureId)58 layerRendererContext()->deleteTexture(m_textureId);59 57 if (m_drawingBuffer && layerRenderer()) 60 58 layerRenderer()->removeChildContext(m_drawingBuffer->graphicsContext3D().get()); … … 73 71 if (!m_contentsDirty || !drawsContent()) 74 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_EDGE85 // 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 this92 // context (the compositor context) is actually created by the service side before the child context93 // attempts to use it (in publishToPlatformLayer).94 context->flush();95 }96 73 // Update the contents of the texture used by the compositor. 97 74 if (m_contentsDirty) { … … 101 78 } 102 79 103 void Canvas2DLayerChromium::setTextureChanged()104 {105 m_textureChanged = true;106 }107 108 80 unsigned Canvas2DLayerChromium::textureId() const 109 81 { 110 return m_ textureId;82 return m_drawingBuffer ? m_drawingBuffer->platformColorBuffer() : 0; 111 83 } 112 84 … … 118 90 119 91 m_drawingBuffer = drawingBuffer; 120 m_textureChanged = true;121 92 122 93 if (drawingBuffer && layerRenderer()) -
trunk/Source/WebCore/platform/graphics/chromium/Canvas2DLayerChromium.h
r89635 r92520 50 50 51 51 void setTextureChanged(); 52 unsigned textureId() const;52 virtual unsigned textureId() const; 53 53 void setDrawingBuffer(DrawingBuffer*); 54 54 -
trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp
r92245 r92520 43 43 CanvasLayerChromium::CanvasLayerChromium(GraphicsLayerChromium* owner) 44 44 : LayerChromium(owner) 45 , m_textureChanged(true)46 , m_textureId(0)47 45 , m_hasAlpha(true) 48 46 , m_premultipliedAlpha(true) … … 64 62 65 63 CCCanvasLayerImpl* canvasLayer = static_cast<CCCanvasLayerImpl*>(layer); 66 canvasLayer->setTextureId( m_textureId);64 canvasLayer->setTextureId(textureId()); 67 65 canvasLayer->setHasAlpha(m_hasAlpha); 68 66 canvasLayer->setPremultipliedAlpha(m_premultipliedAlpha); -
trunk/Source/WebCore/platform/graphics/chromium/CanvasLayerChromium.h
r86905 r92520 51 51 explicit CanvasLayerChromium(GraphicsLayerChromium* owner); 52 52 53 virtual unsigned textureId() const = 0; 53 54 virtual const char* layerTypeAsString() const { return "CanvasLayer"; } 54 55 55 bool m_textureChanged;56 unsigned m_textureId;57 56 bool m_hasAlpha; 58 57 bool m_premultipliedAlpha; -
trunk/Source/WebCore/platform/graphics/chromium/DrawingBufferChromium.cpp
r91736 r92520 33 33 #include "DrawingBuffer.h" 34 34 35 #include "Extensions3DChromium.h"36 35 #include "GraphicsContext3D.h" 37 38 36 #if USE(SKIA) 39 37 #include "GrContext.h" … … 63 61 } 64 62 65 66 63 DrawingBuffer::DrawingBuffer(GraphicsContext3D* context, 67 64 const IntSize& size, … … 83 80 #endif 84 81 { 85 if (!m_context->getExtensions()->supports("GL_CHROMIUM_copy_texture_to_parent_texture")) {86 m_context.clear();87 return;88 }89 82 m_fbo = context->createFramebuffer(); 90 83 context->bindFramebuffer(GraphicsContext3D::FRAMEBUFFER, m_fbo); … … 116 109 return; 117 110 118 if (m_callback)119 m_callback->willPublish();120 111 if (multisample()) 121 112 commit(); 122 unsigned parentTexture = m_platformLayer->textureId();123 // We do the copy in the canvas' (child) context so that it executes in the correct order relative to124 // other commands in the child context. This ensures that the parent texture always contains a complete125 // frame and not some intermediate result.126 113 m_context->makeContextCurrent(); 127 114 #if USE(SKIA) … … 129 116 m_grContext->flush(0); 130 117 #endif 131 static_cast<Extensions3DChromium*>(m_context->getExtensions())->copyTextureToParentTextureCHROMIUM(m_colorBuffer, parentTexture);132 118 m_context->flush(); 133 119 } 134 120 #endif 135 136 void DrawingBuffer::didReset()137 {138 #if USE(ACCELERATED_COMPOSITING)139 if (m_platformLayer)140 m_platformLayer->setTextureChanged();141 #endif142 }143 121 144 122 #if USE(ACCELERATED_COMPOSITING) -
trunk/Source/WebCore/platform/graphics/chromium/Extensions3DChromium.h
r91736 r92520 41 41 // GL_CHROMIUM_strict_attribs : indicating a GL error is generated for out-of-bounds buffer accesses. 42 42 // GL_CHROMIUM_map_sub 43 // GL_CHROMIUM_copy_texture_to_parent_texture44 43 // GL_CHROMIUM_swapbuffers_complete_callback 45 44 // GL_CHROMIUM_rate_limit_offscreen_context … … 69 68 void unmapTexSubImage2DCHROMIUM(const void*); 70 69 71 // GL_CHROMIUM_copy_texture_to_parent_texture72 void copyTextureToParentTextureCHROMIUM(unsigned texture, unsigned parentTexture);73 74 70 // GL_CHROMIUM_swapbuffers_complete_callback 75 71 class SwapBuffersCompleteCallbackCHROMIUM { -
trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.cpp
r89635 r92520 50 50 : CanvasLayerChromium(owner) 51 51 , m_context(0) 52 , m_textureId(0) 53 , m_textureChanged(true) 52 54 , m_contextSupportsRateLimitingExtension(false) 53 55 , m_rateLimitingTimer(this, &WebGLLayerChromium::rateLimitContext) -
trunk/Source/WebCore/platform/graphics/chromium/WebGLLayerChromium.h
r89635 r92520 66 66 friend class WebGLLayerChromiumRateLimitTask; 67 67 68 virtual unsigned textureId() const { return m_textureId; } 68 69 void rateLimitContext(Timer<WebGLLayerChromium>*); 69 70 … … 72 73 // layer's context to 0. 73 74 GraphicsContext3D* m_context; 75 unsigned m_textureId; 76 bool m_textureChanged; 74 77 bool m_contextSupportsRateLimitingExtension; 75 78 Timer<WebGLLayerChromium> m_rateLimitingTimer; -
trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.cpp
r92430 r92520 287 287 clearFramebuffer(); 288 288 289 didReset();290 291 289 return true; 292 290 } -
trunk/Source/WebCore/platform/graphics/gpu/DrawingBuffer.h
r92430 r92520 91 91 #endif 92 92 93 #if PLATFORM(CHROMIUM)94 class WillPublishCallback {95 WTF_MAKE_NONCOPYABLE(WillPublishCallback);96 public:97 WillPublishCallback() { }98 virtual ~WillPublishCallback() { }99 100 virtual void willPublish() = 0;101 };102 103 void setWillPublishCallback(PassOwnPtr<WillPublishCallback> callback) { m_callback = callback; }104 #endif105 106 93 #if USE(SKIA) 107 94 void setGrContext(GrContext* ctx); … … 115 102 116 103 DrawingBuffer(GraphicsContext3D*, const IntSize&, bool multisampleExtensionSupported, bool packedDepthStencilExtensionSupported); 117 118 // Platform specific function called after reset() so each platform can do extra work if needed119 void didReset();120 104 121 105 RefPtr<GraphicsContext3D> m_context; … … 138 122 139 123 #if PLATFORM(CHROMIUM) 140 OwnPtr<WillPublishCallback> m_callback;141 124 #if USE(ACCELERATED_COMPOSITING) 142 125 RefPtr<Canvas2DLayerChromium> m_platformLayer; -
trunk/Source/WebCore/platform/graphics/gpu/mac/DrawingBufferMac.mm
r85891 r92520 85 85 } 86 86 87 void DrawingBuffer::didReset()88 {89 }90 91 87 PlatformLayer* DrawingBuffer::platformLayer() 92 88 { -
trunk/Source/WebCore/platform/graphics/gpu/qt/DrawingBufferQt.cpp
r85891 r92520 72 72 } 73 73 74 void DrawingBuffer::didReset()75 {76 }77 78 74 #if USE(ACCELERATED_COMPOSITING) 79 75 PlatformLayer* DrawingBuffer::platformLayer() -
trunk/Source/WebCore/platform/graphics/gtk/DrawingBufferGtk.cpp
r85891 r92520 72 72 } 73 73 74 void DrawingBuffer::didReset()75 {76 }77 78 74 Platform3DObject DrawingBuffer::platformColorBuffer() const 79 75 { -
trunk/Source/WebKit/chromium/ChangeLog
r92487 r92520 1 2011-08-05 James Robinson <jamesr@chromium.org> 2 3 [chromium] Accelerated canvas breaks when moving canvases or resources between Pages 4 https://bugs.webkit.org/show_bug.cgi?id=65402 5 6 Reviewed by Stephen White. 7 8 Remove plumbing for copyTextureToParentTexture extension, it's no longer used or needed. 9 10 * public/WebGraphicsContext3D.h: 11 * src/Extensions3DChromium.cpp: 12 * src/GraphicsContext3DChromium.cpp: 13 * src/GraphicsContext3DInternal.h: 14 1 15 2011-08-05 Jochen Eisinger <jochen@chromium.org> 2 16 -
trunk/Source/WebKit/chromium/public/WebGraphicsContext3D.h
r91736 r92520 168 168 virtual void unmapTexSubImage2DCHROMIUM(const void*) = 0; 169 169 170 // GL_CHROMIUM_copy_texture_to_parent_texture171 virtual void copyTextureToParentTextureCHROMIUM(WebGLId texture, WebGLId parentTexture) = 0;172 173 170 // GL_CHROMIUM_request_extension 174 171 virtual WebString getRequestableExtensionsCHROMIUM() = 0; -
trunk/Source/WebKit/chromium/src/Extensions3DChromium.cpp
r91736 r92520 98 98 } 99 99 100 void Extensions3DChromium::copyTextureToParentTextureCHROMIUM(unsigned texture, unsigned parentTexture)101 {102 m_internal->copyTextureToParentTextureCHROMIUM(texture, parentTexture);103 }104 105 100 Platform3DObject Extensions3DChromium::createVertexArrayOES() 106 101 { -
trunk/Source/WebKit/chromium/src/GraphicsContext3DChromium.cpp
r92145 r92520 833 833 DELEGATE_TO_IMPL_1(unmapTexSubImage2DCHROMIUM, const void*) 834 834 835 void GraphicsContext3DInternal::copyTextureToParentTextureCHROMIUM(Platform3DObject texture, Platform3DObject parentTexture)836 {837 m_impl->setParentContext(m_webViewImpl->graphicsContext3D());838 m_impl->copyTextureToParentTextureCHROMIUM(texture, parentTexture);839 }840 841 835 DELEGATE_TO_IMPL_10(blitFramebufferCHROMIUM, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dint, GC3Dbitfield, GC3Denum) 842 836 DELEGATE_TO_IMPL_5(renderbufferStorageMultisampleCHROMIUM, GC3Denum, GC3Dsizei, GC3Denum, GC3Dsizei, GC3Dsizei) -
trunk/Source/WebKit/chromium/src/GraphicsContext3DInternal.h
r91736 r92520 273 273 void unmapTexSubImage2DCHROMIUM(const void*); 274 274 275 // GL_CHROMIUM_copy_texture_to_parent_texture276 bool supportsCopyTextureToParentTextureCHROMIUM();277 void copyTextureToParentTextureCHROMIUM(Platform3DObject texture, Platform3DObject parentTexture);278 279 275 // GL_CHROMIUM_framebuffer_multisample 280 276 void blitFramebufferCHROMIUM(GC3Dint srcX0, GC3Dint srcY0, GC3Dint srcX1, GC3Dint srcY1, GC3Dint dstX0, GC3Dint dstY0, GC3Dint dstX1, GC3Dint dstY1, GC3Dbitfield mask, GC3Denum filter);
Note: See TracChangeset
for help on using the changeset viewer.