Chromium Code Reviews| Index: Source/core/platform/graphics/ImageBuffer.cpp |
| diff --git a/Source/core/platform/graphics/ImageBuffer.cpp b/Source/core/platform/graphics/ImageBuffer.cpp |
| index 86fde9637bf93805800850150773d2a31cea747d..0ec01a9b73479575e788f649f196281d73f08678 100644 |
| --- a/Source/core/platform/graphics/ImageBuffer.cpp |
| +++ b/Source/core/platform/graphics/ImageBuffer.cpp |
| @@ -59,15 +59,42 @@ |
| using namespace std; |
| +namespace { |
| + |
| +class AcceleratedLayerHelper : public WebCore::Canvas2DLayerBridge::Helper { |
|
jamesr
2013/08/05 22:56:36
put this anonymous namespace inside WebCore and yo
|
| +public: |
| + virtual PassRefPtr<WebCore::GraphicsContext3D> getContext() OVERRIDE |
| + { |
| + return WebCore::SharedGraphicsContext3D::get(); |
| + } |
| + |
| + virtual SkSurface* createSurface(WebCore::GraphicsContext3D* context3D, const WebCore::IntSize& size) OVERRIDE |
| + { |
| + ASSERT(!context3D->webContext()->isContextLost()); |
| + GrContext* gr = context3D->grContext(); |
| + if (!gr) |
| + return 0; |
| + gr->resetContext(); |
| + SkImage::Info info; |
| + info.fWidth = size.width(); |
| + info.fHeight = size.height(); |
| + info.fColorType = SkImage::kPMColor_ColorType; |
| + info.fAlphaType = SkImage::kPremul_AlphaType; |
| + return SkSurface::NewRenderTarget(gr, info); |
| + } |
| +}; |
| + |
| +} // unnamed namespace |
| + |
| namespace WebCore { |
| static SkCanvas* createAcceleratedCanvas(const IntSize& size, OwnPtr<Canvas2DLayerBridge>* outLayerBridge, OpacityMode opacityMode) |
| { |
| - RefPtr<GraphicsContext3D> context3D = SharedGraphicsContext3D::get(); |
| - if (!context3D) |
| + OwnPtr<AcceleratedLayerHelper> helper = adoptPtr(new AcceleratedLayerHelper); |
| + if (!helper->getContext()) |
| return 0; |
| Canvas2DLayerBridge::OpacityMode bridgeOpacityMode = opacityMode == Opaque ? Canvas2DLayerBridge::Opaque : Canvas2DLayerBridge::NonOpaque; |
| - *outLayerBridge = Canvas2DLayerBridge::create(context3D.release(), size, bridgeOpacityMode); |
| + *outLayerBridge = Canvas2DLayerBridge::create(helper.release(), size, bridgeOpacityMode); |
| // If canvas buffer allocation failed, debug build will have asserted |
| // For release builds, we must verify whether the device has a render target |
| return (*outLayerBridge) ? (*outLayerBridge)->getCanvas() : 0; |