mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 848482 - Make SourceSurface work with SkiaGL r=mattwoodrow
--HG-- extra : rebase_source : ef4a315401edfad5e574ffd387c9951b12f1e9d7
This commit is contained in:
parent
549385d9a1
commit
91c353d366
@ -621,7 +621,6 @@ CanvasRenderingContext2D::Reset()
|
||||
|
||||
// Since the target changes the backing texture will change, and this will
|
||||
// no longer be valid.
|
||||
mThebesSurface = nullptr;
|
||||
mIsEntireFrameInvalid = false;
|
||||
mPredictManyRedrawCalls = false;
|
||||
|
||||
@ -713,11 +712,6 @@ CanvasRenderingContext2D::Redraw()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
if (!mThebesSurface)
|
||||
mThebesSurface =
|
||||
gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mTarget);
|
||||
mThebesSurface->MarkDirty();
|
||||
|
||||
nsSVGEffects::InvalidateDirectRenderingObservers(mCanvasElement);
|
||||
|
||||
mCanvasElement->InvalidateCanvasContent(nullptr);
|
||||
@ -745,11 +739,6 @@ CanvasRenderingContext2D::Redraw(const mgfx::Rect &r)
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mThebesSurface)
|
||||
mThebesSurface =
|
||||
gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mTarget);
|
||||
mThebesSurface->MarkDirty();
|
||||
|
||||
nsSVGEffects::InvalidateDirectRenderingObservers(mCanvasElement);
|
||||
|
||||
mCanvasElement->InvalidateCanvasContent(&r);
|
||||
@ -891,7 +880,6 @@ CanvasRenderingContext2D::InitializeWithSurface(nsIDocShell *shell,
|
||||
int32_t height)
|
||||
{
|
||||
mDocShell = shell;
|
||||
mThebesSurface = surface;
|
||||
|
||||
SetDimensions(width, height);
|
||||
mTarget = gfxPlatform::GetPlatform()->
|
||||
@ -3212,18 +3200,39 @@ CanvasRenderingContext2D::DrawWindow(nsIDOMWindow* window, double x,
|
||||
// save and restore it
|
||||
Matrix matrix = mTarget->GetTransform();
|
||||
nsRefPtr<gfxContext> thebes;
|
||||
nsRefPtr<gfxASurface> drawSurf;
|
||||
if (gfxPlatform::GetPlatform()->SupportsAzureContentForDrawTarget(mTarget)) {
|
||||
thebes = new gfxContext(mTarget);
|
||||
thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21,
|
||||
matrix._22, matrix._31, matrix._32));
|
||||
} else {
|
||||
nsRefPtr<gfxASurface> drawSurf;
|
||||
GetThebesSurface(getter_AddRefs(drawSurf));
|
||||
drawSurf =
|
||||
gfxPlatform::GetPlatform()->CreateOffscreenSurface(gfxIntSize(ceil(w), ceil(h)),
|
||||
gfxASurface::CONTENT_COLOR_ALPHA);
|
||||
|
||||
drawSurf->SetDeviceOffset(gfxPoint(-floor(x), -floor(y)));
|
||||
thebes = new gfxContext(drawSurf);
|
||||
thebes->Translate(gfxPoint(floor(x), floor(y)));
|
||||
}
|
||||
thebes->SetMatrix(gfxMatrix(matrix._11, matrix._12, matrix._21,
|
||||
matrix._22, matrix._31, matrix._32));
|
||||
|
||||
nsCOMPtr<nsIPresShell> shell = presContext->PresShell();
|
||||
unused << shell->RenderDocument(r, renderDocFlags, backgroundColor, thebes);
|
||||
mTarget->SetTransform(matrix);
|
||||
if (drawSurf) {
|
||||
gfxIntSize size = drawSurf->GetSize();
|
||||
|
||||
drawSurf->SetDeviceOffset(gfxPoint(0, 0));
|
||||
nsRefPtr<gfxImageSurface> img = drawSurf->GetAsReadableARGB32ImageSurface();
|
||||
RefPtr<SourceSurface> data =
|
||||
mTarget->CreateSourceSurfaceFromData(img->Data(),
|
||||
IntSize(size.width, size.height),
|
||||
img->Stride(),
|
||||
FORMAT_B8G8R8A8);
|
||||
mgfx::Rect rect(0, 0, w, h);
|
||||
mTarget->DrawSurface(data, rect, rect);
|
||||
mTarget->Flush();
|
||||
} else {
|
||||
mTarget->SetTransform(matrix);
|
||||
}
|
||||
|
||||
// note that x and y are coordinates in the document that
|
||||
// we're drawing; x and y are drawn to 0,0 in current user
|
||||
@ -3667,20 +3676,15 @@ NS_IMETHODIMP
|
||||
CanvasRenderingContext2D::GetThebesSurface(gfxASurface **surface)
|
||||
{
|
||||
EnsureTarget();
|
||||
if (!mThebesSurface) {
|
||||
mThebesSurface =
|
||||
|
||||
nsRefPtr<gfxASurface> thebesSurface =
|
||||
gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mTarget);
|
||||
|
||||
if (!mThebesSurface) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
} else {
|
||||
// Normally GetThebesSurfaceForDrawTarget will handle the flush, when
|
||||
// we're returning a cached ThebesSurface we need to flush here.
|
||||
mTarget->Flush();
|
||||
if (!thebesSurface) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*surface = mThebesSurface;
|
||||
*surface = thebesSurface;
|
||||
NS_ADDREF(*surface);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -61,14 +61,7 @@ CopyableCanvasLayer::UpdateSurface(gfxASurface* aDestSurface, Layer* aMaskLayer)
|
||||
|
||||
if (mDrawTarget) {
|
||||
mDrawTarget->Flush();
|
||||
if (mDrawTarget->GetType() == BACKEND_COREGRAPHICS_ACCELERATED) {
|
||||
// We have an accelerated CG context which has changed, unlike a bitmap surface
|
||||
// where we can alias the bits on initializing the mDrawTarget, we need to readback
|
||||
// and copy the accelerated surface each frame. We want to support this for quick
|
||||
// thumbnail but if we're going to be doing this every frame it likely is better
|
||||
// to use a non accelerated (bitmap) canvas.
|
||||
mSurface = gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mDrawTarget);
|
||||
}
|
||||
mSurface = gfxPlatform::GetPlatform()->GetThebesSurfaceForDrawTarget(mDrawTarget);
|
||||
}
|
||||
|
||||
if (!mGLContext && aDestSurface) {
|
||||
|
@ -52,7 +52,7 @@ protected:
|
||||
nsRefPtr<gfxASurface> mSurface;
|
||||
nsRefPtr<mozilla::gl::GLContext> mGLContext;
|
||||
mozilla::RefPtr<mozilla::gfx::DrawTarget> mDrawTarget;
|
||||
|
||||
|
||||
uint32_t mCanvasFramebuffer;
|
||||
|
||||
bool mIsGLAlphaPremult;
|
||||
|
Loading…
Reference in New Issue
Block a user