Changeset 64870 in webkit
- Timestamp:
- Aug 6, 2010 2:49:20 PM (14 years ago)
- Location:
- trunk
- Files:
-
- 12 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r64869 r64870 1 2010-08-06 James Robinson <jamesr@chromium.org> 2 3 Reviewed by Simon Fraser. 4 5 Composited canvas should be treated the same by the compositor and not be WebGL specific 6 https://bugs.webkit.org/show_bug.cgi?id=43589 7 8 This treats all GraphicsContext3D-backed layers the same instead of special casing WebGL. 9 The cross-platform change is to rename GraphicsLayer::setContentsToWebGL() to 10 GraphicsLayer::setContentsToCanvas() and to rename all implementations. 11 12 This patch also renames the chromium class used for accelerating these layers. 13 14 Cross platform changes: 15 * WebCore.gypi: 16 * platform/graphics/GraphicsLayer.h: 17 (WebCore::GraphicsLayer::setContentsToCanvas): 18 Rename the function on the base class. GraphicsLayerCA and GraphicsLayerChromium implement this. 19 * rendering/RenderLayerBacking.cpp: 20 (WebCore::isAcceleratedCanvas): 21 Helper function to see if a renderer is associated with an accelerated compositing layer. 22 (WebCore::RenderLayerBacking::updateGraphicsLayerConfiguration): 23 (WebCore::RenderLayerBacking::containsPaintedContent): 24 (WebCore::RenderLayerBacking::rendererContentChanged): 25 Chromium specific changes: 26 * platform/graphics/chromium/CanvasLayerChromium.cpp: Added. 27 (WebCore::CanvasLayerChromium::create): 28 (WebCore::CanvasLayerChromium::CanvasLayerChromium): 29 (WebCore::CanvasLayerChromium::textureId): 30 (WebCore::CanvasLayerChromium::updateTextureContents): 31 (WebCore::CanvasLayerChromium::setContext): 32 * platform/graphics/chromium/CanvasLayerChromium.h: Added. 33 (WebCore::CanvasLayerChromium::drawsContent): 34 (WebCore::CanvasLayerChromium::ownsTexture): 35 (WebCore::CanvasLayerChromium::shaderProgramId): 36 (WebCore::CanvasLayerChromium::setShaderProgramId): 37 * platform/graphics/chromium/GraphicsLayerChromium.cpp: 38 (WebCore::GraphicsLayerChromium::setContentsNeedsDisplay): 39 (WebCore::GraphicsLayerChromium::setContentsToCanvas): 40 * platform/graphics/chromium/GraphicsLayerChromium.h: 41 (WebCore::GraphicsLayerChromium::): 42 * platform/graphics/chromium/LayerRendererChromium.cpp: 43 (WebCore::LayerRendererChromium::drawLayer): 44 (WebCore::LayerRendererChromium::initializeSharedGLObjects): 45 * platform/graphics/chromium/LayerRendererChromium.h: 46 (WebCore::LayerRendererChromium::): 47 * platform/graphics/chromium/WebGLLayerChromium.cpp: Removed. 48 * platform/graphics/chromium/WebGLLayerChromium.h: Removed. 49 Mac specific changes: 50 * platform/graphics/mac/GraphicsLayerCA.h: 51 (WebCore::GraphicsLayerCA::): 52 * platform/graphics/mac/GraphicsLayerCA.mm: 53 (WebCore::GraphicsLayerCA::commitLayerChangesBeforeSublayers): 54 (WebCore::GraphicsLayerCA::updateContentsCanvasLayer): 55 (WebCore::GraphicsLayerCA::setContentsToCanvas): 56 1 57 2010-08-06 Patrick Gansterer <paroga@paroga.com> 2 58 -
trunk/WebCore/WebCore.gypi
r64857 r64870 2191 2191 'platform/graphics/cg/PatternCG.cpp', 2192 2192 'platform/graphics/cg/TransformationMatrixCG.cpp', 2193 'platform/graphics/chromium/CanvasLayerChromium.cpp', 2194 'platform/graphics/chromium/CanvasLayerChromium.h', 2193 2195 'platform/graphics/chromium/FontCacheChromiumWin.cpp', 2194 2196 'platform/graphics/chromium/FontCacheLinux.cpp', … … 2238 2240 'platform/graphics/chromium/VideoLayerChromium.cpp', 2239 2241 'platform/graphics/chromium/VideoLayerChromium.h', 2240 'platform/graphics/chromium/WebGLLayerChromium.cpp',2241 'platform/graphics/chromium/WebGLLayerChromium.h',2242 2242 'platform/graphics/filters/FEBlend.cpp', 2243 2243 'platform/graphics/filters/FEBlend.h', -
trunk/WebCore/platform/graphics/GraphicsLayer.h
r63368 r64870 299 299 virtual void setContentsToMedia(PlatformLayer*) { } // video or plug-in 300 300 virtual void setContentsBackgroundColor(const Color&) { } 301 #if ENABLE(3D_CANVAS) 302 virtual void setContentsToWebGL(PlatformLayer*) { } 303 #endif 301 virtual void setContentsToCanvas(PlatformLayer*) { } 304 302 virtual bool hasContentsLayer() const { return false; } 305 303 -
trunk/WebCore/platform/graphics/chromium/CanvasLayerChromium.cpp
r64869 r64870 33 33 #if USE(ACCELERATED_COMPOSITING) 34 34 35 #include " WebGLLayerChromium.h"35 #include "CanvasLayerChromium.h" 36 36 37 37 #include "GraphicsContext3D.h" … … 40 40 namespace WebCore { 41 41 42 unsigned WebGLLayerChromium::m_shaderProgramId = 0;42 unsigned CanvasLayerChromium::m_shaderProgramId = 0; 43 43 44 PassRefPtr< WebGLLayerChromium> WebGLLayerChromium::create(GraphicsLayerChromium* owner)44 PassRefPtr<CanvasLayerChromium> CanvasLayerChromium::create(GraphicsLayerChromium* owner) 45 45 { 46 return adoptRef(new WebGLLayerChromium(owner));46 return adoptRef(new CanvasLayerChromium(owner)); 47 47 } 48 48 49 WebGLLayerChromium::WebGLLayerChromium(GraphicsLayerChromium* owner)49 CanvasLayerChromium::CanvasLayerChromium(GraphicsLayerChromium* owner) 50 50 : LayerChromium(owner) 51 51 , m_context(0) … … 55 55 } 56 56 57 unsigned WebGLLayerChromium::textureId()57 unsigned CanvasLayerChromium::textureId() 58 58 { 59 59 return m_textureId; 60 60 } 61 61 62 void WebGLLayerChromium::updateTextureContents(unsigned textureId)62 void CanvasLayerChromium::updateTextureContents(unsigned textureId) 63 63 { 64 64 ASSERT(textureId == m_textureId); … … 81 81 } 82 82 83 void WebGLLayerChromium::setContext(const GraphicsContext3D* context)83 void CanvasLayerChromium::setContext(const GraphicsContext3D* context) 84 84 { 85 85 m_context = const_cast<GraphicsContext3D*>(context); -
trunk/WebCore/platform/graphics/chromium/CanvasLayerChromium.h
r64869 r64870 30 30 31 31 32 #ifndef WebGLLayerChromium_h33 #define WebGLLayerChromium_h32 #ifndef CanvasLayerChromium_h 33 #define CanvasLayerChromium_h 34 34 35 35 #if USE(ACCELERATED_COMPOSITING) … … 41 41 class GraphicsContext3D; 42 42 43 // A Layer that contains a WebGL element.44 class WebGLLayerChromium : public LayerChromium {43 // A Layer containing a WebGL or accelerated 2d canvas 44 class CanvasLayerChromium : public LayerChromium { 45 45 public: 46 static PassRefPtr< WebGLLayerChromium> create(GraphicsLayerChromium* owner = 0);46 static PassRefPtr<CanvasLayerChromium> create(GraphicsLayerChromium* owner = 0); 47 47 virtual bool drawsContent() { return m_context; } 48 48 virtual bool ownsTexture() { return true; } … … 56 56 57 57 private: 58 WebGLLayerChromium(GraphicsLayerChromium* owner);58 explicit CanvasLayerChromium(GraphicsLayerChromium* owner); 59 59 GraphicsContext3D* m_context; 60 60 unsigned m_textureId; -
trunk/WebCore/platform/graphics/chromium/GraphicsLayerChromium.cpp
r64656 r64870 54 54 #include "SystemTime.h" 55 55 #include "TransformLayerChromium.h" 56 #include "WebGLLayerChromium.h" 56 57 57 #include <wtf/CurrentTime.h> 58 58 #include <wtf/StringExtras.h> … … 286 286 } 287 287 288 void GraphicsLayerChromium::setContentsNeedsDisplay() 289 { 290 if (m_contentsLayer) 291 m_contentsLayer->setNeedsDisplay(); 292 } 288 293 void GraphicsLayerChromium::setNeedsDisplay() 289 294 { … … 335 340 } 336 341 337 #if ENABLE(3D_CANVAS) 338 void GraphicsLayerChromium::setContentsToWebGL(PlatformLayer* platformLayer) 342 void GraphicsLayerChromium::setContentsToCanvas(PlatformLayer* platformLayer) 339 343 { 340 344 bool childrenChanged = false; 341 345 if (platformLayer) { 342 if (!m_contentsLayer.get() || m_contentsLayerPurpose != ContentsLayerForWebGL) {343 WebGLLayerChromium* webGLLayer = static_cast<WebGLLayerChromium*>(platformLayer);344 setupContentsLayer( webGLLayer);345 m_contentsLayer = webGLLayer;346 m_contentsLayerPurpose = ContentsLayerFor WebGL;346 platformLayer->setOwner(this); 347 if (!m_contentsLayer.get() || m_contentsLayerPurpose != ContentsLayerForCanvas) { 348 setupContentsLayer(platformLayer); 349 m_contentsLayer = platformLayer; 350 m_contentsLayerPurpose = ContentsLayerForCanvas; 347 351 childrenChanged = true; 348 352 } 349 platformLayer->setOwner(this);350 353 platformLayer->setNeedsDisplay(); 351 354 updateContentsRect(); … … 362 365 updateSublayerList(); 363 366 } 364 #endif365 367 366 368 void GraphicsLayerChromium::setContentsToMedia(PlatformLayer* layer) -
trunk/WebCore/platform/graphics/chromium/GraphicsLayerChromium.h
r63723 r64870 82 82 virtual void setNeedsDisplay(); 83 83 virtual void setNeedsDisplayInRect(const FloatRect&); 84 virtual void setContentsNeedsDisplay(); 84 85 85 86 virtual void setContentsRect(const IntRect&); … … 87 88 virtual void setContentsToImage(Image*); 88 89 virtual void setContentsToMedia(PlatformLayer*); 89 virtual void setContentsTo WebGL(PlatformLayer*);90 virtual void setContentsToCanvas(PlatformLayer*); 90 91 91 92 virtual PlatformLayer* platformLayer() const; … … 138 139 ContentsLayerForImage, 139 140 ContentsLayerForVideo, 140 ContentsLayerFor WebGL141 ContentsLayerForCanvas 141 142 }; 142 143 -
trunk/WebCore/platform/graphics/chromium/LayerRendererChromium.cpp
r64656 r64870 35 35 #include "LayerRendererChromium.h" 36 36 37 #include "CanvasLayerChromium.h" 37 38 #include "GLES2Context.h" 38 39 #include "LayerChromium.h" 39 40 #include "NotImplemented.h" 40 41 #include "TransformLayerChromium.h" 41 #include "WebGLLayerChromium.h"42 42 #if PLATFORM(SKIA) 43 43 #include "NativeImageSkia.h" … … 692 692 // Update the backing texture contents for any dirty portion of the layer. 693 693 layer->updateTextureContents(textureId); 694 m_gles2Context->makeCurrent(); 694 695 } 695 696 … … 771 772 "} \n"; 772 773 773 // WebGLlayers need to be flipped vertically and their colors shouldn't be774 // Canvas layers need to be flipped vertically and their colors shouldn't be 774 775 // swizzled. 775 char webGLFragmentShaderString[] =776 char canvasFragmentShaderString[] = 776 777 "precision mediump float; \n" 777 778 "varying vec2 v_texCoord; \n" … … 820 821 LayerChromium::setShaderProgramId(ContentLayerProgram); 821 822 822 if (!createLayerShader( WebGLLayerProgram, vertexShaderString, webGLFragmentShaderString)) {823 LOG_ERROR("Failed to create shader program for WebGLlayers");823 if (!createLayerShader(CanvasLayerProgram, vertexShaderString, canvasFragmentShaderString)) { 824 LOG_ERROR("Failed to create shader program for Canvas layers"); 824 825 return false; 825 826 } 826 WebGLLayerChromium::setShaderProgramId(WebGLLayerProgram);827 CanvasLayerChromium::setShaderProgramId(CanvasLayerProgram); 827 828 828 829 if (!createLayerShader(ScrollLayerProgram, vertexShaderString, scrollFragmentShaderString)) { … … 839 840 // avoid binding re-binding the vertex attributes. 840 841 bindCommonAttribLocations(ContentLayerProgram); 841 bindCommonAttribLocations( WebGLLayerProgram);842 bindCommonAttribLocations(CanvasLayerProgram); 842 843 bindCommonAttribLocations(DebugBorderProgram); 843 844 bindCommonAttribLocations(ScrollLayerProgram); -
trunk/WebCore/platform/graphics/chromium/LayerRendererChromium.h
r64656 r64870 89 89 90 90 private: 91 enum ShaderProgramType { DebugBorderProgram, ScrollLayerProgram, ContentLayerProgram, WebGLLayerProgram, NumShaderProgramTypes };91 enum ShaderProgramType { DebugBorderProgram, ScrollLayerProgram, ContentLayerProgram, CanvasLayerProgram, NumShaderProgramTypes }; 92 92 93 93 void updateLayersRecursive(LayerChromium* layer, const TransformationMatrix& parentMatrix, float opacity, const IntRect& visibleRect); -
trunk/WebCore/platform/graphics/mac/GraphicsLayerCA.h
r63368 r64870 104 104 virtual void setContentsToImage(Image*); 105 105 virtual void setContentsToMedia(PlatformLayer*); 106 #if ENABLE(3D_CANVAS) 107 virtual void setContentsToWebGL(PlatformLayer*); 108 #endif 106 virtual void setContentsToCanvas(PlatformLayer*); 107 109 108 virtual bool hasContentsLayer() const { return m_contentsLayer; } 110 109 … … 259 258 void updateContentsImage(); 260 259 void updateContentsMediaLayer(); 261 #if ENABLE(3D_CANVAS) 262 void updateContentsWebGLLayer(); 263 #endif 260 void updateContentsCanvasLayer(); 264 261 void updateContentsRect(); 265 262 void updateGeometryOrientation(); … … 306 303 ContentsImageChanged = 1 << 17, 307 304 ContentsMediaLayerChanged = 1 << 18, 308 #if ENABLE(3D_CANVAS) 309 ContentsWebGLLayerChanged = 1 << 19, 310 #endif 305 ContentsCanvasLayerChanged = 1 << 19, 311 306 ContentsRectChanged = 1 << 20, 312 307 GeometryOrientationChanged = 1 << 21, … … 333 328 NoContentsLayer = 0, 334 329 ContentsLayerForImage, 335 ContentsLayerForMedia 336 #if ENABLE(3D_CANVAS) 337 , ContentsLayerForWebGL 338 #endif 330 ContentsLayerForMedia, 331 ContentsLayerForCanvas 339 332 }; 340 333 -
trunk/WebCore/platform/graphics/mac/GraphicsLayerCA.mm
r63835 r64870 918 918 updateContentsMediaLayer(); 919 919 920 #if ENABLE(3D_CANVAS) 921 if (m_uncommittedChanges & ContentsWebGLLayerChanged) // Needs to happen before ChildrenChanged 922 updateContentsWebGLLayer(); 923 #endif 920 if (m_uncommittedChanges & ContentsCanvasLayerChanged) // Needs to happen before ChildrenChanged 921 updateContentsCanvasLayer(); 924 922 925 923 if (m_uncommittedChanges & BackgroundColorChanged) // Needs to happen before ChildrenChanged, and after updating image or video … … 1397 1395 } 1398 1396 1399 #if ENABLE(3D_CANVAS) 1400 void GraphicsLayerCA::updateContentsWebGLLayer() 1401 { 1402 // WebGLLayer was set as m_contentsLayer, and will get parented in updateSublayerList(). 1397 void GraphicsLayerCA::updateContentsCanvasLayer() 1398 { 1399 // CanvasLayer was set as m_contentsLayer, and will get parented in updateSublayerList(). 1403 1400 if (m_contentsLayer) { 1404 1401 setupContentsLayer(m_contentsLayer.get()); … … 1407 1404 } 1408 1405 } 1409 #endif 1410 1406 1411 1407 void GraphicsLayerCA::updateContentsRect() 1412 1408 { … … 1723 1719 } 1724 1720 1725 #if ENABLE(3D_CANVAS) 1726 void GraphicsLayerCA::setContentsToWebGL(PlatformLayer* webglLayer) 1727 { 1728 if (webglLayer == m_contentsLayer) 1721 void GraphicsLayerCA::setContentsToCanvas(PlatformLayer* canvasLayer) 1722 { 1723 if (canvasLayer == m_contentsLayer) 1729 1724 return; 1730 1725 1731 m_contentsLayer = webglLayer;1726 m_contentsLayer = canvasLayer; 1732 1727 if (m_contentsLayer && [m_contentsLayer.get() respondsToSelector:@selector(setLayerOwner:)]) 1733 1728 [(id)m_contentsLayer.get() setLayerOwner:this]; 1734 1729 1735 m_contentsLayerPurpose = webglLayer ? ContentsLayerForWebGL: NoContentsLayer;1730 m_contentsLayerPurpose = canvasLayer ? ContentsLayerForCanvas : NoContentsLayer; 1736 1731 1737 1732 noteSublayersChanged(); 1738 noteLayerPropertyChanged(ContentsWebGLLayerChanged); 1739 } 1740 #endif 1733 noteLayerPropertyChanged(ContentsCanvasLayerChanged); 1734 } 1741 1735 1742 1736 void GraphicsLayerCA::repaintLayerDirtyRects() -
trunk/WebCore/rendering/RenderLayerBacking.cpp
r64298 r64870 29 29 30 30 #include "AnimationController.h" 31 #if ENABLE(3D_CANVAS) 32 #include "WebGLRenderingContext.h" 33 #endif 31 #include "CanvasRenderingContext.h" 34 32 #include "CSSPropertyNames.h" 35 33 #include "CSSStyleSelector.h" 36 34 #include "FrameView.h" 37 35 #include "GraphicsContext.h" 36 #include "GraphicsContext3D.h" 38 37 #include "GraphicsLayer.h" 39 38 #include "HTMLCanvasElement.h" … … 67 66 static IntRect clipBox(RenderBox* renderer); 68 67 69 static inline bool is3DCanvas(RenderObject* renderer) 70 { 71 #if ENABLE(3D_CANVAS) 72 if (renderer->isCanvas()) 73 return static_cast<HTMLCanvasElement*>(renderer->node())->is3D(); 68 static inline bool isAcceleratedCanvas(RenderObject* renderer) 69 { 70 #if ENABLE(3D_CANVAS) || ENABLE(ACCELERATED_2D_CANVAS) 71 if (renderer->isCanvas()) { 72 HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(renderer->node()); 73 if (CanvasRenderingContext* context = canvas->renderingContext()) 74 return context->isAccelerated(); 75 } 74 76 #else 75 77 UNUSED_PARAM(renderer); … … 253 255 } 254 256 #endif 255 #if ENABLE(3D_CANVAS) 256 else if (is 3DCanvas(renderer())) {257 #if ENABLE(3D_CANVAS) || ENABLE(ACCELERATED_2D_CANVAS) 258 else if (isAcceleratedCanvas(renderer())) { 257 259 HTMLCanvasElement* canvas = static_cast<HTMLCanvasElement*>(renderer()->node()); 258 WebGLRenderingContext* context = static_cast<WebGLRenderingContext*>(canvas->renderingContext()); 259 if (context->graphicsContext3D()->platformLayer()) 260 m_graphicsLayer->setContentsToWebGL(context->graphicsContext3D()->platformLayer()); 260 if (CanvasRenderingContext* context = canvas->renderingContext()) 261 if (context->graphicsContext3D()) 262 if (PlatformLayer* pl = context->graphicsContext3D()->platformLayer()) 263 m_graphicsLayer->setContentsToCanvas(pl); 261 264 } 262 265 #endif … … 757 760 // FIXME: we could optimize cases where the image, video or canvas is known to fill the border box entirely, 758 761 // and set background color on the layer in that case, instead of allocating backing store and painting. 759 if (renderer()->isVideo() || is3DCanvas(renderer()))762 if (renderer()->isVideo()) 760 763 return hasBoxDecorationsOrBackground(renderer()); 764 #if ENABLE(3D_CANVAS) || ENABLE(ACCELERATED_2D_CANVAS) 765 if (isAcceleratedCanvas(renderer())) 766 return hasBoxDecorationsOrBackground(renderer()); 767 #endif 761 768 762 769 return true; … … 778 785 } 779 786 780 #if ENABLE(3D_CANVAS) 781 if (is 3DCanvas(renderer())) {787 #if ENABLE(3D_CANVAS) || ENABLE(ACCELERATED_2D_CANVAS) 788 if (isAcceleratedCanvas(renderer())) { 782 789 m_graphicsLayer->setContentsNeedsDisplay(); 783 790 return; -
trunk/WebKit/chromium/ChangeLog
r64861 r64870 1 2010-08-06 James Robinson <jamesr@chromium.org> 2 3 Reviewed by Simon Fraser. 4 5 Composited canvas should be treated the same by the compositor and not be WebGL specific 6 https://bugs.webkit.org/show_bug.cgi?id=43589 7 8 Initializes the platformLayer as a CanvasLayerChromium, not a WebGLLayerChromium. 9 The layer itself isn't WebGL-specific. 10 11 * src/GraphicsContext3D.cpp: 12 (WebCore::GraphicsContext3DInternal::initialize): 13 (WebCore::GraphicsContext3DInternal::platformLayer): 14 (WebCore::GraphicsContext3D::platformLayer): 15 1 16 2010-08-06 Jessie Berlin <jberlin@apple.com> 2 17 -
trunk/WebKit/chromium/src/GraphicsContext3D.cpp
r64767 r64870 36 36 37 37 #include "CachedImage.h" 38 #include "CanvasLayerChromium.h" 38 39 #include "CanvasRenderingContext.h" 39 40 #include "Chrome.h" … … 47 48 #include "Int8Array.h" 48 49 #include "Uint8Array.h" 49 #include "WebGLLayerChromium.h"50 50 #include "WebGraphicsContext3D.h" 51 51 #include "WebGraphicsContext3DDefaultImpl.h" … … 112 112 113 113 #if USE(ACCELERATED_COMPOSITING) 114 WebGLLayerChromium* platformLayer() const;114 CanvasLayerChromium* platformLayer() const; 115 115 #endif 116 116 bool isGLES2Compliant() const; … … 305 305 OwnPtr<WebKit::WebGraphicsContext3D> m_impl; 306 306 #if USE(ACCELERATED_COMPOSITING) 307 RefPtr< WebGLLayerChromium> m_compositingLayer;307 RefPtr<CanvasLayerChromium> m_compositingLayer; 308 308 #endif 309 309 #if PLATFORM(SKIA) … … 366 366 367 367 #if USE(ACCELERATED_COMPOSITING) 368 m_compositingLayer = WebGLLayerChromium::create(0);368 m_compositingLayer = CanvasLayerChromium::create(0); 369 369 #endif 370 370 return true; … … 387 387 388 388 #if USE(ACCELERATED_COMPOSITING) 389 WebGLLayerChromium* GraphicsContext3DInternal::platformLayer() const389 CanvasLayerChromium* GraphicsContext3DInternal::platformLayer() const 390 390 { 391 391 return m_compositingLayer.get(); … … 1047 1047 PlatformLayer* GraphicsContext3D::platformLayer() const 1048 1048 { 1049 WebGLLayerChromium* webGLLayer = m_internal->platformLayer();1050 webGLLayer->setContext(this);1051 return webGLLayer;1049 CanvasLayerChromium* canvasLayer = m_internal->platformLayer(); 1050 canvasLayer->setContext(this); 1051 return canvasLayer; 1052 1052 } 1053 1053 #endif
Note: See TracChangeset
for help on using the changeset viewer.