mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
a057fcd85b
- Bug 1201329 - Use AlignedStorage2 instead of char[] for IPDL union members. r=billm (420db1710) - Bug 1146214 - Remove unused set fence functions. r=nical (148188894) - Bug 1146214 - Combine FenceHandle and FenceHandleFromChild. r=nical (9d33cdedc) - Bug 1147894 - Remove the redundant OpUpdateTexture IPDL message. r=sotaro (c3b037c92) - Bug 1146214 - Implement fence delivery. Combine ipc messages and remove reply fence delivery message. r=nical (cd115f0db) - Bug 1146214 - Remove the unused code after refactoring. r=nical (2582f1dfa) - Bug 1146214 - Rename some functions after refactoring. r=nical (fd7655c71) - Bug 1150381 - [LayerScope]: Don't showing the same texture in the same frame on LayerScope. r=chiajung (7a5310113) - Bug 1162395 - [LayerScope]: No need to read and send the texture when the same texture id contains in a frame. r=cku (2c67a0994) - Bug 1168015 - Dump source image from graphic buffer directly on B2G. r=kamidphish, r=hshih (108f3dd5a) - Bug 1158575: Support using GDI rendering for opaque surfaces when using cross-process layers. r=jrmuizel (8913ea2ff) - Bug 1155498 - Use FdObj to replace FenceHandle's android fence. r=sotaro (ac0f66f02) - Bug 1155498 - Part 2 - Use new FenceHandle to handle the fence in TextureHost. r=sotaro (8c3cd6427) - Bug 1152370 part 1 - Add android aosp VirtualDisplaySurface r=mwu (795674527) - Bug 1152370 part 2 - Add DisplaySurface r=mwu (f4e7cb123) - Bug 1151936 - Update GLContextEGL's EGLSurface override handling r=jgilbert (a1a72947b) - Bug 1154313 - Move sUsingHwc to gfxPrefs r=mwu,nical (d315f572a) - Bug 1152361 - Ensure outbufAcquireFenceFd is initialized during boot animation. r=mwu (c17f9bc1a) - Bug 1152135 - Split EGLSurface buffer swap and HWC buffer swap r=mwu,nical,jgilbert (2ec0aaccc) - Bug 1148149 - Support Android Presentation API. r=snorp, r=jgilbert (60ae01557) - Bug 1150518 - Remove glClear() on blit composition r=Sushil (24b242a14) - Bug 1152370 part 3 - Use DisplaySurface r=mwu (c531c0b44) - Bug 1157661 - Fix a null-check in CompositorOGL::DrawQuad. r=nical (c00d429d3) - Bug 1113425 part 1 - Fix some bad CSS comment syntax in animation tests; r=mattwoodrow (7abbbb3de) - Bug 1113425 part 2 - Apply async properties when querying the animated transform; r=mattwoodrow (52e778eeb) - Bug 1113425 part 4 - Enable test_deferred_start.html on all platforms; r=mattwoodrow (3884a02a3) - Bug 1113425 part 3 - Make test_deferred_start.html wait an extra frame; r=mattwoodrow (0971c8836) - Bug 1148949 - Apply async properties when querying the animated transform for cross-process compositor parents too; r=mattwoodrow (8bdeafc25) - Bug 1157066. When reading back the OMTA transfrom of a layer don't include transforms from async panning or zooming. r=kats,birtles (43c1bab02) - Bug 1129133 - Clean up GeckoTouchDispatcher so that it's a real singleton. r=kats,mwu (ac97ee5f4) - Bug 1140578 - Remove some redundant code and an unused return value. r=mchang (9d02a9794) - Bug 1140578 - Simplify some code. r=mchang (5a2f95805) - Bug 1140578 - Add a explicit flag to track if we have pending touch moves to process. r=mchang (3255a2ac8) - Bug 1140578 - Prevent resampling moves across non-move touch events. r=mchang (5a2622f6c) - Bug 1146987 - Deal with cases where we get a batch of interleaved move and non-move events on the libui thread before anything is processed, with resampling disabled. r=mchang (462ce355c) - Bug 1149412 - Remove bad assertion. r=mchang (d9d2db4ba) - Bug 1137151: Marked destructor of |GeckoTouchDispatcher| as protected, r=mwu (21fae6af2) - Bug 1138502. Reset vsync unobserve count if a force composite occurs. r=mstange (9682c9e62) - Bug 1148583 - Dispatch touch events before composites. r=kats (cfabb0eef) - Bug 1128690 - Ensure Talos Performance Tests still work with silk enabled. r=mstange (089e87b89) - Bug 1138181 - Be more aggressive in updating plugin geometry in the compositor, avoids filtering out important offset updates that don't involve remote layer tree updates. r=roc (e341636de) - comment coming from Bug 1143249 (2f6c7bdc8) - Bug 1154614 - Don't try to pick up the same non-reentrant lock twice. r=dvander a=RyanVM (c69cba3d9) - Bug 1156981 - Split CompositorParent's scheduling of composition to CompositorScheduler r=mchang (bf87b2ba3) - Bug 1139541 - Make HWC skip opacity=0 layers. r=sotaro (cd6d5114c) - Bug 1149646 - Delete non-uniform vsync interval warning. r=kats (5bc0cd3fa) - Bug 1155498 - Part 3 - Use new FenceHandle to handle the fence in Compositor. r=sotaro (f5c685606) - Bug 1155498 - Part 4 - Use new FenceHandle to handle the fence in TextureClient. r=sotaro (0390d19fd) - Bug 1155498 - Part 5 - Use new FenceHandle to handle Decoder fence. r=sotaro (a99b62351) - Bug 1164513 - Add nullptr check r=milan (41053d048) - Bug 1155495 - Part 1: Remove TextureHostOGL and integrate the platform specific API into TextureHost. r=nical, r=sotaro (9c909e5e2) - Bug 1155495 - Part 2: Remove unnecessary class inheritance and casting. r=nical, r=sotaro (4ce5869ff) - Bug 1133007 - Send the content of a texture only if its was altered since previous transmission. r=kamidphish, r=boris (f78a07160) - Bug 1156456 patch 1 - Reftests comparing a 3-D transformed cube generated by main-thread paths and off-main-thread animations paths. r=birtles (f0f5309d9) - Bug 1156456 patch 2 - Transform the z component just like the x and y. r=birtles (cc36b5b91) - Bug 1156456 patch 3 - Send transform origin and perspective origin to layer in device pixels rather than CSS pixels. r=birtles (94ea8a04a) - Bug 1156456 followup - Also annotate as fuzzy on Mulet, on a CLOSED TREE. (712c97eff) - Bug 1156456 followup - Add a simple reftest for off-main-thread animation of opacity. (eac0fe0e4) - Bug 1157455 patch 1 - Add tests for OMTA transforms in degrees in addition to those in radians. r=birtles (83fb5b7af) - Bug 1157455 patch 2 - Send angles (in CSS transform functions) to the compositor thread with their units rather than sending all such angles in radians. r=birtles (a8b47f5b0) - Bug 1157455 patch 3 - When interpolating angles, preserve units when possible in order to avoid floating point error. r=birtles (ace148e00) - Bug 1157455 followup - fix test_transitions_per_property.html to expect different angle interpolation results, on a CLOSED TREE. (270ef56eb) - Bug 1022080 - Don't force intermediate surfaces when dumping textures, unless explicitly specified. r=nical (0a010b6c8) - Bug 1022080 - Make non-HTML dumping of textures work better. r=nical (304939544)
389 lines
12 KiB
C++
389 lines
12 KiB
C++
/* -*- 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 "ImageClient.h"
|
|
#include <stdint.h> // for uint32_t
|
|
#include "ImageContainer.h" // for Image, PlanarYCbCrImage, etc
|
|
#include "ImageTypes.h" // for ImageFormat::PLANAR_YCBCR, etc
|
|
#include "GLImages.h" // for SurfaceTextureImage::Data, etc
|
|
#include "gfx2DGlue.h" // for ImageFormatToSurfaceFormat
|
|
#include "gfxPlatform.h" // for gfxPlatform
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
|
#include "mozilla/RefPtr.h" // for RefPtr, already_AddRefed
|
|
#include "mozilla/gfx/BaseSize.h" // for BaseSize
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
|
#include "mozilla/gfx/Types.h" // for SurfaceFormat, etc
|
|
#include "mozilla/layers/CompositableClient.h" // for CompositableClient
|
|
#include "mozilla/layers/CompositableForwarder.h"
|
|
#include "mozilla/layers/CompositorTypes.h" // for CompositableType, etc
|
|
#include "mozilla/layers/ISurfaceAllocator.h"
|
|
#include "mozilla/layers/LayersSurfaces.h" // for SurfaceDescriptor, etc
|
|
#include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder
|
|
#include "mozilla/layers/SharedPlanarYCbCrImage.h"
|
|
#include "mozilla/layers/SharedRGBImage.h"
|
|
#include "mozilla/layers/TextureClient.h" // for TextureClient, etc
|
|
#include "mozilla/layers/TextureClientOGL.h" // for SurfaceTextureClient
|
|
#include "mozilla/mozalloc.h" // for operator delete, etc
|
|
#include "nsAutoPtr.h" // for nsRefPtr
|
|
#include "nsCOMPtr.h" // for already_AddRefed
|
|
#include "nsDebug.h" // for NS_WARNING, NS_ASSERTION
|
|
#include "nsISupportsImpl.h" // for Image::Release, etc
|
|
#include "nsRect.h" // for nsIntRect
|
|
#include "mozilla/gfx/2D.h"
|
|
#ifdef MOZ_WIDGET_GONK
|
|
#include "GrallocImages.h"
|
|
#endif
|
|
|
|
namespace mozilla {
|
|
namespace layers {
|
|
|
|
using namespace mozilla::gfx;
|
|
|
|
/* static */ already_AddRefed<ImageClient>
|
|
ImageClient::CreateImageClient(CompositableType aCompositableHostType,
|
|
CompositableForwarder* aForwarder,
|
|
TextureFlags aFlags)
|
|
{
|
|
RefPtr<ImageClient> result = nullptr;
|
|
switch (aCompositableHostType) {
|
|
case CompositableType::IMAGE:
|
|
result = new ImageClientSingle(aForwarder, aFlags, CompositableType::IMAGE);
|
|
break;
|
|
case CompositableType::IMAGE_BRIDGE:
|
|
result = new ImageClientBridge(aForwarder, aFlags);
|
|
break;
|
|
case CompositableType::UNKNOWN:
|
|
result = nullptr;
|
|
break;
|
|
#ifdef MOZ_WIDGET_GONK
|
|
case CompositableType::IMAGE_OVERLAY:
|
|
result = new ImageClientOverlay(aForwarder, aFlags);
|
|
break;
|
|
#endif
|
|
default:
|
|
MOZ_CRASH("unhandled program type");
|
|
}
|
|
|
|
NS_ASSERTION(result, "Failed to create ImageClient");
|
|
|
|
return result.forget();
|
|
}
|
|
|
|
void
|
|
ImageClient::RemoveTexture(TextureClient* aTexture)
|
|
{
|
|
RemoveTextureWithTracker(aTexture, nullptr);
|
|
}
|
|
|
|
void
|
|
ImageClient::RemoveTextureWithTracker(TextureClient* aTexture,
|
|
AsyncTransactionTracker* aAsyncTransactionTracker)
|
|
{
|
|
#ifdef MOZ_WIDGET_GONK
|
|
if (aAsyncTransactionTracker ||
|
|
GetForwarder()->IsImageBridgeChild()) {
|
|
RefPtr<AsyncTransactionTracker> request = aAsyncTransactionTracker;
|
|
if (!request) {
|
|
// Create AsyncTransactionTracker if it is not provided as argument.
|
|
request = new RemoveTextureFromCompositableTracker();
|
|
}
|
|
// Hold TextureClient until the transaction complete to postpone
|
|
// the TextureClient recycle/delete.
|
|
request->SetTextureClient(aTexture);
|
|
GetForwarder()->RemoveTextureFromCompositableAsync(request, this, aTexture);
|
|
return;
|
|
}
|
|
#endif
|
|
|
|
GetForwarder()->RemoveTextureFromCompositable(this, aTexture);
|
|
if (aAsyncTransactionTracker) {
|
|
// Do not need to wait a transaction complete message
|
|
// from the compositor side.
|
|
aAsyncTransactionTracker->NotifyComplete();
|
|
}
|
|
}
|
|
|
|
ImageClientSingle::ImageClientSingle(CompositableForwarder* aFwd,
|
|
TextureFlags aFlags,
|
|
CompositableType aType)
|
|
: ImageClient(aFwd, aFlags, aType)
|
|
{
|
|
}
|
|
|
|
TextureInfo ImageClientSingle::GetTextureInfo() const
|
|
{
|
|
return TextureInfo(CompositableType::IMAGE);
|
|
}
|
|
|
|
already_AddRefed<AsyncTransactionTracker>
|
|
ImageClientSingle::PrepareFlushAllImages()
|
|
{
|
|
return MakeAndAddRef<RemoveTextureFromCompositableTracker>();
|
|
}
|
|
|
|
void
|
|
ImageClientSingle::FlushAllImages(bool aExceptFront,
|
|
AsyncTransactionTracker* aAsyncTransactionTracker)
|
|
{
|
|
if (!aExceptFront && mFrontBuffer) {
|
|
RemoveTextureWithTracker(mFrontBuffer, aAsyncTransactionTracker);
|
|
mFrontBuffer = nullptr;
|
|
} else if(aAsyncTransactionTracker) {
|
|
// already flushed
|
|
aAsyncTransactionTracker->NotifyComplete();
|
|
}
|
|
}
|
|
|
|
bool
|
|
ImageClientSingle::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags)
|
|
{
|
|
AutoLockImage autoLock(aContainer);
|
|
|
|
Image *image = autoLock.GetImage();
|
|
if (!image) {
|
|
return false;
|
|
}
|
|
|
|
// Don't try to update to an invalid image. We return true because the caller
|
|
// would attempt to recreate the ImageClient otherwise, and that isn't going
|
|
// to help.
|
|
if (!image->IsValid()) {
|
|
return true;
|
|
}
|
|
|
|
if (mLastPaintedImageSerial == image->GetSerial()) {
|
|
return true;
|
|
}
|
|
|
|
RefPtr<TextureClient> texture = image->GetTextureClient(this);
|
|
|
|
AutoRemoveTexture autoRemoveTexture(this);
|
|
if (texture != mFrontBuffer) {
|
|
autoRemoveTexture.mTexture = mFrontBuffer;
|
|
mFrontBuffer = nullptr;
|
|
}
|
|
|
|
if (!texture) {
|
|
// Slow path, we should not be hitting it very often and if we do it means
|
|
// we are using an Image class that is not backed by textureClient and we
|
|
// should fix it.
|
|
if (image->GetFormat() == ImageFormat::PLANAR_YCBCR) {
|
|
PlanarYCbCrImage* ycbcr = static_cast<PlanarYCbCrImage*>(image);
|
|
const PlanarYCbCrData* data = ycbcr->GetData();
|
|
if (!data) {
|
|
return false;
|
|
}
|
|
texture = TextureClient::CreateForYCbCr(GetForwarder(),
|
|
data->mYSize, data->mCbCrSize, data->mStereoMode,
|
|
TextureFlags::DEFAULT | mTextureFlags
|
|
);
|
|
if (!texture || !texture->Lock(OpenMode::OPEN_WRITE_ONLY)) {
|
|
return false;
|
|
}
|
|
bool status = texture->AsTextureClientYCbCr()->UpdateYCbCr(*data);
|
|
MOZ_ASSERT(status);
|
|
|
|
texture->Unlock();
|
|
if (!status) {
|
|
return false;
|
|
}
|
|
|
|
} else if (image->GetFormat() == ImageFormat::SURFACE_TEXTURE ||
|
|
image->GetFormat() == ImageFormat::EGLIMAGE) {
|
|
gfx::IntSize size = image->GetSize();
|
|
|
|
if (image->GetFormat() == ImageFormat::EGLIMAGE) {
|
|
EGLImageImage* typedImage = static_cast<EGLImageImage*>(image);
|
|
texture = new EGLImageTextureClient(GetForwarder(),
|
|
mTextureFlags,
|
|
typedImage,
|
|
size);
|
|
#ifdef MOZ_WIDGET_ANDROID
|
|
} else if (image->GetFormat() == ImageFormat::SURFACE_TEXTURE) {
|
|
SurfaceTextureImage* typedImage = static_cast<SurfaceTextureImage*>(image);
|
|
const SurfaceTextureImage::Data* data = typedImage->GetData();
|
|
texture = new SurfaceTextureClient(GetForwarder(), mTextureFlags,
|
|
data->mSurfTex, size,
|
|
data->mOriginPos);
|
|
#endif
|
|
} else {
|
|
MOZ_ASSERT(false, "Bad ImageFormat.");
|
|
}
|
|
} else {
|
|
RefPtr<gfx::SourceSurface> surface = image->GetAsSourceSurface();
|
|
MOZ_ASSERT(surface);
|
|
texture = CreateTextureClientForDrawing(surface->GetFormat(), image->GetSize(),
|
|
gfx::BackendType::NONE, mTextureFlags);
|
|
if (!texture) {
|
|
return false;
|
|
}
|
|
|
|
MOZ_ASSERT(texture->CanExposeDrawTarget());
|
|
|
|
if (!texture->Lock(OpenMode::OPEN_WRITE_ONLY)) {
|
|
return false;
|
|
}
|
|
|
|
{
|
|
// We must not keep a reference to the DrawTarget after it has been unlocked.
|
|
DrawTarget* dt = texture->BorrowDrawTarget();
|
|
if (!dt) {
|
|
gfxWarning() << "ImageClientSingle::UpdateImage failed in BorrowDrawTarget";
|
|
return false;
|
|
}
|
|
MOZ_ASSERT(surface.get());
|
|
dt->CopySurface(surface, IntRect(IntPoint(), surface->GetSize()), IntPoint());
|
|
}
|
|
|
|
texture->Unlock();
|
|
}
|
|
}
|
|
if (!texture || !AddTextureClient(texture)) {
|
|
return false;
|
|
}
|
|
|
|
mFrontBuffer = texture;
|
|
GetForwarder()->UseTexture(this, texture);
|
|
|
|
UpdatePictureRect(image->GetPictureRect());
|
|
|
|
mLastPaintedImageSerial = image->GetSerial();
|
|
aContainer->NotifyPaintedImage(image);
|
|
|
|
texture->SyncWithObject(GetForwarder()->GetSyncObject());
|
|
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
ImageClientSingle::AddTextureClient(TextureClient* aTexture)
|
|
{
|
|
MOZ_ASSERT((mTextureFlags & aTexture->GetFlags()) == mTextureFlags);
|
|
return CompositableClient::AddTextureClient(aTexture);
|
|
}
|
|
|
|
void
|
|
ImageClientSingle::OnDetach()
|
|
{
|
|
mFrontBuffer = nullptr;
|
|
}
|
|
|
|
ImageClient::ImageClient(CompositableForwarder* aFwd, TextureFlags aFlags,
|
|
CompositableType aType)
|
|
: CompositableClient(aFwd, aFlags)
|
|
, mType(aType)
|
|
, mLastPaintedImageSerial(0)
|
|
{}
|
|
|
|
void
|
|
ImageClient::UpdatePictureRect(nsIntRect aRect)
|
|
{
|
|
if (mPictureRect == aRect) {
|
|
return;
|
|
}
|
|
mPictureRect = aRect;
|
|
MOZ_ASSERT(mForwarder);
|
|
GetForwarder()->UpdatePictureRect(this, aRect);
|
|
}
|
|
|
|
ImageClientBridge::ImageClientBridge(CompositableForwarder* aFwd,
|
|
TextureFlags aFlags)
|
|
: ImageClient(aFwd, aFlags, CompositableType::IMAGE_BRIDGE)
|
|
, mAsyncContainerID(0)
|
|
, mLayer(nullptr)
|
|
{
|
|
}
|
|
|
|
bool
|
|
ImageClientBridge::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags)
|
|
{
|
|
if (!GetForwarder() || !mLayer) {
|
|
return false;
|
|
}
|
|
if (mAsyncContainerID == aContainer->GetAsyncContainerID()) {
|
|
return true;
|
|
}
|
|
mAsyncContainerID = aContainer->GetAsyncContainerID();
|
|
static_cast<ShadowLayerForwarder*>(GetForwarder())->AttachAsyncCompositable(mAsyncContainerID, mLayer);
|
|
AutoLockImage autoLock(aContainer);
|
|
aContainer->NotifyPaintedImage(autoLock.GetImage());
|
|
Updated();
|
|
return true;
|
|
}
|
|
|
|
already_AddRefed<Image>
|
|
ImageClientSingle::CreateImage(ImageFormat aFormat)
|
|
{
|
|
nsRefPtr<Image> img;
|
|
switch (aFormat) {
|
|
case ImageFormat::PLANAR_YCBCR:
|
|
img = new SharedPlanarYCbCrImage(this);
|
|
return img.forget();
|
|
case ImageFormat::SHARED_RGB:
|
|
img = new SharedRGBImage(this);
|
|
return img.forget();
|
|
#ifdef MOZ_WIDGET_GONK
|
|
case ImageFormat::GRALLOC_PLANAR_YCBCR:
|
|
img = new GrallocImage();
|
|
return img.forget();
|
|
#endif
|
|
default:
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
#ifdef MOZ_WIDGET_GONK
|
|
ImageClientOverlay::ImageClientOverlay(CompositableForwarder* aFwd,
|
|
TextureFlags aFlags)
|
|
: ImageClient(aFwd, aFlags, CompositableType::IMAGE_OVERLAY)
|
|
{
|
|
}
|
|
|
|
bool
|
|
ImageClientOverlay::UpdateImage(ImageContainer* aContainer, uint32_t aContentFlags)
|
|
{
|
|
AutoLockImage autoLock(aContainer);
|
|
|
|
Image *image = autoLock.GetImage();
|
|
if (!image) {
|
|
return false;
|
|
}
|
|
|
|
if (mLastPaintedImageSerial == image->GetSerial()) {
|
|
return true;
|
|
}
|
|
|
|
AutoRemoveTexture autoRemoveTexture(this);
|
|
if (image->GetFormat() == ImageFormat::OVERLAY_IMAGE) {
|
|
OverlayImage* overlayImage = static_cast<OverlayImage*>(image);
|
|
uint32_t overlayId = overlayImage->GetOverlayId();
|
|
gfx::IntSize size = overlayImage->GetSize();
|
|
|
|
OverlaySource source;
|
|
source.handle() = OverlayHandle(overlayId);
|
|
source.size() = size;
|
|
GetForwarder()->UseOverlaySource(this, source);
|
|
}
|
|
UpdatePictureRect(image->GetPictureRect());
|
|
return true;
|
|
}
|
|
|
|
already_AddRefed<Image>
|
|
ImageClientOverlay::CreateImage(ImageFormat aFormat)
|
|
{
|
|
nsRefPtr<Image> img;
|
|
switch (aFormat) {
|
|
case ImageFormat::OVERLAY_IMAGE:
|
|
img = new OverlayImage();
|
|
return img.forget();
|
|
default:
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
#endif
|
|
}
|
|
}
|