mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1165710 - Make DrawTargetSkia own its snapshot instead of the other way around. r=gw280
This commit is contained in:
parent
5471e06cbf
commit
39c7059712
@ -132,6 +132,7 @@ DrawTargetSkia::DrawTargetSkia()
|
||||
|
||||
DrawTargetSkia::~DrawTargetSkia()
|
||||
{
|
||||
MarkChanged();
|
||||
}
|
||||
|
||||
TemporaryRef<SourceSurface>
|
||||
@ -140,9 +141,9 @@ DrawTargetSkia::Snapshot()
|
||||
RefPtr<SourceSurfaceSkia> snapshot = mSnapshot;
|
||||
if (!snapshot) {
|
||||
snapshot = new SourceSurfaceSkia();
|
||||
mSnapshot = snapshot;
|
||||
if (!snapshot->InitFromCanvas(mCanvas.get(), mFormat, this))
|
||||
if (!snapshot->InitFromCanvas(mCanvas.get(), mFormat))
|
||||
return nullptr;
|
||||
mSnapshot = snapshot;
|
||||
}
|
||||
|
||||
return snapshot.forget();
|
||||
@ -1008,11 +1009,5 @@ DrawTargetSkia::SkRectCoveringWholeSurface() const
|
||||
return RectToSkRect(mTransform.TransformBounds(Rect(0, 0, mSize.width, mSize.height)));
|
||||
}
|
||||
|
||||
void
|
||||
DrawTargetSkia::SnapshotDestroyed()
|
||||
{
|
||||
mSnapshot = nullptr;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -125,7 +125,6 @@ public:
|
||||
|
||||
private:
|
||||
friend class SourceSurfaceSkia;
|
||||
void SnapshotDestroyed();
|
||||
|
||||
void MarkChanged();
|
||||
|
||||
@ -142,7 +141,7 @@ private:
|
||||
|
||||
IntSize mSize;
|
||||
RefPtrSkia<SkCanvas> mCanvas;
|
||||
SourceSurfaceSkia* mSnapshot;
|
||||
RefPtr<SourceSurfaceSkia> mSnapshot;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -17,17 +17,14 @@ namespace mozilla {
|
||||
namespace gfx {
|
||||
|
||||
SourceSurfaceSkia::SourceSurfaceSkia()
|
||||
: mDrawTarget(nullptr), mLocked(false)
|
||||
: mLocked(false)
|
||||
, mBitmapDataOwned(false)
|
||||
{
|
||||
}
|
||||
|
||||
SourceSurfaceSkia::~SourceSurfaceSkia()
|
||||
{
|
||||
MaybeUnlock();
|
||||
if (mDrawTarget) {
|
||||
mDrawTarget->SnapshotDestroyed();
|
||||
mDrawTarget = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
IntSize
|
||||
@ -44,8 +41,7 @@ SourceSurfaceSkia::GetFormat() const
|
||||
|
||||
bool
|
||||
SourceSurfaceSkia::InitFromCanvas(SkCanvas* aCanvas,
|
||||
SurfaceFormat aFormat,
|
||||
DrawTargetSkia* aOwner)
|
||||
SurfaceFormat aFormat)
|
||||
{
|
||||
SkISize size = aCanvas->getDeviceSize();
|
||||
|
||||
@ -55,7 +51,7 @@ SourceSurfaceSkia::InitFromCanvas(SkCanvas* aCanvas,
|
||||
|
||||
mSize = IntSize(size.fWidth, size.fHeight);
|
||||
mStride = mBitmap.rowBytes();
|
||||
mDrawTarget = aOwner;
|
||||
mBitmapDataOwned = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -115,7 +111,6 @@ SourceSurfaceSkia::InitFromTexture(DrawTargetSkia* aOwner,
|
||||
mBitmap.setPixelRef(texRef);
|
||||
#endif
|
||||
|
||||
mDrawTarget = aOwner;
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -134,10 +129,9 @@ SourceSurfaceSkia::GetData()
|
||||
void
|
||||
SourceSurfaceSkia::DrawTargetWillChange()
|
||||
{
|
||||
if (mDrawTarget) {
|
||||
if (mBitmapDataOwned) {
|
||||
MaybeUnlock();
|
||||
|
||||
mDrawTarget = nullptr;
|
||||
SkBitmap temp = mBitmap;
|
||||
mBitmap.reset();
|
||||
temp.copyTo(&mBitmap, temp.colorType());
|
||||
|
@ -36,8 +36,7 @@ public:
|
||||
SurfaceFormat aFormat);
|
||||
|
||||
bool InitFromCanvas(SkCanvas* aCanvas,
|
||||
SurfaceFormat aFormat,
|
||||
DrawTargetSkia* aOwner);
|
||||
SurfaceFormat aFormat);
|
||||
|
||||
/**
|
||||
* NOTE: While wrapping a Texture for SkiaGL, the texture *must* be created
|
||||
@ -54,7 +53,6 @@ public:
|
||||
|
||||
private:
|
||||
friend class DrawTargetSkia;
|
||||
|
||||
void DrawTargetWillChange();
|
||||
void MaybeUnlock();
|
||||
|
||||
@ -62,8 +60,8 @@ private:
|
||||
SurfaceFormat mFormat;
|
||||
IntSize mSize;
|
||||
int32_t mStride;
|
||||
RefPtr<DrawTargetSkia> mDrawTarget;
|
||||
bool mLocked;
|
||||
bool mBitmapDataOwned;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user