2013-04-30 22:03:25 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "BasicLayersImpl.h" // for FillWithMask, etc
|
2013-04-30 22:03:25 -07:00
|
|
|
#include "CopyableCanvasLayer.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "GLContext.h" // for GLContext
|
|
|
|
#include "GLScreenBuffer.h" // for GLScreenBuffer
|
|
|
|
#include "SharedSurface.h" // for SharedSurface
|
|
|
|
#include "SharedSurfaceGL.h" // for SharedSurface_GL, etc
|
|
|
|
#include "SurfaceTypes.h" // for APITypeT, APITypeT::OpenGL, etc
|
|
|
|
#include "gfxImageSurface.h" // for gfxImageSurface
|
|
|
|
#include "gfxMatrix.h" // for gfxMatrix
|
|
|
|
#include "gfxPattern.h" // for gfxPattern, etc
|
|
|
|
#include "gfxPlatform.h" // for gfxPlatform, gfxImageFormat
|
|
|
|
#include "gfxRect.h" // for gfxRect
|
|
|
|
#include "gfxUtils.h" // for gfxUtils
|
2013-12-20 08:46:28 -08:00
|
|
|
#include "gfx2DGlue.h" // for thebes --> moz2d transition
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
|
|
|
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING, etc
|
|
|
|
#include "nsISupportsImpl.h" // for gfxContext::AddRef, etc
|
|
|
|
#include "nsRect.h" // for nsIntRect
|
|
|
|
#include "nsSize.h" // for nsIntSize
|
2014-02-12 07:07:46 -08:00
|
|
|
#include "LayerUtils.h"
|
2013-04-30 22:03:25 -07:00
|
|
|
|
|
|
|
using namespace mozilla::gfx;
|
|
|
|
using namespace mozilla::gl;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2013-09-06 19:11:41 -07:00
|
|
|
CopyableCanvasLayer::CopyableCanvasLayer(LayerManager* aLayerManager, void *aImplData) :
|
|
|
|
CanvasLayer(aLayerManager, aImplData)
|
2014-03-05 13:49:37 -08:00
|
|
|
, mStream(nullptr)
|
2013-09-06 19:11:41 -07:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(CopyableCanvasLayer);
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyableCanvasLayer::~CopyableCanvasLayer()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(CopyableCanvasLayer);
|
|
|
|
}
|
|
|
|
|
2013-04-30 22:03:25 -07:00
|
|
|
void
|
|
|
|
CopyableCanvasLayer::Initialize(const Data& aData)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(mSurface == nullptr, "BasicCanvasLayer::Initialize called twice!");
|
|
|
|
|
2014-02-06 06:46:30 -08:00
|
|
|
if (aData.mGLContext) {
|
2013-04-30 22:03:25 -07:00
|
|
|
mGLContext = aData.mGLContext;
|
2014-03-05 13:49:37 -08:00
|
|
|
mStream = aData.mStream;
|
2013-04-30 22:03:25 -07:00
|
|
|
mIsGLAlphaPremult = aData.mIsGLAlphaPremult;
|
|
|
|
mNeedsYFlip = true;
|
|
|
|
MOZ_ASSERT(mGLContext->IsOffscreen(), "canvas gl context isn't offscreen");
|
|
|
|
|
|
|
|
// [Basic Layers, non-OMTC] WebGL layer init.
|
|
|
|
// `GLScreenBuffer::Morph`ing is only needed in BasicShadowableCanvasLayer.
|
|
|
|
} else if (aData.mDrawTarget) {
|
|
|
|
mDrawTarget = aData.mDrawTarget;
|
2014-02-12 07:07:46 -08:00
|
|
|
mSurface = mDrawTarget->Snapshot();
|
|
|
|
mDeprecatedSurface =
|
2013-07-17 20:24:15 -07:00
|
|
|
gfxPlatform::GetPlatform()->CreateThebesSurfaceAliasForDrawTarget_hack(mDrawTarget);
|
2013-04-30 22:03:25 -07:00
|
|
|
mNeedsYFlip = false;
|
|
|
|
} else {
|
|
|
|
NS_ERROR("CanvasLayer created without mSurface, mDrawTarget or mGLContext?");
|
|
|
|
}
|
|
|
|
|
|
|
|
mBounds.SetRect(0, 0, aData.mSize.width, aData.mSize.height);
|
|
|
|
}
|
|
|
|
|
2013-12-04 14:46:20 -08:00
|
|
|
bool
|
|
|
|
CopyableCanvasLayer::IsDataValid(const Data& aData)
|
|
|
|
{
|
2014-03-05 13:49:37 -08:00
|
|
|
return mGLContext == aData.mGLContext && mStream == aData.mStream;
|
2013-12-04 14:46:20 -08:00
|
|
|
}
|
|
|
|
|
2013-04-30 22:03:25 -07:00
|
|
|
void
|
2014-02-12 07:07:46 -08:00
|
|
|
CopyableCanvasLayer::UpdateTarget(DrawTarget* aDestTarget,
|
|
|
|
SourceSurface* aMaskSurface)
|
2013-04-30 22:03:25 -07:00
|
|
|
{
|
|
|
|
if (!IsDirty())
|
|
|
|
return;
|
|
|
|
Painted();
|
|
|
|
|
|
|
|
if (mDrawTarget) {
|
|
|
|
mDrawTarget->Flush();
|
2014-02-12 07:07:46 -08:00
|
|
|
mSurface = mDrawTarget->Snapshot();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!mGLContext && aDestTarget) {
|
|
|
|
PaintWithOpacity(aDestTarget, 1.0f, aMaskSurface);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mGLContext) {
|
|
|
|
RefPtr<DataSourceSurface> readSurf;
|
|
|
|
RefPtr<SourceSurface> resultSurf;
|
|
|
|
|
2014-03-10 19:08:49 -07:00
|
|
|
SharedSurface_GL* sharedSurf = mGLContext->RequestFrame();
|
2014-02-12 07:07:46 -08:00
|
|
|
if (!sharedSurf) {
|
|
|
|
NS_WARNING("Null frame received.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
IntSize readSize(sharedSurf->Size());
|
|
|
|
SurfaceFormat format = (GetContentFlags() & CONTENT_OPAQUE)
|
|
|
|
? SurfaceFormat::B8G8R8X8
|
|
|
|
: SurfaceFormat::B8G8R8A8;
|
|
|
|
|
|
|
|
if (aDestTarget) {
|
|
|
|
resultSurf = aDestTarget->Snapshot();
|
|
|
|
if (!resultSurf) {
|
|
|
|
resultSurf = GetTempSurface(readSize, format);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
resultSurf = GetTempSurface(readSize, format);
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(resultSurf);
|
|
|
|
MOZ_ASSERT(sharedSurf->APIType() == APITypeT::OpenGL);
|
|
|
|
SharedSurface_GL* surfGL = SharedSurface_GL::Cast(sharedSurf);
|
|
|
|
|
|
|
|
if (surfGL->Type() == SharedSurfaceType::Basic) {
|
|
|
|
// sharedSurf_Basic->mData must outlive readSurf. Alas, readSurf may not
|
|
|
|
// leave the scope it was declared in.
|
|
|
|
SharedSurface_Basic* sharedSurf_Basic = SharedSurface_Basic::Cast(surfGL);
|
|
|
|
readSurf = sharedSurf_Basic->GetData();
|
|
|
|
} else {
|
|
|
|
if (resultSurf->GetSize() != readSize ||
|
|
|
|
!(readSurf = resultSurf->GetDataSurface()) ||
|
|
|
|
readSurf->GetFormat() != format)
|
|
|
|
{
|
|
|
|
readSurf = GetTempSurface(readSize, format);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Readback handles Flush/MarkDirty.
|
|
|
|
mGLContext->Screen()->Readback(surfGL, readSurf);
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(readSurf);
|
|
|
|
|
|
|
|
bool needsPremult = surfGL->HasAlpha() && !mIsGLAlphaPremult;
|
|
|
|
if (needsPremult) {
|
|
|
|
PremultiplySurface(readSurf);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (readSurf != resultSurf) {
|
|
|
|
RefPtr<DataSourceSurface> resultDataSurface =
|
|
|
|
resultSurf->GetDataSurface();
|
|
|
|
RefPtr<DrawTarget> dt =
|
|
|
|
Factory::CreateDrawTargetForData(BackendType::CAIRO,
|
|
|
|
resultDataSurface->GetData(),
|
|
|
|
resultDataSurface->GetSize(),
|
|
|
|
resultDataSurface->Stride(),
|
|
|
|
resultDataSurface->GetFormat());
|
|
|
|
IntSize readSize = readSurf->GetSize();
|
|
|
|
Rect r(0, 0, readSize.width, readSize.height);
|
|
|
|
DrawOptions opts(1.0f, CompositionOp::OP_SOURCE, AntialiasMode::DEFAULT);
|
|
|
|
dt->DrawSurface(readSurf, r, r, DrawSurfaceOptions(), opts);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If !aDestSurface then we will end up painting using mSurface, so
|
|
|
|
// stick our surface into mSurface, so that the Paint() path is the same.
|
|
|
|
if (!aDestTarget) {
|
|
|
|
mSurface = resultSurf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CopyableCanvasLayer::DeprecatedUpdateSurface(gfxASurface* aDestSurface,
|
|
|
|
Layer* aMaskLayer)
|
|
|
|
{
|
|
|
|
if (!IsDirty())
|
|
|
|
return;
|
|
|
|
Painted();
|
|
|
|
|
|
|
|
if (mDrawTarget) {
|
|
|
|
mDrawTarget->Flush();
|
|
|
|
mDeprecatedSurface =
|
2013-07-17 20:24:15 -07:00
|
|
|
gfxPlatform::GetPlatform()->CreateThebesSurfaceAliasForDrawTarget_hack(mDrawTarget);
|
2013-04-30 22:03:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!mGLContext && aDestSurface) {
|
|
|
|
nsRefPtr<gfxContext> tmpCtx = new gfxContext(aDestSurface);
|
|
|
|
tmpCtx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
2014-02-12 07:07:46 -08:00
|
|
|
DeprecatedPaintWithOpacity(tmpCtx, 1.0f, aMaskLayer);
|
2013-04-30 22:03:25 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mGLContext) {
|
|
|
|
nsRefPtr<gfxImageSurface> readSurf;
|
2013-12-10 08:11:58 -08:00
|
|
|
RefPtr<DataSourceSurface> readDSurf;
|
2013-07-31 15:17:41 -07:00
|
|
|
nsRefPtr<gfxASurface> resultSurf;
|
2013-04-30 22:03:25 -07:00
|
|
|
|
2014-03-10 19:08:49 -07:00
|
|
|
SharedSurface_GL* sharedSurf = mGLContext->RequestFrame();
|
2013-04-30 22:03:25 -07:00
|
|
|
if (!sharedSurf) {
|
|
|
|
NS_WARNING("Null frame received.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-10 08:11:58 -08:00
|
|
|
IntSize readSize(sharedSurf->Size());
|
2013-04-30 22:03:25 -07:00
|
|
|
gfxImageFormat format = (GetContentFlags() & CONTENT_OPAQUE)
|
2014-01-23 10:26:40 -08:00
|
|
|
? gfxImageFormat::RGB24
|
|
|
|
: gfxImageFormat::ARGB32;
|
2013-04-30 22:03:25 -07:00
|
|
|
|
2013-07-30 19:28:46 -07:00
|
|
|
if (aDestSurface) {
|
2013-07-31 15:17:41 -07:00
|
|
|
resultSurf = aDestSurface;
|
2013-07-30 19:28:46 -07:00
|
|
|
} else {
|
2014-02-12 07:07:46 -08:00
|
|
|
resultSurf = DeprecatedGetTempSurface(readSize, format);
|
2013-04-30 22:03:25 -07:00
|
|
|
}
|
|
|
|
MOZ_ASSERT(resultSurf);
|
|
|
|
if (resultSurf->CairoStatus() != 0) {
|
|
|
|
MOZ_ASSERT(false, "Bad resultSurf->CairoStatus().");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(sharedSurf->APIType() == APITypeT::OpenGL);
|
|
|
|
SharedSurface_GL* surfGL = SharedSurface_GL::Cast(sharedSurf);
|
|
|
|
|
|
|
|
if (surfGL->Type() == SharedSurfaceType::Basic) {
|
2013-12-10 08:11:58 -08:00
|
|
|
// sharedSurf_Basic->mData must outlive readSurf and readDSurf. Alas,
|
|
|
|
// readSurf and readDSurf may not leave the scope they were declared in.
|
2013-04-30 22:03:25 -07:00
|
|
|
SharedSurface_Basic* sharedSurf_Basic = SharedSurface_Basic::Cast(surfGL);
|
2013-12-10 08:11:58 -08:00
|
|
|
readDSurf = sharedSurf_Basic->GetData();
|
|
|
|
readSurf = new gfxImageSurface(readDSurf->GetData(),
|
|
|
|
ThebesIntSize(readDSurf->GetSize()),
|
|
|
|
readDSurf->Stride(),
|
|
|
|
SurfaceFormatToImageFormat(readDSurf->GetFormat()));
|
2013-04-30 22:03:25 -07:00
|
|
|
} else {
|
2013-12-20 08:46:28 -08:00
|
|
|
if (ToIntSize(resultSurf->GetSize()) != readSize ||
|
2013-07-31 15:17:41 -07:00
|
|
|
!(readSurf = resultSurf->GetAsImageSurface()) ||
|
|
|
|
readSurf->Format() != format)
|
2013-04-30 22:03:25 -07:00
|
|
|
{
|
2014-02-12 07:07:46 -08:00
|
|
|
readSurf = DeprecatedGetTempSurface(readSize, format);
|
2013-04-30 22:03:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Readback handles Flush/MarkDirty.
|
2014-02-12 07:07:46 -08:00
|
|
|
mGLContext->Screen()->DeprecatedReadback(surfGL, readSurf);
|
2013-04-30 22:03:25 -07:00
|
|
|
}
|
|
|
|
MOZ_ASSERT(readSurf);
|
|
|
|
|
|
|
|
bool needsPremult = surfGL->HasAlpha() && !mIsGLAlphaPremult;
|
|
|
|
if (needsPremult) {
|
|
|
|
readSurf->Flush();
|
2013-07-31 15:17:41 -07:00
|
|
|
gfxUtils::PremultiplyImageSurface(readSurf);
|
|
|
|
readSurf->MarkDirty();
|
|
|
|
}
|
2014-02-12 07:07:46 -08:00
|
|
|
|
2013-07-31 15:17:41 -07:00
|
|
|
if (readSurf != resultSurf) {
|
2013-04-30 22:03:25 -07:00
|
|
|
readSurf->Flush();
|
|
|
|
nsRefPtr<gfxContext> ctx = new gfxContext(resultSurf);
|
|
|
|
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
|
|
|
ctx->SetSource(readSurf);
|
|
|
|
ctx->Paint();
|
|
|
|
}
|
|
|
|
|
2013-07-31 15:17:41 -07:00
|
|
|
// If !aDestSurface then we will end up painting using mSurface, so
|
|
|
|
// stick our surface into mSurface, so that the Paint() path is the same.
|
2013-07-30 19:28:46 -07:00
|
|
|
if (!aDestSurface) {
|
2014-02-12 07:07:46 -08:00
|
|
|
mDeprecatedSurface = resultSurf;
|
2013-04-30 22:03:25 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-02-12 07:07:46 -08:00
|
|
|
CopyableCanvasLayer::PaintWithOpacity(gfx::DrawTarget* aTarget,
|
2013-04-30 22:03:25 -07:00
|
|
|
float aOpacity,
|
2014-02-12 07:07:46 -08:00
|
|
|
SourceSurface* aMaskSurface,
|
|
|
|
gfx::CompositionOp aOperator)
|
2013-04-30 22:03:25 -07:00
|
|
|
{
|
|
|
|
if (!mSurface) {
|
|
|
|
NS_WARNING("No valid surface to draw!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-12 07:07:46 -08:00
|
|
|
SurfacePattern pat(mSurface, ExtendMode::CLAMP, Matrix(), ToFilter(mFilter));
|
|
|
|
|
|
|
|
Matrix oldTransform;
|
|
|
|
if (mNeedsYFlip) {
|
|
|
|
oldTransform = aTarget->GetTransform();
|
|
|
|
Matrix flipped = oldTransform;
|
|
|
|
flipped.Translate(0, mBounds.height);
|
|
|
|
flipped.Scale(1.0, -1.0);
|
|
|
|
aTarget->SetTransform(flipped);
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawOptions options = DrawOptions(aOpacity, CompositionOp::OP_SOURCE);
|
|
|
|
|
|
|
|
if (aOperator != CompositionOp::OP_OVER) {
|
|
|
|
options.mCompositionOp = aOperator;
|
|
|
|
}
|
|
|
|
|
2014-03-17 07:49:21 -07:00
|
|
|
// XXX: This needs rewriting for acceptable performance using CoreGraphics.
|
|
|
|
// Therefore - this ::PaintWithOpacity is currently not used
|
2014-02-12 07:07:46 -08:00
|
|
|
Rect rect = Rect(0, 0, mBounds.width, mBounds.height);
|
|
|
|
aTarget->FillRect(rect, pat, options);
|
2014-03-17 07:49:21 -07:00
|
|
|
|
2014-02-12 07:07:46 -08:00
|
|
|
if (aMaskSurface) {
|
|
|
|
aTarget->MaskSurface(pat, aMaskSurface, Point(0, 0), options);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mNeedsYFlip) {
|
|
|
|
aTarget->SetTransform(oldTransform);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CopyableCanvasLayer::DeprecatedPaintWithOpacity(gfxContext* aContext,
|
|
|
|
float aOpacity,
|
|
|
|
Layer* aMaskLayer,
|
|
|
|
gfxContext::GraphicsOperator aOperator)
|
|
|
|
{
|
|
|
|
if (!mDeprecatedSurface) {
|
|
|
|
NS_WARNING("No valid surface to draw!");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsRefPtr<gfxPattern> pat = new gfxPattern(mDeprecatedSurface);
|
2013-04-30 22:03:25 -07:00
|
|
|
|
|
|
|
pat->SetFilter(mFilter);
|
|
|
|
pat->SetExtend(gfxPattern::EXTEND_PAD);
|
|
|
|
|
|
|
|
gfxMatrix m;
|
|
|
|
if (mNeedsYFlip) {
|
|
|
|
m = aContext->CurrentMatrix();
|
|
|
|
aContext->Translate(gfxPoint(0.0, mBounds.height));
|
|
|
|
aContext->Scale(1.0, -1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If content opaque, then save off current operator and set to source.
|
|
|
|
// This ensures that alpha is not applied even if the source surface
|
|
|
|
// has an alpha channel
|
|
|
|
gfxContext::GraphicsOperator savedOp;
|
|
|
|
if (GetContentFlags() & CONTENT_OPAQUE) {
|
|
|
|
savedOp = aContext->CurrentOperator();
|
|
|
|
aContext->SetOperator(gfxContext::OPERATOR_SOURCE);
|
|
|
|
}
|
|
|
|
|
|
|
|
AutoSetOperator setOperator(aContext, aOperator);
|
|
|
|
aContext->NewPath();
|
|
|
|
// No need to snap here; our transform is already set up to snap our rect
|
|
|
|
aContext->Rectangle(gfxRect(0, 0, mBounds.width, mBounds.height));
|
|
|
|
aContext->SetPattern(pat);
|
|
|
|
|
|
|
|
FillWithMask(aContext, aOpacity, aMaskLayer);
|
|
|
|
// Restore surface operator
|
|
|
|
if (GetContentFlags() & CONTENT_OPAQUE) {
|
|
|
|
aContext->SetOperator(savedOp);
|
2014-03-10 19:08:49 -07:00
|
|
|
}
|
2013-04-30 22:03:25 -07:00
|
|
|
|
|
|
|
if (mNeedsYFlip) {
|
|
|
|
aContext->SetMatrix(m);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-12 07:07:46 -08:00
|
|
|
DataSourceSurface*
|
|
|
|
CopyableCanvasLayer::GetTempSurface(const IntSize& aSize,
|
|
|
|
const SurfaceFormat aFormat)
|
2013-09-24 13:45:14 -07:00
|
|
|
{
|
|
|
|
if (!mCachedTempSurface ||
|
|
|
|
aSize.width != mCachedSize.width ||
|
|
|
|
aSize.height != mCachedSize.height ||
|
|
|
|
aFormat != mCachedFormat)
|
|
|
|
{
|
2014-02-12 07:07:46 -08:00
|
|
|
mCachedTempSurface = Factory::CreateDataSourceSurface(aSize, aFormat);
|
2013-09-24 13:45:14 -07:00
|
|
|
mCachedSize = aSize;
|
|
|
|
mCachedFormat = aFormat;
|
|
|
|
}
|
|
|
|
|
2014-02-12 07:07:46 -08:00
|
|
|
MOZ_ASSERT(mCachedTempSurface->Stride() ==
|
|
|
|
mCachedTempSurface->GetSize().width * 4);
|
2013-09-24 13:45:14 -07:00
|
|
|
return mCachedTempSurface;
|
|
|
|
}
|
|
|
|
|
2014-02-12 07:07:46 -08:00
|
|
|
gfxImageSurface*
|
|
|
|
CopyableCanvasLayer::DeprecatedGetTempSurface(const IntSize& aSize,
|
|
|
|
const gfxImageFormat aFormat)
|
|
|
|
{
|
|
|
|
if (!mDeprecatedCachedTempSurface ||
|
|
|
|
aSize.width != mCachedSize.width ||
|
|
|
|
aSize.height != mCachedSize.height ||
|
|
|
|
aFormat != mDeprecatedCachedFormat)
|
|
|
|
{
|
|
|
|
mDeprecatedCachedTempSurface =
|
|
|
|
new gfxImageSurface(ThebesIntSize(aSize), aFormat);
|
|
|
|
mCachedSize = aSize;
|
|
|
|
mDeprecatedCachedFormat = aFormat;
|
|
|
|
}
|
|
|
|
|
|
|
|
MOZ_ASSERT(mDeprecatedCachedTempSurface->Stride() ==
|
|
|
|
mDeprecatedCachedTempSurface->Width() * 4);
|
|
|
|
return mDeprecatedCachedTempSurface;
|
|
|
|
}
|
|
|
|
|
2013-09-24 13:45:14 -07:00
|
|
|
void
|
|
|
|
CopyableCanvasLayer::DiscardTempSurface()
|
|
|
|
{
|
|
|
|
mCachedTempSurface = nullptr;
|
2014-02-12 07:07:46 -08:00
|
|
|
mDeprecatedCachedTempSurface = nullptr;
|
2013-09-24 13:45:14 -07:00
|
|
|
}
|
|
|
|
|
2013-04-30 22:03:25 -07:00
|
|
|
}
|
|
|
|
}
|