| 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..8f25602d03fca50efbd63a44f757e9f46158e772 100644
|
| --- a/Source/core/platform/graphics/ImageBuffer.cpp
|
| +++ b/Source/core/platform/graphics/ImageBuffer.cpp
|
| @@ -61,13 +61,40 @@ using namespace std;
|
|
|
| namespace WebCore {
|
|
|
| +namespace {
|
| +
|
| +class AcceleratedLayerHelper : public Canvas2DLayerBridge::Helper {
|
| +public:
|
| + virtual PassRefPtr<GraphicsContext3D> getContext() OVERRIDE
|
| + {
|
| + return SharedGraphicsContext3D::get();
|
| + }
|
| +
|
| + virtual SkSurface* createSurface(GraphicsContext3D* context3D, const 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
|
| +
|
| 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;
|
|
|