Changeset 144072 in webkit
- Timestamp:
- Feb 26, 2013, 10:35:26 AM (14 years ago)
- Location:
- trunk/Source
- Files:
-
- 6 edited
-
Platform/ChangeLog (modified) (1 diff)
-
Platform/chromium/public/Platform.h (modified) (2 diffs)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/platform/chromium/support/GraphicsContext3DPrivate.cpp (modified) (4 diffs)
-
WebCore/platform/chromium/support/GraphicsContext3DPrivate.h (modified) (4 diffs)
-
WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/Platform/ChangeLog
r143803 r144072 1 2013-02-26 Dana Jansens <danakj@chromium.org> 2 3 Create the SharedGraphicsContext3D through its own method. 4 https://bugs.webkit.org/show_bug.cgi?id=109345 5 6 Reviewed by James Robinson. 7 8 Add Platform API methods to get shared contexts from the embedder. 9 10 * chromium/public/Platform.h: 11 (Platform): 12 (WebKit::Platform::sharedOffscreenGraphicsContext3D): 13 (WebKit::Platform::sharedOffscreenGrContext): 14 1 15 2013-02-22 Ali Juma <ajuma@chromium.org> 2 16 -
trunk/Source/Platform/chromium/public/Platform.h
r143496 r144072 44 44 #include "WebString.h" 45 45 #include "WebVector.h" 46 47 class GrContext; 46 48 47 49 namespace WebKit { … … 452 454 virtual WebGraphicsContext3D* createOffscreenGraphicsContext3D(const WebGraphicsContext3D::Attributes&) { return 0; } 453 455 456 // May return null if GPU is not supported. 457 // Returns the shared WebGraphicsContext3D. This is a singleton object for 458 // the entire process. Calling this function may destroy both the shared 459 // offscreen WebGraphicsContext3D and GrContext pointers last returned, so 460 // it should only be called from a single site. The implementor should 461 // create a new context before destroying its current context, if required, 462 // to ensure the same pointer can not be returned twice in a row for two 463 // different contexts. 464 virtual WebGraphicsContext3D* sharedOffscreenGraphicsContext3D() { return 0; } 465 466 // May return null if GPU is not supported. 467 // Returns the shared GrContext. This is a singleton object for the entire process. 468 virtual GrContext* sharedOffscreenGrContext() { return 0; } 469 454 470 // Returns true if the platform is capable of producing an offscreen context suitable for accelerating 2d canvas. 455 471 // This will return false if the platform cannot promise that contexts will be preserved across operations like -
trunk/Source/WebCore/ChangeLog
r144068 r144072 1 2013-02-26 Dana Jansens <danakj@chromium.org> 2 3 Create the SharedGraphicsContext3D through its own method. 4 https://bugs.webkit.org/show_bug.cgi?id=109345 5 6 Reviewed by James Robinson. 7 8 Allow creating a GraphicsContext3DPrivate from an externally owned 9 WebGraphicsContext3D and GrContext. Then create the shared graphics 10 context from these provided by the embedder. 11 12 This falls back to the old path if the new methods return NULL to 13 let us land this immediately and then transition the chromium side 14 over to this path. 15 16 * platform/chromium/support/GraphicsContext3DPrivate.cpp: 17 (WebCore::GraphicsContext3DPrivate::GraphicsContext3DPrivate): 18 (WebCore): 19 (WebCore::GraphicsContext3DPrivate::createGraphicsContextFromExternalWebContextAndGrContext): 20 (WebCore::GraphicsContext3DPrivate::grContext): 21 * platform/chromium/support/GraphicsContext3DPrivate.h: 22 (GraphicsContext3DPrivate): 23 (WebCore::GraphicsContext3DPrivate::webContext): 24 * platform/graphics/gpu/SharedGraphicsContext3D.cpp: 25 (WebCore::SharedGraphicsContext3DImpl::getOrCreateContext): 26 1 27 2013-02-26 Antti Koivisto <antti@apple.com> 2 28 -
trunk/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.cpp
r142028 r144072 58 58 59 59 GraphicsContext3DPrivate::GraphicsContext3DPrivate(PassOwnPtr<WebKit::WebGraphicsContext3D> webContext, bool preserveDrawingBuffer) 60 : m_impl(webContext.get()) 61 , m_ownedWebContext(webContext) 62 , m_initializedAvailableExtensions(false) 63 , m_layerComposited(false) 64 , m_preserveDrawingBuffer(preserveDrawingBuffer) 65 , m_resourceSafety(ResourceSafetyUnknown) 66 , m_grContext(0) 67 { 68 } 69 70 GraphicsContext3DPrivate::GraphicsContext3DPrivate(WebKit::WebGraphicsContext3D* webContext, GrContext* grContext, bool preserveDrawingBuffer) 60 71 : m_impl(webContext) 61 72 , m_initializedAvailableExtensions(false) … … 63 74 , m_preserveDrawingBuffer(preserveDrawingBuffer) 64 75 , m_resourceSafety(ResourceSafetyUnknown) 65 , m_grContext(0) 66 { 67 } 76 , m_grContext(grContext) 77 { 78 } 79 68 80 69 81 GraphicsContext3DPrivate::~GraphicsContext3DPrivate() … … 80 92 81 93 OwnPtr<GraphicsContext3DPrivate> priv = adoptPtr(new GraphicsContext3DPrivate(webContext, preserveDrawingBuffer)); 94 context->m_private = priv.release(); 95 return context.release(); 96 } 97 98 PassRefPtr<GraphicsContext3D> GraphicsContext3DPrivate::createGraphicsContextFromExternalWebContextAndGrContext(WebKit::WebGraphicsContext3D* webContext, GrContext* grContext, bool preserveDrawingBuffer) 99 { 100 RefPtr<GraphicsContext3D> context = adoptRef(new GraphicsContext3D(GraphicsContext3D::Attributes(), 0)); 101 102 OwnPtr<GraphicsContext3DPrivate> priv = adoptPtr(new GraphicsContext3DPrivate(webContext, grContext, preserveDrawingBuffer)); 82 103 context->m_private = priv.release(); 83 104 return context.release(); … … 131 152 132 153 interface->fCallback = bindWebGraphicsContext3DGLContextCallback; 133 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(m_impl.get()); 134 135 m_grContext.reset(GrContext::Create(kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get()))); 154 interface->fCallbackData = reinterpret_cast<GrGLInterfaceCallbackData>(m_impl); 155 156 m_ownedGrContext.reset(GrContext::Create(kOpenGL_GrBackend, reinterpret_cast<GrBackendContext>(interface.get()))); 157 m_grContext = m_ownedGrContext; 136 158 if (!m_grContext) 137 159 return 0; -
trunk/Source/WebCore/platform/chromium/support/GraphicsContext3DPrivate.h
r141943 r144072 55 55 static PassRefPtr<GraphicsContext3D> createGraphicsContextFromWebContext(PassOwnPtr<WebKit::WebGraphicsContext3D>, bool preserveDrawingBuffer = false); 56 56 57 static PassRefPtr<GraphicsContext3D> createGraphicsContextFromExternalWebContextAndGrContext(WebKit::WebGraphicsContext3D*, GrContext*, bool preserveDrawingBuffer = false); 58 57 59 // Helper function to provide access to the lower-level WebGraphicsContext3D, 58 60 // which is needed for subordinate contexts like WebGL's to share resources … … 62 64 virtual ~GraphicsContext3DPrivate(); 63 65 64 WebKit::WebGraphicsContext3D* webContext() const { return m_impl .get(); }66 WebKit::WebGraphicsContext3D* webContext() const { return m_impl; } 65 67 66 68 GrContext* grContext(); … … 87 89 private: 88 90 GraphicsContext3DPrivate(PassOwnPtr<WebKit::WebGraphicsContext3D>, bool preserveDrawingBuffer); 91 GraphicsContext3DPrivate(WebKit::WebGraphicsContext3D*, GrContext*, bool preserveDrawingBuffer); 89 92 90 93 void initializeExtensions(); 91 94 92 OwnPtr<WebKit::WebGraphicsContext3D> m_impl; 95 WebKit::WebGraphicsContext3D* m_impl; 96 OwnPtr<WebKit::WebGraphicsContext3D> m_ownedWebContext; 93 97 OwnPtr<Extensions3DChromium> m_extensions; 94 98 OwnPtr<GraphicsContext3DContextLostCallbackAdapter> m_contextLostCallbackAdapter; … … 115 119 SkBitmap m_resizingBitmap; 116 120 117 SkAutoTUnref<GrContext> m_grContext; 121 GrContext* m_grContext; 122 SkAutoTUnref<GrContext> m_ownedGrContext; 118 123 }; 119 124 -
trunk/Source/WebCore/platform/graphics/gpu/SharedGraphicsContext3D.cpp
r141943 r144072 30 30 31 31 #include "Extensions3D.h" 32 #if PLATFORM(CHROMIUM) 33 #include "GraphicsContext3DPrivate.h" 34 #include <public/Platform.h> 35 #include <public/WebGraphicsContext3D.h> 36 #endif 32 37 #include <wtf/MainThread.h> 33 38 … … 39 44 PassRefPtr<GraphicsContext3D> getOrCreateContext() 40 45 { 41 // If we lost the context, or can't make it current, create a new one.42 if (m_context && (!m_context->makeContextCurrent() || (m_context->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR)))43 m_context.clear();44 45 46 bool wasCreated = false; 46 47 47 if (!m_context) { 48 createContext(); 49 wasCreated = true; 48 #if PLATFORM(CHROMIUM) 49 WebKit::WebGraphicsContext3D* webContext = WebKit::Platform::current()->sharedOffscreenGraphicsContext3D(); 50 GrContext* grContext = WebKit::Platform::current()->sharedOffscreenGrContext(); 51 52 if (webContext && grContext) { 53 WebKit::WebGraphicsContext3D* oldWebContext = m_context ? GraphicsContext3DPrivate::extractWebGraphicsContext3D(m_context.get()) : 0; 54 GrContext* oldGrContext = m_context ? m_context->grContext() : 0; 55 if (webContext != oldWebContext || grContext != oldGrContext) 56 m_context.clear(); 57 58 if (!m_context) { 59 m_context = GraphicsContext3DPrivate::createGraphicsContextFromExternalWebContextAndGrContext(webContext, grContext); 60 wasCreated = true; 61 } 62 63 // FIXME: Don't fallback to the legacy path when chromium supports the new offscreen methods. 64 } else 65 #endif 66 { 67 // If we lost the context, or can't make it current, create a new one. 68 if (m_context && (!m_context->makeContextCurrent() || (m_context->getExtensions()->getGraphicsResetStatusARB() != GraphicsContext3D::NO_ERROR))) 69 m_context.clear(); 70 71 if (!m_context) { 72 createContext(); 73 wasCreated = true; 74 } 75 76 if (m_context && !m_context->makeContextCurrent()) 77 m_context.clear(); 50 78 } 51 52 if (m_context && !m_context->makeContextCurrent())53 m_context.clear();54 79 55 80 if (m_context && wasCreated) 56 81 m_context->getExtensions()->pushGroupMarkerEXT("SharedGraphicsContext"); 57 58 82 return m_context; 59 83 }
Note:
See TracChangeset
for help on using the changeset viewer.