mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
b=583838; add ANGLE/D3D WebGL support - part 4 - allow CanvasLayerOGL to work with different-type GL contexts; r=bas
This commit is contained in:
parent
9636d54ad1
commit
51835ef8a6
@ -132,13 +132,15 @@ CanvasLayerOGL::Updated(const nsIntRect& aRect)
|
|||||||
|
|
||||||
mUpdatedRect.UnionRect(mUpdatedRect, aRect);
|
mUpdatedRect.UnionRect(mUpdatedRect, aRect);
|
||||||
|
|
||||||
if (mCanvasGLContext) {
|
if (mCanvasGLContext &&
|
||||||
|
mCanvasGLContext->GetContextType() == gl()->GetContextType())
|
||||||
|
{
|
||||||
if (gl()->BindOffscreenNeedsTexture(mCanvasGLContext) &&
|
if (gl()->BindOffscreenNeedsTexture(mCanvasGLContext) &&
|
||||||
mTexture == 0)
|
mTexture == 0)
|
||||||
{
|
{
|
||||||
MakeTexture();
|
MakeTexture();
|
||||||
}
|
}
|
||||||
} else if (mCanvasSurface) {
|
} else {
|
||||||
PRBool newTexture = mTexture == 0;
|
PRBool newTexture = mTexture == 0;
|
||||||
if (newTexture) {
|
if (newTexture) {
|
||||||
MakeTexture();
|
MakeTexture();
|
||||||
@ -149,40 +151,50 @@ CanvasLayerOGL::Updated(const nsIntRect& aRect)
|
|||||||
}
|
}
|
||||||
|
|
||||||
nsRefPtr<gfxImageSurface> updatedAreaImageSurface;
|
nsRefPtr<gfxImageSurface> updatedAreaImageSurface;
|
||||||
nsRefPtr<gfxASurface> sourceSurface = mCanvasSurface;
|
if (mCanvasSurface) {
|
||||||
|
nsRefPtr<gfxASurface> sourceSurface = mCanvasSurface;
|
||||||
|
|
||||||
#ifdef XP_WIN
|
#ifdef XP_WIN
|
||||||
if (sourceSurface->GetType() == gfxASurface::SurfaceTypeWin32) {
|
if (sourceSurface->GetType() == gfxASurface::SurfaceTypeWin32) {
|
||||||
sourceSurface = static_cast<gfxWindowsSurface*>(sourceSurface.get())->GetImageSurface();
|
sourceSurface = static_cast<gfxWindowsSurface*>(sourceSurface.get())->GetImageSurface();
|
||||||
if (!sourceSurface)
|
if (!sourceSurface)
|
||||||
sourceSurface = mCanvasSurface;
|
sourceSurface = mCanvasSurface;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
// XXX don't copy, blah.
|
// XXX don't copy, blah.
|
||||||
// but need to deal with stride on the gl side; do this later.
|
// but need to deal with stride on the gl side; do this later.
|
||||||
if (mCanvasSurface->GetType() == gfxASurface::SurfaceTypeImage) {
|
if (mCanvasSurface->GetType() == gfxASurface::SurfaceTypeImage) {
|
||||||
gfxImageSurface *s = static_cast<gfxImageSurface*>(mCanvasSurface.get());
|
gfxImageSurface *s = static_cast<gfxImageSurface*>(mCanvasSurface.get());
|
||||||
if (s->Format() == gfxASurface::ImageFormatARGB32 ||
|
if (s->Format() == gfxASurface::ImageFormatARGB32 ||
|
||||||
s->Format() == gfxASurface::ImageFormatRGB24)
|
s->Format() == gfxASurface::ImageFormatRGB24)
|
||||||
{
|
{
|
||||||
updatedAreaImageSurface = ...;
|
updatedAreaImageSurface = ...;
|
||||||
} else {
|
} else {
|
||||||
NS_WARNING("surface with format that we can't handle");
|
NS_WARNING("surface with format that we can't handle");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
updatedAreaImageSurface =
|
||||||
|
new gfxImageSurface(gfxIntSize(mUpdatedRect.width, mUpdatedRect.height),
|
||||||
|
gfxASurface::ImageFormatARGB32);
|
||||||
|
nsRefPtr<gfxContext> ctx = new gfxContext(updatedAreaImageSurface);
|
||||||
|
ctx->Translate(gfxPoint(-mUpdatedRect.x, -mUpdatedRect.y));
|
||||||
|
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
||||||
|
ctx->SetSource(sourceSurface);
|
||||||
|
ctx->Paint();
|
||||||
|
}
|
||||||
|
} else if (mCanvasGLContext) {
|
||||||
updatedAreaImageSurface =
|
updatedAreaImageSurface =
|
||||||
new gfxImageSurface(gfxIntSize(mUpdatedRect.width, mUpdatedRect.height),
|
new gfxImageSurface(gfxIntSize(mUpdatedRect.width, mUpdatedRect.height),
|
||||||
gfxASurface::ImageFormatARGB32);
|
gfxASurface::ImageFormatARGB32);
|
||||||
nsRefPtr<gfxContext> ctx = new gfxContext(updatedAreaImageSurface);
|
mCanvasGLContext->ReadPixelsIntoImageSurface(mUpdatedRect.x, mUpdatedRect.y,
|
||||||
ctx->Translate(gfxPoint(-mUpdatedRect.x, -mUpdatedRect.y));
|
mUpdatedRect.width,
|
||||||
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
|
mUpdatedRect.height,
|
||||||
ctx->SetSource(sourceSurface);
|
updatedAreaImageSurface);
|
||||||
ctx->Paint();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newTexture) {
|
if (newTexture) {
|
||||||
@ -231,12 +243,12 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
|
|||||||
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
|
gl()->fBindTexture(LOCAL_GL_TEXTURE_2D, mTexture);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mCanvasGLContext) {
|
bool useGLContext = mCanvasGLContext &&
|
||||||
|
mCanvasGLContext->GetContextType() == gl()->GetContextType();
|
||||||
|
|
||||||
|
if (useGLContext) {
|
||||||
gl()->BindTex2DOffscreen(mCanvasGLContext);
|
gl()->BindTex2DOffscreen(mCanvasGLContext);
|
||||||
DEBUG_GL_ERROR_CHECK(gl());
|
DEBUG_GL_ERROR_CHECK(gl());
|
||||||
}
|
|
||||||
|
|
||||||
if (mCanvasGLContext) {
|
|
||||||
program = mOGLManager->GetRGBALayerProgram();
|
program = mOGLManager->GetRGBALayerProgram();
|
||||||
} else {
|
} else {
|
||||||
program = mOGLManager->GetBGRALayerProgram();
|
program = mOGLManager->GetBGRALayerProgram();
|
||||||
@ -253,7 +265,7 @@ CanvasLayerOGL::RenderLayer(int aPreviousDestination,
|
|||||||
|
|
||||||
DEBUG_GL_ERROR_CHECK(gl());
|
DEBUG_GL_ERROR_CHECK(gl());
|
||||||
|
|
||||||
if (mCanvasGLContext) {
|
if (useGLContext) {
|
||||||
gl()->UnbindTex2DOffscreen(mCanvasGLContext);
|
gl()->UnbindTex2DOffscreen(mCanvasGLContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user