Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 20; 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/. */
|
|
|
|
|
|
|
|
#include "mozilla/layers/CanvasClient.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "ClientCanvasLayer.h" // for ClientCanvasLayer
|
|
|
|
#include "GLContext.h" // for GLContext
|
|
|
|
#include "GLScreenBuffer.h" // for GLScreenBuffer
|
|
|
|
#include "SurfaceStream.h" // for SurfaceStream
|
|
|
|
#include "SurfaceTypes.h" // for SurfaceStreamHandle
|
|
|
|
#include "gfx2DGlue.h" // for ImageFormatToSurfaceFormat
|
|
|
|
#include "gfxASurface.h" // for gfxASurface, etc
|
|
|
|
#include "gfxPlatform.h" // for gfxPlatform
|
|
|
|
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
|
|
|
#include "mozilla/layers/CompositableForwarder.h"
|
2014-01-10 05:06:06 -08:00
|
|
|
#include "mozilla/layers/GrallocTextureClient.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/layers/LayersTypes.h"
|
|
|
|
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
|
2014-01-10 05:06:06 -08:00
|
|
|
#include "mozilla/layers/TextureClientOGL.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "nsAutoPtr.h" // for nsRefPtr
|
|
|
|
#include "nsDebug.h" // for printf_stderr, NS_ASSERTION
|
|
|
|
#include "nsXULAppAPI.h" // for XRE_GetProcessType, etc
|
2013-05-27 07:12:13 -07:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
#include "SharedSurfaceGralloc.h"
|
|
|
|
#endif
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
|
2013-12-08 18:53:26 -08:00
|
|
|
using namespace mozilla::gfx;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
using namespace mozilla::gl;
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
/* static */ TemporaryRef<CanvasClient>
|
2013-08-01 18:12:15 -07:00
|
|
|
CanvasClient::CreateCanvasClient(CanvasClientType aType,
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
CompositableForwarder* aForwarder,
|
|
|
|
TextureFlags aFlags)
|
|
|
|
{
|
2013-08-01 18:12:15 -07:00
|
|
|
if (aType == CanvasClientGLContext &&
|
2014-01-23 10:26:41 -08:00
|
|
|
aForwarder->GetCompositorBackendType() == LayersBackend::LAYERS_OPENGL) {
|
2013-10-02 13:52:04 -07:00
|
|
|
aFlags |= TEXTURE_DEALLOCATE_CLIENT;
|
2014-01-10 05:06:06 -08:00
|
|
|
return new CanvasClientSurfaceStream(aForwarder, aFlags);
|
2013-08-02 19:59:49 -07:00
|
|
|
}
|
2013-08-03 10:29:37 -07:00
|
|
|
if (gfxPlatform::GetPlatform()->UseDeprecatedTextures()) {
|
2013-10-02 13:52:04 -07:00
|
|
|
aFlags |= TEXTURE_DEALLOCATE_CLIENT;
|
2013-08-03 10:29:37 -07:00
|
|
|
return new DeprecatedCanvasClient2D(aForwarder, aFlags);
|
|
|
|
}
|
|
|
|
return new CanvasClient2D(aForwarder, aFlags);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
|
|
|
{
|
|
|
|
if (mBuffer &&
|
|
|
|
(mBuffer->IsImmutable() || mBuffer->GetSize() != aSize)) {
|
2014-02-10 12:52:35 -08:00
|
|
|
GetForwarder()->RemoveTextureFromCompositable(this, mBuffer);
|
2013-08-03 10:29:37 -07:00
|
|
|
mBuffer = nullptr;
|
|
|
|
}
|
|
|
|
|
2013-08-19 16:39:55 -07:00
|
|
|
bool bufferCreated = false;
|
2013-08-03 10:29:37 -07:00
|
|
|
if (!mBuffer) {
|
|
|
|
bool isOpaque = (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE);
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxContentType contentType = isOpaque
|
2014-01-23 10:26:40 -08:00
|
|
|
? gfxContentType::COLOR
|
|
|
|
: gfxContentType::COLOR_ALPHA;
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxImageFormat format
|
2013-08-03 10:29:37 -07:00
|
|
|
= gfxPlatform::GetPlatform()->OptimalFormatForContent(contentType);
|
2014-02-19 11:28:05 -08:00
|
|
|
mBuffer = CreateBufferTextureClient(gfx::ImageFormatToSurfaceFormat(format));
|
2013-08-03 10:29:37 -07:00
|
|
|
MOZ_ASSERT(mBuffer->AsTextureClientSurface());
|
|
|
|
mBuffer->AsTextureClientSurface()->AllocateForSurface(aSize);
|
|
|
|
|
2013-08-19 16:39:55 -07:00
|
|
|
bufferCreated = true;
|
2013-08-03 10:29:37 -07:00
|
|
|
}
|
|
|
|
|
2014-01-07 08:20:11 -08:00
|
|
|
if (!mBuffer->Lock(OPEN_WRITE_ONLY)) {
|
2013-08-03 10:29:37 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-19 07:53:26 -08:00
|
|
|
bool updated = false;
|
|
|
|
{
|
|
|
|
// Restrict drawTarget to a scope so that terminates before Unlock.
|
|
|
|
RefPtr<DrawTarget> drawTarget =
|
|
|
|
mBuffer->AsTextureClientDrawTarget()->GetAsDrawTarget();
|
|
|
|
if (drawTarget) {
|
|
|
|
aLayer->UpdateTarget(drawTarget);
|
|
|
|
updated = true;
|
|
|
|
}
|
2013-08-03 10:29:37 -07:00
|
|
|
}
|
|
|
|
mBuffer->Unlock();
|
|
|
|
|
2013-10-09 16:18:29 -07:00
|
|
|
if (bufferCreated && !AddTextureClient(mBuffer)) {
|
|
|
|
mBuffer = nullptr;
|
|
|
|
return;
|
2013-08-19 16:39:55 -07:00
|
|
|
}
|
|
|
|
|
2014-02-19 07:53:26 -08:00
|
|
|
if (updated) {
|
2013-08-03 10:29:37 -07:00
|
|
|
GetForwarder()->UpdatedTexture(this, mBuffer, nullptr);
|
|
|
|
GetForwarder()->UseTexture(this, mBuffer);
|
|
|
|
}
|
2013-08-02 19:59:49 -07:00
|
|
|
}
|
|
|
|
|
2014-01-10 05:06:06 -08:00
|
|
|
CanvasClientSurfaceStream::CanvasClientSurfaceStream(CompositableForwarder* aLayerForwarder,
|
|
|
|
TextureFlags aFlags)
|
|
|
|
: CanvasClient(aLayerForwarder, aFlags)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
CanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
|
|
|
{
|
|
|
|
GLScreenBuffer* screen = aLayer->mGLContext->Screen();
|
2014-03-05 13:49:37 -08:00
|
|
|
SurfaceStream* stream = nullptr;
|
|
|
|
|
|
|
|
if (aLayer->mStream) {
|
|
|
|
stream = aLayer->mStream;
|
|
|
|
|
|
|
|
// Copy our current surface to the current producer surface in our stream, then
|
|
|
|
// call SwapProducer to make a new buffer ready.
|
|
|
|
stream->CopySurfaceToProducer(aLayer->mTextureSurface, aLayer->mFactory);
|
|
|
|
stream->SwapProducer(aLayer->mFactory, gfx::IntSize(aSize.width, aSize.height));
|
|
|
|
} else {
|
|
|
|
stream = screen->Stream();
|
|
|
|
}
|
2014-01-10 05:06:06 -08:00
|
|
|
|
|
|
|
bool isCrossProcess = !(XRE_GetProcessType() == GeckoProcessType_Default);
|
|
|
|
bool bufferCreated = false;
|
|
|
|
if (isCrossProcess) {
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
SharedSurface* surf = stream->SwapConsumer();
|
|
|
|
if (!surf) {
|
|
|
|
printf_stderr("surf is null post-SwapConsumer!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (surf->Type() != SharedSurfaceType::Gralloc) {
|
|
|
|
printf_stderr("Unexpected non-Gralloc SharedSurface in IPC path!");
|
|
|
|
MOZ_ASSERT(false);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
SharedSurface_Gralloc* grallocSurf = SharedSurface_Gralloc::Cast(surf);
|
|
|
|
|
2014-02-18 06:46:13 -08:00
|
|
|
RefPtr<GrallocTextureClientOGL> grallocTextureClient =
|
2014-01-10 05:06:06 -08:00
|
|
|
static_cast<GrallocTextureClientOGL*>(grallocSurf->GetTextureClient());
|
|
|
|
|
|
|
|
// If IPDLActor is null means this TextureClient didn't AddTextureClient yet
|
|
|
|
if (!grallocTextureClient->GetIPDLActor()) {
|
|
|
|
grallocTextureClient->SetTextureFlags(mTextureInfo.mTextureFlags);
|
|
|
|
AddTextureClient(grallocTextureClient);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (grallocTextureClient->GetIPDLActor()) {
|
|
|
|
GetForwarder()->UseTexture(this, grallocTextureClient);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
printf_stderr("isCrossProcess, but not MOZ_WIDGET_GONK! Someone needs to write some code!");
|
|
|
|
MOZ_ASSERT(false);
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
if (!mBuffer) {
|
|
|
|
StreamTextureClientOGL* textureClient =
|
|
|
|
new StreamTextureClientOGL(mTextureInfo.mTextureFlags);
|
|
|
|
textureClient->InitWith(stream);
|
|
|
|
mBuffer = textureClient;
|
|
|
|
bufferCreated = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bufferCreated && !AddTextureClient(mBuffer)) {
|
|
|
|
mBuffer = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mBuffer) {
|
|
|
|
GetForwarder()->UseTexture(this, mBuffer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
aLayer->Painted();
|
|
|
|
}
|
|
|
|
|
2013-08-02 19:59:49 -07:00
|
|
|
void
|
2013-08-03 10:29:28 -07:00
|
|
|
DeprecatedCanvasClient2D::Updated()
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
{
|
2013-09-23 18:14:12 -07:00
|
|
|
mForwarder->UpdateTexture(this, 1, mDeprecatedTextureClient->LockSurfaceDescriptor());
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
}
|
|
|
|
|
2013-04-12 00:28:55 -07:00
|
|
|
|
2013-08-03 10:29:28 -07:00
|
|
|
DeprecatedCanvasClient2D::DeprecatedCanvasClient2D(CompositableForwarder* aFwd,
|
|
|
|
TextureFlags aFlags)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
: CanvasClient(aFwd, aFlags)
|
|
|
|
{
|
2013-04-12 00:28:55 -07:00
|
|
|
mTextureInfo.mCompositableType = BUFFER_IMAGE_SINGLE;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-08-03 10:29:28 -07:00
|
|
|
DeprecatedCanvasClient2D::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
{
|
2013-09-23 18:14:12 -07:00
|
|
|
bool isOpaque = (aLayer->GetContentFlags() & Layer::CONTENT_OPAQUE);
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxContentType contentType = isOpaque
|
2014-01-23 10:26:40 -08:00
|
|
|
? gfxContentType::COLOR
|
|
|
|
: gfxContentType::COLOR_ALPHA;
|
2013-09-23 18:14:12 -07:00
|
|
|
|
2013-07-08 14:30:44 -07:00
|
|
|
if (!mDeprecatedTextureClient) {
|
2013-09-23 18:14:12 -07:00
|
|
|
mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_CONTENT, contentType);
|
2013-08-20 18:13:57 -07:00
|
|
|
if (!mDeprecatedTextureClient) {
|
2013-09-23 18:14:12 -07:00
|
|
|
mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_FALLBACK, contentType);
|
2013-08-20 18:13:57 -07:00
|
|
|
if (!mDeprecatedTextureClient) {
|
|
|
|
NS_WARNING("Could not create texture client");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
}
|
|
|
|
|
2013-08-17 23:46:21 -07:00
|
|
|
if (!mDeprecatedTextureClient->EnsureAllocated(aSize, contentType)) {
|
2013-08-20 18:13:57 -07:00
|
|
|
// We might already be on the fallback texture client if we couldn't create a
|
|
|
|
// better one above. In which case this call to create is wasted. But I don't
|
|
|
|
// think this will happen often enough to be worth complicating the code with
|
|
|
|
// further checks.
|
2013-09-23 18:14:12 -07:00
|
|
|
mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_FALLBACK, contentType);
|
2013-08-17 23:46:21 -07:00
|
|
|
MOZ_ASSERT(mDeprecatedTextureClient, "Failed to create texture client");
|
|
|
|
if (!mDeprecatedTextureClient->EnsureAllocated(aSize, contentType)) {
|
|
|
|
NS_WARNING("Could not allocate texture client");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
|
2013-07-31 15:17:41 -07:00
|
|
|
gfxASurface* surface = mDeprecatedTextureClient->LockSurface();
|
2014-02-12 07:07:46 -08:00
|
|
|
aLayer->DeprecatedUpdateSurface(surface);
|
2013-07-08 14:30:44 -07:00
|
|
|
mDeprecatedTextureClient->Unlock();
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
}
|
|
|
|
|
2013-05-01 16:24:27 -07:00
|
|
|
void
|
2013-08-03 10:29:28 -07:00
|
|
|
DeprecatedCanvasClientSurfaceStream::Updated()
|
2013-05-01 16:24:27 -07:00
|
|
|
{
|
2013-09-23 18:14:12 -07:00
|
|
|
mForwarder->UpdateTextureNoSwap(this, 1, mDeprecatedTextureClient->LockSurfaceDescriptor());
|
2013-05-01 16:24:27 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-03 10:29:28 -07:00
|
|
|
DeprecatedCanvasClientSurfaceStream::DeprecatedCanvasClientSurfaceStream(CompositableForwarder* aFwd,
|
|
|
|
TextureFlags aFlags)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
: CanvasClient(aFwd, aFlags)
|
|
|
|
{
|
2013-08-01 18:12:15 -07:00
|
|
|
mTextureInfo.mCompositableType = BUFFER_IMAGE_SINGLE;
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2013-08-03 10:29:28 -07:00
|
|
|
DeprecatedCanvasClientSurfaceStream::Update(gfx::IntSize aSize, ClientCanvasLayer* aLayer)
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
{
|
2013-07-08 14:30:44 -07:00
|
|
|
if (!mDeprecatedTextureClient) {
|
2013-09-23 18:14:12 -07:00
|
|
|
mDeprecatedTextureClient = CreateDeprecatedTextureClient(TEXTURE_STREAM_GL,
|
2014-01-23 10:26:41 -08:00
|
|
|
aLayer->GetSurfaceMode() == SurfaceMode::SURFACE_OPAQUE
|
2014-01-23 10:26:40 -08:00
|
|
|
? gfxContentType::COLOR
|
|
|
|
: gfxContentType::COLOR_ALPHA);
|
2013-07-08 14:30:44 -07:00
|
|
|
MOZ_ASSERT(mDeprecatedTextureClient, "Failed to create texture client");
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
}
|
|
|
|
|
2013-08-01 18:12:15 -07:00
|
|
|
NS_ASSERTION(aLayer->mGLContext, "CanvasClientSurfaceStream should only be used with GL canvases");
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
|
|
|
|
// the content type won't be used
|
2014-01-23 10:26:40 -08:00
|
|
|
mDeprecatedTextureClient->EnsureAllocated(aSize, gfxContentType::COLOR);
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
|
|
|
|
GLScreenBuffer* screen = aLayer->mGLContext->Screen();
|
2014-03-05 13:49:37 -08:00
|
|
|
SurfaceStream* stream = nullptr;
|
|
|
|
|
|
|
|
if (aLayer->mStream) {
|
|
|
|
stream = aLayer->mStream;
|
|
|
|
stream->CopySurfaceToProducer(aLayer->mTextureSurface, aLayer->mFactory);
|
|
|
|
stream->SwapProducer(aLayer->mFactory, gfx::IntSize(aSize.width, aSize.height));
|
|
|
|
} else {
|
|
|
|
stream = screen->Stream();
|
|
|
|
}
|
2013-05-27 07:12:13 -07:00
|
|
|
|
|
|
|
bool isCrossProcess = !(XRE_GetProcessType() == GeckoProcessType_Default);
|
|
|
|
if (isCrossProcess) {
|
|
|
|
// swap staging -> consumer so we can send it to the compositor
|
|
|
|
SharedSurface* surf = stream->SwapConsumer();
|
|
|
|
if (!surf) {
|
|
|
|
printf_stderr("surf is null post-SwapConsumer!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
if (surf->Type() != SharedSurfaceType::Gralloc) {
|
|
|
|
printf_stderr("Unexpected non-Gralloc SharedSurface in IPC path!");
|
|
|
|
return;
|
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
|
2013-05-27 07:12:13 -07:00
|
|
|
SharedSurface_Gralloc* grallocSurf = SharedSurface_Gralloc::Cast(surf);
|
2014-01-10 05:06:06 -08:00
|
|
|
//XXX todo
|
|
|
|
//mDeprecatedTextureClient->SetDescriptor(grallocSurf->GetDescriptor());
|
2013-05-27 07:12:13 -07:00
|
|
|
#else
|
|
|
|
printf_stderr("isCrossProcess, but not MOZ_WIDGET_GONK! Someone needs to write some code!");
|
|
|
|
MOZ_ASSERT(false);
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
SurfaceStreamHandle handle = stream->GetShareHandle();
|
2013-09-08 19:35:20 -07:00
|
|
|
mDeprecatedTextureClient->SetDescriptor(SurfaceStreamDescriptor(handle, false));
|
|
|
|
|
|
|
|
// Bug 894405
|
|
|
|
//
|
|
|
|
// Ref this so the SurfaceStream doesn't disappear unexpectedly. The
|
|
|
|
// Compositor will need to unref it when finished.
|
|
|
|
aLayer->mGLContext->AddRef();
|
2013-05-27 07:12:13 -07:00
|
|
|
}
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
|
|
|
|
aLayer->Painted();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|