Chromium Code Reviews| Index: Source/core/platform/graphics/Canvas2DLayerBridge.cpp |
| diff --git a/Source/core/platform/graphics/Canvas2DLayerBridge.cpp b/Source/core/platform/graphics/Canvas2DLayerBridge.cpp |
| index f7e911ca33b2d907134986ca2b647367234e92f9..e676a68b57dbb6992cfaac326f627463a83a3b37 100644 |
| --- a/Source/core/platform/graphics/Canvas2DLayerBridge.cpp |
| +++ b/Source/core/platform/graphics/Canvas2DLayerBridge.cpp |
| @@ -43,21 +43,6 @@ using blink::WebGraphicsContext3D; |
| namespace WebCore { |
| -void Canvas2DLayerBridgePtr::clear() |
| -{ |
| - if (m_ptr) { |
| - m_ptr->destroy(); |
| - m_ptr.clear(); |
| - } |
| -} |
| - |
| -Canvas2DLayerBridgePtr& Canvas2DLayerBridgePtr::operator=(const PassRefPtr<Canvas2DLayerBridge>& other) |
| -{ |
| - clear(); |
| - m_ptr = other; |
| - return *this; |
| -} |
| - |
| static SkSurface* createSurface(GraphicsContext3D* context3D, const IntSize& size, int msaaSampleCount) |
| { |
| ASSERT(!context3D->webContext()->isContextLost()); |
| @@ -73,19 +58,20 @@ static SkSurface* createSurface(GraphicsContext3D* context3D, const IntSize& siz |
| return SkSurface::NewRenderTarget(gr, info, msaaSampleCount); |
| } |
| -PassRefPtr<Canvas2DLayerBridge> Canvas2DLayerBridge::create(PassRefPtr<GraphicsContext3D> context, const IntSize& size, OpacityMode opacityMode, int msaaSampleCount) |
| +PassRefPtr<Canvas2DLayerBridge> Canvas2DLayerBridge::create(const IntSize& size, OpacityMode opacityMode, int msaaSampleCount) |
| { |
| TRACE_EVENT_INSTANT0("test_gpu", "Canvas2DLayerBridgeCreation"); |
| - SkAutoTUnref<SkSurface> surface(createSurface(context.get(), size, msaaSampleCount)); |
| - if (!surface.get()) { |
| - return PassRefPtr<Canvas2DLayerBridge>(); |
| + RefPtr<GraphicsContext3D> context = SharedGraphicsContext3D::get(); |
| + RefPtr<SkSurface> surface(createSurface(context.get(), size, msaaSampleCount)); |
|
Stephen White
2013/12/04 21:18:40
Maybe createSurface() should be renamed createSkSu
|
| + RefPtr<Canvas2DLayerBridge> layerBridge; |
| + if (surface) { |
| + OwnPtr<SkDeferredCanvas> canvas = adoptPtr(SkDeferredCanvas::Create(surface.get())); |
| + layerBridge = adoptRef(new Canvas2DLayerBridge(context, canvas.release(), msaaSampleCount, opacityMode)); |
| } |
| - RefPtr<SkDeferredCanvas> canvas = adoptRef(SkDeferredCanvas::Create(surface.get())); |
| - RefPtr<Canvas2DLayerBridge> layerBridge = adoptRef(new Canvas2DLayerBridge(context, canvas.release(), msaaSampleCount, opacityMode)); |
| return layerBridge.release(); |
| } |
| -Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, PassRefPtr<SkDeferredCanvas> canvas, int msaaSampleCount, OpacityMode opacityMode) |
| +Canvas2DLayerBridge::Canvas2DLayerBridge(PassRefPtr<GraphicsContext3D> context, PassOwnPtr<SkDeferredCanvas> canvas, int msaaSampleCount, OpacityMode opacityMode) |
| : m_canvas(canvas) |
| , m_context(context) |
| , m_msaaSampleCount(msaaSampleCount) |
| @@ -385,28 +371,28 @@ void Canvas2DLayerBridge::mailboxReleased(const blink::WebExternalTextureMailbox |
| } |
| } |
| -blink::WebLayer* Canvas2DLayerBridge::layer() |
| +blink::WebLayer* Canvas2DLayerBridge::layer() const |
| { |
| ASSERT(m_layer); |
| return m_layer->layer(); |
| } |
| -void Canvas2DLayerBridge::contextAcquired() |
| +void Canvas2DLayerBridge::aboutToUse() |
| { |
| ASSERT(!m_destructionInProgress); |
| Canvas2DLayerManager::get().layerDidDraw(this); |
| m_didRecordDrawCommand = true; |
| } |
| -unsigned Canvas2DLayerBridge::backBufferTexture() |
| +Platform3DObject Canvas2DLayerBridge::getBackingTexture() |
| { |
| ASSERT(!m_destructionInProgress); |
| if (!isValid()) |
| return 0; |
| - contextAcquired(); |
| + aboutToUse(); |
| m_canvas->flush(); |
| m_context->flush(); |
| - GrRenderTarget* renderTarget = reinterpret_cast<GrRenderTarget*>(m_canvas->getDevice()->accessRenderTarget()); |
| + GrRenderTarget* renderTarget = m_canvas->getTopDevice()->accessRenderTarget(); |
| if (renderTarget) { |
| return renderTarget->asTexture()->getTextureHandle(); |
| } |