Bug 1167235 - Part 2: Add support for the basic buffer provider to CanvasLayer. r=nical

This commit is contained in:
Bas Schouten 2015-06-19 01:07:21 +02:00
parent 774ff16a5d
commit 369f921871
3 changed files with 11 additions and 1 deletions

View File

@ -18,6 +18,7 @@
#include "mozilla/gfx/BaseSize.h" // for BaseSize
#include "mozilla/gfx/Tools.h"
#include "mozilla/gfx/Point.h" // for IntSize
#include "mozilla/layers/PersistentBufferProvider.h"
#include "nsDebug.h" // for NS_ASSERTION, NS_WARNING, etc
#include "nsISupportsImpl.h" // for gfxContext::AddRef, etc
#include "nsRect.h" // for mozilla::gfx::IntRect
@ -61,6 +62,8 @@ CopyableCanvasLayer::Initialize(const Data& aData)
mGLFrontbuffer = SharedSurface_Basic::Wrap(aData.mGLContext, size, aData.mHasAlpha,
aData.mFrontbufferGLTex);
}
} else if (aData.mBufferProvider) {
mBufferProvider = aData.mBufferProvider;
} else if (aData.mDrawTarget) {
mDrawTarget = aData.mDrawTarget;
mSurface = mDrawTarget->Snapshot();
@ -85,6 +88,10 @@ CopyableCanvasLayer::UpdateTarget(DrawTarget* aDestTarget)
mSurface = mDrawTarget->Snapshot();
}
if (mBufferProvider) {
mSurface = mBufferProvider->GetSnapshot();
}
if (!mGLContext && aDestTarget) {
NS_ASSERTION(mSurface, "Must have surface to draw!");
if (mSurface) {
@ -96,7 +103,7 @@ CopyableCanvasLayer::UpdateTarget(DrawTarget* aDestTarget)
return;
}
if (mDrawTarget) {
if (mDrawTarget || mBufferProvider) {
return;
}

View File

@ -53,6 +53,7 @@ protected:
RefPtr<gfx::SourceSurface> mSurface;
nsRefPtr<gl::GLContext> mGLContext;
GLuint mCanvasFrontbufferTexID;
RefPtr<PersistentBufferProvider> mBufferProvider;
mozilla::RefPtr<mozilla::gfx::DrawTarget> mDrawTarget;
UniquePtr<gl::SharedSurface> mGLFrontbuffer;

View File

@ -2141,6 +2141,7 @@ public:
struct Data {
Data()
: mDrawTarget(nullptr)
, mBufferProvider(nullptr)
, mGLContext(nullptr)
, mFrontbufferGLTex(0)
, mSize(0,0)
@ -2150,6 +2151,7 @@ public:
// One of these two must be specified for Canvas2D, but never both
mozilla::gfx::DrawTarget* mDrawTarget; // a DrawTarget for the canvas contents
PersistentBufferProvider* mBufferProvider; // A BufferProvider for the Canvas contents
mozilla::gl::GLContext* mGLContext; // or this, for GL.
// Frontbuffer override