2012-08-19 12:33:25 -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 "ImageContainer.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include <string.h> // for memcpy, memset
|
2014-09-17 06:13:29 -07:00
|
|
|
#include "GLImages.h" // for SurfaceTextureImage
|
2013-12-13 09:32:02 -08:00
|
|
|
#include "gfx2DGlue.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "gfxPlatform.h" // for gfxPlatform
|
|
|
|
#include "gfxUtils.h" // for gfxUtils
|
2015-06-17 07:00:52 -07:00
|
|
|
#include "mozilla/RefPtr.h" // for already_AddRefed
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/ipc/CrossProcessMutex.h" // for CrossProcessMutex, etc
|
|
|
|
#include "mozilla/layers/CompositorTypes.h"
|
|
|
|
#include "mozilla/layers/ImageBridgeChild.h" // for ImageBridgeChild
|
2015-07-05 20:02:26 -07:00
|
|
|
#include "mozilla/layers/PImageContainerChild.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/layers/ImageClient.h" // for ImageClient
|
2015-07-03 00:39:09 -07:00
|
|
|
#include "mozilla/layers/LayersMessages.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "nsISupportsUtils.h" // for NS_IF_ADDREF
|
2013-12-13 09:32:02 -08:00
|
|
|
#include "YCbCrUtils.h" // for YCbCr conversions
|
2013-08-11 16:17:23 -07:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2012-08-21 03:22:58 -07:00
|
|
|
#include "GrallocImages.h"
|
2014-12-19 13:42:19 -08:00
|
|
|
#endif
|
2014-12-23 22:04:07 -08:00
|
|
|
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_CAMERA) && defined(MOZ_WEBRTC)
|
2014-12-17 20:42:00 -08:00
|
|
|
#include "GonkCameraImage.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#endif
|
2014-01-15 07:06:43 -08:00
|
|
|
#include "gfx2DGlue.h"
|
2014-02-16 14:23:39 -08:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2012-08-19 12:33:25 -07:00
|
|
|
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
#include "mozilla/gfx/QuartzSupport.h"
|
2013-10-31 18:54:14 -07:00
|
|
|
#include "MacIOSurfaceImage.h"
|
2012-08-19 12:33:25 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XP_WIN
|
|
|
|
#include "gfxWindowsPlatform.h"
|
|
|
|
#include <d3d10_1.h>
|
2013-05-04 03:12:40 -07:00
|
|
|
#include "D3D9SurfaceImage.h"
|
2015-03-30 22:21:15 -07:00
|
|
|
#include "D3D11ShareHandleImage.h"
|
2012-08-19 12:33:25 -07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
2014-05-22 03:11:45 -07:00
|
|
|
using namespace mozilla::ipc;
|
|
|
|
using namespace android;
|
|
|
|
using namespace mozilla::gfx;
|
2013-08-11 16:17:23 -07:00
|
|
|
|
2013-08-12 02:51:49 -07:00
|
|
|
Atomic<int32_t> Image::sSerialCounter(0);
|
2012-08-22 17:08:26 -07:00
|
|
|
|
2015-05-11 17:56:09 -07:00
|
|
|
Atomic<uint32_t> ImageContainer::sGenerationCounter(0);
|
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
already_AddRefed<Image>
|
2014-01-30 14:58:51 -08:00
|
|
|
ImageFactory::CreateImage(ImageFormat aFormat,
|
2013-12-13 09:32:02 -08:00
|
|
|
const gfx::IntSize &,
|
2012-08-19 12:33:25 -07:00
|
|
|
BufferRecycleBin *aRecycleBin)
|
|
|
|
{
|
|
|
|
nsRefPtr<Image> img;
|
2012-08-21 03:22:58 -07:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
2014-01-30 14:58:51 -08:00
|
|
|
if (aFormat == ImageFormat::GRALLOC_PLANAR_YCBCR) {
|
2013-07-24 19:13:35 -07:00
|
|
|
img = new GrallocImage();
|
2012-08-21 03:22:58 -07:00
|
|
|
return img.forget();
|
|
|
|
}
|
2014-08-18 19:14:00 -07:00
|
|
|
if (aFormat == ImageFormat::OVERLAY_IMAGE) {
|
|
|
|
img = new OverlayImage();
|
|
|
|
return img.forget();
|
|
|
|
}
|
2014-12-19 13:42:19 -08:00
|
|
|
#endif
|
2014-12-23 22:04:07 -08:00
|
|
|
#if defined(MOZ_WIDGET_GONK) && defined(MOZ_B2G_CAMERA) && defined(MOZ_WEBRTC)
|
2014-12-17 20:42:00 -08:00
|
|
|
if (aFormat == ImageFormat::GONK_CAMERA_IMAGE) {
|
|
|
|
img = new GonkCameraImage();
|
|
|
|
return img.forget();
|
|
|
|
}
|
2012-08-21 03:22:58 -07:00
|
|
|
#endif
|
2014-01-30 14:58:51 -08:00
|
|
|
if (aFormat == ImageFormat::PLANAR_YCBCR) {
|
2012-08-19 12:33:25 -07:00
|
|
|
img = new PlanarYCbCrImage(aRecycleBin);
|
2012-08-21 03:22:58 -07:00
|
|
|
return img.forget();
|
|
|
|
}
|
2014-01-30 14:58:51 -08:00
|
|
|
if (aFormat == ImageFormat::CAIRO_SURFACE) {
|
2012-08-19 12:33:25 -07:00
|
|
|
img = new CairoImage();
|
2012-08-21 03:22:58 -07:00
|
|
|
return img.forget();
|
|
|
|
}
|
2014-09-17 06:13:29 -07:00
|
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
|
|
if (aFormat == ImageFormat::SURFACE_TEXTURE) {
|
|
|
|
img = new SurfaceTextureImage();
|
|
|
|
return img.forget();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (aFormat == ImageFormat::EGLIMAGE) {
|
|
|
|
img = new EGLImageImage();
|
2012-08-21 03:22:58 -07:00
|
|
|
return img.forget();
|
|
|
|
}
|
2013-10-31 18:54:14 -07:00
|
|
|
#ifdef XP_MACOSX
|
2014-01-30 14:58:51 -08:00
|
|
|
if (aFormat == ImageFormat::MAC_IOSURFACE) {
|
2013-10-31 18:54:14 -07:00
|
|
|
img = new MacIOSurfaceImage();
|
|
|
|
return img.forget();
|
|
|
|
}
|
|
|
|
#endif
|
2013-05-04 03:12:40 -07:00
|
|
|
#ifdef XP_WIN
|
2015-03-30 22:21:15 -07:00
|
|
|
if (aFormat == ImageFormat::D3D11_SHARE_HANDLE_TEXTURE) {
|
|
|
|
img = new D3D11ShareHandleImage();
|
|
|
|
return img.forget();
|
|
|
|
}
|
2014-01-30 14:58:51 -08:00
|
|
|
if (aFormat == ImageFormat::D3D9_RGB32_TEXTURE) {
|
2013-05-04 03:12:40 -07:00
|
|
|
img = new D3D9SurfaceImage();
|
|
|
|
return img.forget();
|
|
|
|
}
|
2012-08-21 03:22:58 -07:00
|
|
|
#endif
|
|
|
|
return nullptr;
|
2012-08-19 12:33:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
BufferRecycleBin::BufferRecycleBin()
|
|
|
|
: mLock("mozilla.layers.BufferRecycleBin.mLock")
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2012-08-22 08:56:38 -07:00
|
|
|
BufferRecycleBin::RecycleBuffer(uint8_t* aBuffer, uint32_t aSize)
|
2012-08-19 12:33:25 -07:00
|
|
|
{
|
|
|
|
MutexAutoLock lock(mLock);
|
|
|
|
|
|
|
|
if (!mRecycledBuffers.IsEmpty() && aSize != mRecycledBufferSize) {
|
|
|
|
mRecycledBuffers.Clear();
|
|
|
|
}
|
|
|
|
mRecycledBufferSize = aSize;
|
|
|
|
mRecycledBuffers.AppendElement(aBuffer);
|
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t*
|
|
|
|
BufferRecycleBin::GetBuffer(uint32_t aSize)
|
2012-08-19 12:33:25 -07:00
|
|
|
{
|
|
|
|
MutexAutoLock lock(mLock);
|
|
|
|
|
|
|
|
if (mRecycledBuffers.IsEmpty() || mRecycledBufferSize != aSize)
|
2012-08-22 08:56:38 -07:00
|
|
|
return new uint8_t[aSize];
|
2012-08-19 12:33:25 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint32_t last = mRecycledBuffers.Length() - 1;
|
|
|
|
uint8_t* result = mRecycledBuffers[last].forget();
|
2012-08-19 12:33:25 -07:00
|
|
|
mRecycledBuffers.RemoveElementAt(last);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-07-05 20:02:26 -07:00
|
|
|
/**
|
|
|
|
* The child side of PImageContainer. It's best to avoid ImageContainer filling
|
|
|
|
* this role since IPDL objects should be associated with a single thread and
|
|
|
|
* ImageContainer definitely isn't. This object belongs to (and is always
|
|
|
|
* destroyed on) the ImageBridge thread, except when we need to destroy it
|
|
|
|
* during shutdown.
|
|
|
|
* An ImageContainer owns one of these; we have a weak reference to our
|
|
|
|
* ImageContainer.
|
|
|
|
*/
|
|
|
|
class ImageContainerChild : public PImageContainerChild {
|
|
|
|
public:
|
|
|
|
explicit ImageContainerChild(ImageContainer* aImageContainer)
|
|
|
|
: mLock("ImageContainerChild"), mImageContainer(aImageContainer) {}
|
|
|
|
void ForgetImageContainer()
|
|
|
|
{
|
|
|
|
MutexAutoLock lock(mLock);
|
|
|
|
mImageContainer = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This protects mImageContainer. This is always taken before the
|
|
|
|
// mImageContainer's monitor (when both need to be held).
|
|
|
|
Mutex mLock;
|
|
|
|
ImageContainer* mImageContainer;
|
|
|
|
};
|
|
|
|
|
|
|
|
ImageContainer::ImageContainer(Mode flag)
|
2012-08-19 12:33:25 -07:00
|
|
|
: mReentrantMonitor("ImageContainer.mReentrantMonitor"),
|
2015-05-11 17:56:09 -07:00
|
|
|
mGenerationCounter(++sGenerationCounter),
|
2012-08-19 12:33:25 -07:00
|
|
|
mPaintCount(0),
|
2015-05-10 19:07:07 -07:00
|
|
|
mDroppedImageCount(0),
|
2012-08-19 12:33:25 -07:00
|
|
|
mPreviousImagePainted(false),
|
2015-05-10 19:07:07 -07:00
|
|
|
mCurrentImageComposited(false),
|
2012-08-19 12:33:25 -07:00
|
|
|
mImageFactory(new ImageFactory()),
|
|
|
|
mRecycleBin(new BufferRecycleBin()),
|
2015-07-05 20:02:26 -07:00
|
|
|
mImageClient(nullptr),
|
|
|
|
mIPDLChild(nullptr)
|
2012-08-19 12:33:25 -07:00
|
|
|
{
|
2015-05-27 16:35:00 -07:00
|
|
|
if (ImageBridgeChild::IsCreated()) {
|
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 refcount of this ImageClient is 1. we don't use a RefPtr here because the refcount
|
|
|
|
// of this class must be done on the ImageBridge thread.
|
2015-07-05 20:02:26 -07:00
|
|
|
switch (flag) {
|
2015-05-27 16:35:00 -07:00
|
|
|
case SYNCHRONOUS:
|
|
|
|
break;
|
|
|
|
case ASYNCHRONOUS:
|
2015-07-05 20:02:26 -07:00
|
|
|
mIPDLChild = new ImageContainerChild(this);
|
|
|
|
mImageClient = ImageBridgeChild::GetSingleton()->CreateImageClient(CompositableType::IMAGE, this).take();
|
2015-05-27 16:35:00 -07:00
|
|
|
MOZ_ASSERT(mImageClient);
|
|
|
|
break;
|
|
|
|
case ASYNCHRONOUS_OVERLAY:
|
2015-07-05 20:02:26 -07:00
|
|
|
mIPDLChild = new ImageContainerChild(this);
|
|
|
|
mImageClient = ImageBridgeChild::GetSingleton()->CreateImageClient(CompositableType::IMAGE_OVERLAY, this).take();
|
2015-05-27 16:35:00 -07:00
|
|
|
MOZ_ASSERT(mImageClient);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
MOZ_ASSERT(false, "This flag is invalid.");
|
|
|
|
break;
|
|
|
|
}
|
2012-08-19 12:33:25 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageContainer::~ImageContainer()
|
|
|
|
{
|
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
|
|
|
if (IsAsync()) {
|
2015-07-05 20:02:26 -07:00
|
|
|
mIPDLChild->ForgetImageContainer();
|
|
|
|
ImageBridgeChild::DispatchReleaseImageClient(mImageClient, mIPDLChild);
|
2012-08-19 12:33:25 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<Image>
|
2014-01-30 14:58:51 -08:00
|
|
|
ImageContainer::CreateImage(ImageFormat aFormat)
|
2012-08-19 12:33:25 -07:00
|
|
|
{
|
|
|
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
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
|
|
|
|
2014-08-18 19:14:00 -07:00
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
if (aFormat == ImageFormat::OVERLAY_IMAGE) {
|
|
|
|
if (mImageClient && mImageClient->GetTextureInfo().mCompositableType != CompositableType::IMAGE_OVERLAY) {
|
|
|
|
// If this ImageContainer is async but the image type mismatch, fix it here
|
|
|
|
if (ImageBridgeChild::IsCreated()) {
|
|
|
|
ImageBridgeChild::DispatchReleaseImageClient(mImageClient);
|
2015-07-05 20:02:26 -07:00
|
|
|
mImageClient = ImageBridgeChild::GetSingleton()->CreateImageClient(
|
|
|
|
CompositableType::IMAGE_OVERLAY, this).take();
|
2014-08-18 19:14:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#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
|
|
|
if (mImageClient) {
|
2014-01-30 14:58:51 -08:00
|
|
|
nsRefPtr<Image> img = mImageClient->CreateImage(aFormat);
|
2012-11-05 02:38:03 -08:00
|
|
|
if (img) {
|
|
|
|
return img.forget();
|
|
|
|
}
|
|
|
|
}
|
2014-01-30 14:58:51 -08:00
|
|
|
return mImageFactory->CreateImage(aFormat, mScaleHint, mRecycleBin);
|
2012-08-19 12:33:25 -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
|
|
|
void
|
2015-05-10 19:07:07 -07:00
|
|
|
ImageContainer::SetCurrentImageInternal(Image *aImage,
|
|
|
|
const TimeStamp& aTimeStamp)
|
2012-08-19 12:33:25 -07:00
|
|
|
{
|
|
|
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
|
|
|
|
2015-05-11 17:56:09 -07:00
|
|
|
if (mActiveImage != aImage) {
|
2015-05-10 19:07:07 -07:00
|
|
|
if (!mCurrentImageComposited && !mCurrentImageTimeStamp.IsNull() &&
|
|
|
|
(aTimeStamp.IsNull() || aTimeStamp > mCurrentImageTimeStamp)) {
|
|
|
|
mFrameIDsNotYetComposited.AppendElement(mGenerationCounter);
|
|
|
|
}
|
2015-05-11 17:56:09 -07:00
|
|
|
mGenerationCounter = ++sGenerationCounter;
|
2015-05-10 19:07:07 -07:00
|
|
|
mCurrentImageComposited = false;
|
|
|
|
mActiveImage = aImage;
|
|
|
|
mCurrentImageTimeStamp = aTimeStamp;
|
2015-05-11 17:56:09 -07:00
|
|
|
}
|
2012-08-19 12:33:25 -07:00
|
|
|
CurrentImageChanged();
|
|
|
|
}
|
|
|
|
|
2013-09-12 07:50:28 -07:00
|
|
|
void
|
2015-03-25 18:17:13 -07:00
|
|
|
ImageContainer::ClearImagesFromImageBridge()
|
2013-09-12 07:50:28 -07:00
|
|
|
{
|
|
|
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
2015-05-10 19:07:07 -07:00
|
|
|
SetCurrentImageInternal(nullptr, TimeStamp());
|
2013-09-12 07:50:28 -07:00
|
|
|
}
|
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
void
|
2015-07-06 14:58:18 -07:00
|
|
|
ImageContainer::SetCurrentImages(const nsTArray<NonOwningImage>& aImages)
|
2012-08-19 12:33:25 -07:00
|
|
|
{
|
2015-07-06 14:58:18 -07:00
|
|
|
MOZ_ASSERT(!aImages.IsEmpty());
|
2012-08-19 12:33:25 -07:00
|
|
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
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
|
|
|
if (IsAsync()) {
|
2013-09-12 07:50:28 -07:00
|
|
|
ImageBridgeChild::DispatchImageClientUpdate(mImageClient, this);
|
2012-08-19 12:33:25 -07:00
|
|
|
}
|
2015-07-06 14:58:18 -07:00
|
|
|
MOZ_ASSERT(aImages.Length() == 1);
|
2015-05-10 19:07:07 -07:00
|
|
|
SetCurrentImageInternal(aImages[0].mImage, aImages[0].mTimeStamp);
|
2012-08-19 12:33:25 -07:00
|
|
|
}
|
|
|
|
|
2013-10-17 08:09:15 -07:00
|
|
|
void
|
|
|
|
ImageContainer::ClearAllImages()
|
|
|
|
{
|
|
|
|
if (IsAsync()) {
|
2015-03-25 18:17:13 -07:00
|
|
|
// Let ImageClient release all TextureClients. This doesn't return
|
|
|
|
// until ImageBridge has called ClearCurrentImageFromImageBridge.
|
2015-03-25 18:08:30 -07:00
|
|
|
ImageBridgeChild::FlushAllImages(mImageClient, this);
|
2013-10-17 08:09:15 -07:00
|
|
|
return;
|
|
|
|
}
|
2013-12-11 17:44:45 -08:00
|
|
|
|
2013-10-17 08:09:15 -07:00
|
|
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
2015-05-10 19:07:07 -07:00
|
|
|
SetCurrentImageInternal(nullptr, TimeStamp());
|
2013-10-17 08:09:15 -07:00
|
|
|
}
|
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
void
|
|
|
|
ImageContainer::SetCurrentImageInTransaction(Image *aImage)
|
|
|
|
{
|
|
|
|
NS_ASSERTION(NS_IsMainThread(), "Should be on main thread.");
|
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
|
|
|
NS_ASSERTION(!mImageClient, "Should use async image transfer with ImageBridge.");
|
|
|
|
|
2015-05-10 19:07:07 -07:00
|
|
|
SetCurrentImageInternal(aImage, TimeStamp());
|
2012-08-19 12:33:25 -07:00
|
|
|
}
|
|
|
|
|
2015-03-25 18:08:30 -07:00
|
|
|
bool ImageContainer::IsAsync() const
|
|
|
|
{
|
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
|
|
|
return mImageClient != nullptr;
|
2012-08-19 12:33:25 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t ImageContainer::GetAsyncContainerID() const
|
2012-08-19 12:33:25 -07:00
|
|
|
{
|
|
|
|
NS_ASSERTION(IsAsync(),"Shared image ID is only relevant to async ImageContainers");
|
|
|
|
if (IsAsync()) {
|
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
|
|
|
return mImageClient->GetAsyncID();
|
2012-08-19 12:33:25 -07:00
|
|
|
} else {
|
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
|
|
|
return 0; // zero is always an invalid AsyncID
|
2012-08-19 12:33:25 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ImageContainer::HasCurrentImage()
|
|
|
|
{
|
|
|
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
|
|
|
|
|
|
|
return !!mActiveImage.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-05-11 17:56:09 -07:00
|
|
|
ImageContainer::GetCurrentImages(nsTArray<OwningImage>* aImages,
|
|
|
|
uint32_t* aGenerationCounter)
|
2014-01-15 07:06:43 -08:00
|
|
|
{
|
|
|
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
|
|
|
|
2015-03-26 16:07:53 -07:00
|
|
|
if (mActiveImage) {
|
2015-07-05 20:02:26 -07:00
|
|
|
OwningImage* img = aImages->AppendElement();
|
|
|
|
img->mImage = mActiveImage;
|
|
|
|
img->mFrameID = mGenerationCounter;
|
|
|
|
img->mProducerID = 0;
|
2015-03-26 16:07:53 -07:00
|
|
|
}
|
2015-05-11 17:56:09 -07:00
|
|
|
if (aGenerationCounter) {
|
|
|
|
*aGenerationCounter = mGenerationCounter;
|
|
|
|
}
|
2014-01-15 07:06:43 -08:00
|
|
|
}
|
|
|
|
|
2013-12-13 09:32:02 -08:00
|
|
|
gfx::IntSize
|
2012-08-19 12:33:25 -07:00
|
|
|
ImageContainer::GetCurrentSize()
|
|
|
|
{
|
|
|
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
|
|
|
|
|
|
|
if (!mActiveImage) {
|
2013-12-31 01:06:12 -08:00
|
|
|
return gfx::IntSize(0, 0);
|
2012-08-19 12:33:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return mActiveImage->GetSize();
|
|
|
|
}
|
|
|
|
|
2015-07-03 00:39:09 -07:00
|
|
|
void
|
|
|
|
ImageContainer::NotifyCompositeInternal(const ImageCompositeNotification& aNotification)
|
|
|
|
{
|
|
|
|
ReentrantMonitorAutoEnter mon(mReentrantMonitor);
|
|
|
|
|
2015-05-10 19:07:07 -07:00
|
|
|
while (!mFrameIDsNotYetComposited.IsEmpty()) {
|
|
|
|
if (mFrameIDsNotYetComposited[0] <= aNotification.frameID()) {
|
|
|
|
if (mFrameIDsNotYetComposited[0] < aNotification.frameID()) {
|
|
|
|
++mDroppedImageCount;
|
|
|
|
}
|
|
|
|
mFrameIDsNotYetComposited.RemoveElementAt(0);
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aNotification.frameID() == mGenerationCounter) {
|
|
|
|
mCurrentImageComposited = true;
|
|
|
|
}
|
|
|
|
|
2015-07-03 00:39:09 -07:00
|
|
|
if (!aNotification.imageTimeStamp().IsNull()) {
|
|
|
|
mPaintDelay = aNotification.firstCompositeTimeStamp() -
|
|
|
|
aNotification.imageTimeStamp();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
PlanarYCbCrImage::PlanarYCbCrImage(BufferRecycleBin *aRecycleBin)
|
2014-01-30 14:58:49 -08:00
|
|
|
: Image(nullptr, ImageFormat::PLANAR_YCBCR)
|
2012-08-19 12:33:25 -07:00
|
|
|
, mBufferSize(0)
|
2014-01-23 10:26:40 -08:00
|
|
|
, mOffscreenFormat(gfxImageFormat::Unknown)
|
2012-08-19 12:33:25 -07:00
|
|
|
, mRecycleBin(aRecycleBin)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PlanarYCbCrImage::~PlanarYCbCrImage()
|
|
|
|
{
|
|
|
|
if (mBuffer) {
|
|
|
|
mRecycleBin->RecycleBuffer(mBuffer.forget(), mBufferSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-19 14:33:12 -07:00
|
|
|
size_t
|
|
|
|
PlanarYCbCrImage::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const
|
|
|
|
{
|
|
|
|
// Ignoring:
|
|
|
|
// - mData - just wraps mBuffer
|
|
|
|
// - Surfaces should be reported under gfx-surfaces-*:
|
|
|
|
// - mSourceSurface
|
|
|
|
// - Base class:
|
|
|
|
// - mImplData is not used
|
|
|
|
// Not owned:
|
|
|
|
// - mRecycleBin
|
|
|
|
size_t size = mBuffer.SizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
|
|
|
|
// Could add in the future:
|
|
|
|
// - mBackendData (from base class)
|
|
|
|
|
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2014-07-11 13:50:23 -07:00
|
|
|
uint8_t*
|
2012-08-22 08:56:38 -07:00
|
|
|
PlanarYCbCrImage::AllocateBuffer(uint32_t aSize)
|
2012-08-19 12:33:25 -07:00
|
|
|
{
|
2014-07-11 13:50:23 -07:00
|
|
|
return mRecycleBin->GetBuffer(aSize);
|
2012-08-19 12:33:25 -07:00
|
|
|
}
|
|
|
|
|
2012-08-23 10:01:14 -07:00
|
|
|
static void
|
2012-09-04 10:10:06 -07:00
|
|
|
CopyPlane(uint8_t *aDst, const uint8_t *aSrc,
|
2013-12-20 08:46:29 -08:00
|
|
|
const gfx::IntSize &aSize, int32_t aStride, int32_t aSkip)
|
2012-08-23 10:01:14 -07:00
|
|
|
{
|
2012-08-25 20:22:51 -07:00
|
|
|
if (!aSkip) {
|
2012-08-23 10:01:14 -07:00
|
|
|
// Fast path: planar input.
|
|
|
|
memcpy(aDst, aSrc, aSize.height * aStride);
|
|
|
|
} else {
|
|
|
|
int32_t height = aSize.height;
|
|
|
|
int32_t width = aSize.width;
|
|
|
|
for (int y = 0; y < height; ++y) {
|
2012-09-04 10:10:06 -07:00
|
|
|
const uint8_t *src = aSrc;
|
2012-08-23 10:01:14 -07:00
|
|
|
uint8_t *dst = aDst;
|
2012-08-25 20:22:51 -07:00
|
|
|
// Slow path
|
|
|
|
for (int x = 0; x < width; ++x) {
|
|
|
|
*dst++ = *src++;
|
|
|
|
src += aSkip;
|
2012-08-23 10:01:14 -07:00
|
|
|
}
|
2012-09-04 10:10:06 -07:00
|
|
|
aSrc += aStride;
|
|
|
|
aDst += aStride;
|
2012-08-23 10:01:14 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PlanarYCbCrImage::CopyData(const Data& aData)
|
2012-08-19 12:33:25 -07:00
|
|
|
{
|
2012-08-23 10:01:14 -07:00
|
|
|
mData = aData;
|
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
// update buffer size
|
2013-12-10 22:58:51 -08:00
|
|
|
size_t size = mData.mCbCrStride * mData.mCbCrSize.height * 2 +
|
2012-08-23 10:01:14 -07:00
|
|
|
mData.mYStride * mData.mYSize.height;
|
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
// get new buffer
|
2013-12-10 22:58:51 -08:00
|
|
|
mBuffer = AllocateBuffer(size);
|
2012-08-23 10:01:14 -07:00
|
|
|
if (!mBuffer)
|
2012-08-19 12:33:25 -07:00
|
|
|
return;
|
|
|
|
|
2013-12-10 22:58:51 -08:00
|
|
|
// update buffer size
|
|
|
|
mBufferSize = size;
|
|
|
|
|
2012-08-23 10:01:14 -07:00
|
|
|
mData.mYChannel = mBuffer;
|
|
|
|
mData.mCbChannel = mData.mYChannel + mData.mYStride * mData.mYSize.height;
|
|
|
|
mData.mCrChannel = mData.mCbChannel + mData.mCbCrStride * mData.mCbCrSize.height;
|
|
|
|
|
|
|
|
CopyPlane(mData.mYChannel, aData.mYChannel,
|
2012-08-25 20:22:51 -07:00
|
|
|
mData.mYSize, mData.mYStride, mData.mYSkip);
|
2012-08-23 10:01:14 -07:00
|
|
|
CopyPlane(mData.mCbChannel, aData.mCbChannel,
|
2012-08-25 20:22:51 -07:00
|
|
|
mData.mCbCrSize, mData.mCbCrStride, mData.mCbSkip);
|
2012-08-23 10:01:14 -07:00
|
|
|
CopyPlane(mData.mCrChannel, aData.mCrChannel,
|
2012-08-25 20:22:51 -07:00
|
|
|
mData.mCbCrSize, mData.mCbCrStride, mData.mCrSkip);
|
2012-08-23 10:01:14 -07:00
|
|
|
|
|
|
|
mSize = aData.mPicSize;
|
2012-08-19 12:33:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PlanarYCbCrImage::SetData(const Data &aData)
|
|
|
|
{
|
2012-08-23 10:01:14 -07:00
|
|
|
CopyData(aData);
|
2012-08-19 12:33:25 -07:00
|
|
|
}
|
|
|
|
|
2013-09-24 13:45:13 -07:00
|
|
|
gfxImageFormat
|
2013-01-23 15:08:16 -08:00
|
|
|
PlanarYCbCrImage::GetOffscreenFormat()
|
|
|
|
{
|
2014-01-23 10:26:40 -08:00
|
|
|
return mOffscreenFormat == gfxImageFormat::Unknown ?
|
2013-01-23 15:08:16 -08:00
|
|
|
gfxPlatform::GetPlatform()->GetOffscreenFormat() :
|
|
|
|
mOffscreenFormat;
|
|
|
|
}
|
|
|
|
|
2013-03-13 13:11:15 -07:00
|
|
|
void
|
|
|
|
PlanarYCbCrImage::SetDataNoCopy(const Data &aData)
|
|
|
|
{
|
|
|
|
mData = aData;
|
|
|
|
mSize = aData.mPicSize;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t*
|
|
|
|
PlanarYCbCrImage::AllocateAndGetNewBuffer(uint32_t aSize)
|
|
|
|
{
|
|
|
|
// get new buffer
|
2013-12-10 22:58:51 -08:00
|
|
|
mBuffer = AllocateBuffer(aSize);
|
|
|
|
if (mBuffer) {
|
|
|
|
// update buffer size
|
|
|
|
mBufferSize = aSize;
|
|
|
|
}
|
2013-03-13 13:11:15 -07:00
|
|
|
return mBuffer;
|
|
|
|
}
|
|
|
|
|
2015-06-17 07:00:52 -07:00
|
|
|
already_AddRefed<gfx::SourceSurface>
|
2014-01-21 08:49:53 -08:00
|
|
|
PlanarYCbCrImage::GetAsSourceSurface()
|
|
|
|
{
|
|
|
|
if (mSourceSurface) {
|
2015-04-30 12:20:30 -07:00
|
|
|
RefPtr<gfx::SourceSurface> surface(mSourceSurface);
|
|
|
|
return surface.forget();
|
2014-01-21 08:49:53 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
gfx::IntSize size(mSize);
|
|
|
|
gfx::SurfaceFormat format = gfx::ImageFormatToSurfaceFormat(GetOffscreenFormat());
|
|
|
|
gfx::GetYCbCrToRGBDestFormatAndSize(mData, format, size);
|
|
|
|
if (mSize.width > PlanarYCbCrImage::MAX_DIMENSION ||
|
|
|
|
mSize.height > PlanarYCbCrImage::MAX_DIMENSION) {
|
|
|
|
NS_ERROR("Illegal image dest width or height");
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<gfx::DataSourceSurface> surface = gfx::Factory::CreateDataSourceSurface(size, format);
|
2014-08-27 08:57:43 -07:00
|
|
|
if (NS_WARN_IF(!surface)) {
|
2014-06-16 16:47:28 -07:00
|
|
|
return nullptr;
|
|
|
|
}
|
2014-01-21 08:49:53 -08:00
|
|
|
|
2015-06-10 04:01:00 -07:00
|
|
|
DataSourceSurface::ScopedMap mapping(surface, DataSourceSurface::WRITE);
|
|
|
|
if (NS_WARN_IF(!mapping.IsMapped())) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
gfx::ConvertYCbCrToRGB(mData, format, size, mapping.GetData(), mapping.GetStride());
|
2014-01-21 08:49:53 -08:00
|
|
|
|
|
|
|
mSourceSurface = surface;
|
|
|
|
|
|
|
|
return surface.forget();
|
|
|
|
}
|
|
|
|
|
2014-02-16 14:23:39 -08:00
|
|
|
CairoImage::CairoImage()
|
|
|
|
: Image(nullptr, ImageFormat::CAIRO_SURFACE)
|
|
|
|
{}
|
|
|
|
|
|
|
|
CairoImage::~CairoImage()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TextureClient*
|
|
|
|
CairoImage::GetTextureClient(CompositableClient *aClient)
|
|
|
|
{
|
2014-05-06 05:34:19 -07:00
|
|
|
if (!aClient) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-02-16 14:23:39 -08:00
|
|
|
CompositableForwarder* forwarder = aClient->GetForwarder();
|
|
|
|
RefPtr<TextureClient> textureClient = mTextureClients.Get(forwarder->GetSerial());
|
|
|
|
if (textureClient) {
|
|
|
|
return textureClient;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefPtr<SourceSurface> surface = GetAsSourceSurface();
|
|
|
|
MOZ_ASSERT(surface);
|
2014-05-06 05:34:19 -07:00
|
|
|
if (!surface) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-02-16 14:23:39 -08:00
|
|
|
|
2014-11-13 07:53:49 -08:00
|
|
|
|
|
|
|
// XXX windows' TextureClients do not hold ISurfaceAllocator,
|
|
|
|
// recycler does not work on windows.
|
|
|
|
#ifndef XP_WIN
|
|
|
|
|
|
|
|
// XXX only gonk ensure when TextureClient is recycled,
|
|
|
|
// TextureHost is not used by CompositableHost.
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
|
|
RefPtr<TextureClientRecycleAllocator> recycler =
|
|
|
|
aClient->GetTextureClientRecycler();
|
|
|
|
if (recycler) {
|
|
|
|
textureClient =
|
|
|
|
recycler->CreateOrRecycleForDrawing(surface->GetFormat(),
|
|
|
|
surface->GetSize(),
|
|
|
|
gfx::BackendType::NONE,
|
|
|
|
aClient->GetTextureFlags());
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
if (!textureClient) {
|
|
|
|
// gfx::BackendType::NONE means default to content backend
|
|
|
|
textureClient = aClient->CreateTextureClientForDrawing(surface->GetFormat(),
|
|
|
|
surface->GetSize(),
|
|
|
|
gfx::BackendType::NONE,
|
|
|
|
TextureFlags::DEFAULT);
|
|
|
|
}
|
2014-05-06 05:34:19 -07:00
|
|
|
if (!textureClient) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-04-10 01:14:28 -07:00
|
|
|
MOZ_ASSERT(textureClient->CanExposeDrawTarget());
|
2014-07-10 04:45:40 -07:00
|
|
|
if (!textureClient->Lock(OpenMode::OPEN_WRITE_ONLY)) {
|
2014-02-16 14:23:39 -08:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2014-06-11 10:33:37 -07:00
|
|
|
TextureClientAutoUnlock autoUnolck(textureClient);
|
2014-02-16 14:23:39 -08:00
|
|
|
{
|
|
|
|
// We must not keep a reference to the DrawTarget after it has been unlocked.
|
2014-06-11 11:57:58 -07:00
|
|
|
DrawTarget* dt = textureClient->BorrowDrawTarget();
|
2014-06-11 10:33:37 -07:00
|
|
|
if (!dt) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
2014-02-16 14:23:39 -08:00
|
|
|
dt->CopySurface(surface, IntRect(IntPoint(), surface->GetSize()), IntPoint());
|
|
|
|
}
|
|
|
|
|
|
|
|
mTextureClients.Put(forwarder->GetSerial(), textureClient);
|
|
|
|
return textureClient;
|
|
|
|
}
|
|
|
|
|
2015-07-05 20:02:26 -07:00
|
|
|
PImageContainerChild*
|
|
|
|
ImageContainer::GetPImageContainerChild()
|
|
|
|
{
|
|
|
|
return mIPDLChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* static */ void
|
|
|
|
ImageContainer::NotifyComposite(const ImageCompositeNotification& aNotification)
|
|
|
|
{
|
|
|
|
ImageContainerChild* child =
|
|
|
|
static_cast<ImageContainerChild*>(aNotification.imageContainerChild());
|
|
|
|
if (child) {
|
|
|
|
MutexAutoLock lock(child->mLock);
|
|
|
|
if (child->mImageContainer) {
|
|
|
|
child->mImageContainer->NotifyCompositeInternal(aNotification);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-19 12:33:25 -07:00
|
|
|
} // namespace
|
2012-08-19 19:39:10 -07:00
|
|
|
} // namespace
|