Bug 1071825 - Remove simple tiling code. r=mattwoodrow

This commit is contained in:
Nicolas Silva 2014-09-23 17:44:48 -04:00
parent 31eea3ce68
commit da4fea2925
9 changed files with 5 additions and 808 deletions

View File

@ -20,7 +20,6 @@
#include "mozilla/layers/PLayerChild.h" // for PLayerChild
#include "mozilla/layers/LayerTransactionChild.h"
#include "mozilla/layers/TextureClientPool.h" // for TextureClientPool
#include "mozilla/layers/SimpleTextureClientPool.h" // for SimpleTextureClientPool
#include "ClientReadbackLayer.h" // for ClientReadbackLayer
#include "nsAString.h"
#include "nsIWidget.h" // for nsIWidget
@ -647,23 +646,6 @@ ClientLayerManager::GetTexturePool(SurfaceFormat aFormat)
return mTexturePools.LastElement();
}
SimpleTextureClientPool*
ClientLayerManager::GetSimpleTileTexturePool(SurfaceFormat aFormat)
{
int index = (int) aFormat;
mSimpleTilePools.EnsureLengthAtLeast(index+1);
if (mSimpleTilePools[index].get() == nullptr) {
mSimpleTilePools[index] = new SimpleTextureClientPool(aFormat, IntSize(gfxPrefs::LayersTileWidth(),
gfxPrefs::LayersTileHeight()),
gfxPrefs::LayersTileMaxPoolSize(),
gfxPrefs::LayersTileShrinkPoolTimeout(),
mForwarder);
}
return mSimpleTilePools[index];
}
void
ClientLayerManager::ReturnTextureClientDeferred(TextureClient& aClient) {
GetTexturePool(aClient.GetFormat())->ReturnTextureClientDeferred(&aClient);

View File

@ -37,7 +37,6 @@ class CompositorChild;
class ImageLayer;
class PLayerChild;
class TextureClientPool;
class SimpleTextureClientPool;
class ClientLayerManager MOZ_FINAL : public LayerManager
{
@ -124,7 +123,6 @@ public:
virtual void SetIsFirstPaint() MOZ_OVERRIDE;
TextureClientPool* GetTexturePool(gfx::SurfaceFormat aFormat);
SimpleTextureClientPool* GetSimpleTileTexturePool(gfx::SurfaceFormat aFormat);
/// Utility methods for managing texture clients.
void ReturnTextureClientDeferred(TextureClient& aClient);
@ -337,9 +335,6 @@ private:
nsAutoTArray<dom::OverfillCallback*,0> mOverfillCallbacks;
mozilla::TimeStamp mTransactionStart;
// indexed by gfx::SurfaceFormat
nsTArray<RefPtr<SimpleTextureClientPool> > mSimpleTilePools;
nsRefPtr<MemoryPressureObserver> mMemoryPressureObserver;
};

View File

@ -5,7 +5,6 @@
#include "ClientThebesLayer.h"
#include "ClientTiledThebesLayer.h" // for ClientTiledThebesLayer
#include "SimpleTiledContentClient.h"
#include <stdint.h> // for uint32_t
#include "GeckoProfiler.h" // for PROFILER_LABEL
#include "client/ClientLayerManager.h" // for ClientLayerManager, etc
@ -167,21 +166,11 @@ ClientLayerManager::CreateThebesLayerWithHint(ThebesLayerCreationHint aHint)
(AsShadowForwarder()->GetCompositorBackendType() == LayersBackend::LAYERS_OPENGL ||
AsShadowForwarder()->GetCompositorBackendType() == LayersBackend::LAYERS_D3D9 ||
AsShadowForwarder()->GetCompositorBackendType() == LayersBackend::LAYERS_D3D11)) {
if (gfxPrefs::LayersUseSimpleTiles()) {
nsRefPtr<SimpleClientTiledThebesLayer> layer =
new SimpleClientTiledThebesLayer(this, aHint);
CREATE_SHADOW(Thebes);
return layer.forget();
} else {
nsRefPtr<ClientTiledThebesLayer> layer =
new ClientTiledThebesLayer(this, aHint);
CREATE_SHADOW(Thebes);
return layer.forget();
}
} else
{
nsRefPtr<ClientThebesLayer> layer =
new ClientThebesLayer(this, aHint);
nsRefPtr<ClientTiledThebesLayer> layer = new ClientTiledThebesLayer(this, aHint);
CREATE_SHADOW(Thebes);
return layer.forget();
} else {
nsRefPtr<ClientThebesLayer> layer = new ClientThebesLayer(this, aHint);
CREATE_SHADOW(Thebes);
return layer.forget();
}

View File

@ -1,145 +0,0 @@
/* -*- 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 "SimpleTextureClientPool.h"
#include "CompositableClient.h"
#include "mozilla/layers/ISurfaceAllocator.h"
#include "gfxPrefs.h"
#include "nsComponentManagerUtils.h"
#if 0
#define RECYCLE_LOG(...) printf_stderr(__VA_ARGS__)
#else
#define RECYCLE_LOG(...) do { } while (0)
#endif
namespace mozilla {
namespace layers {
using gfx::SurfaceFormat;
/* static */ void
SimpleTextureClientPool::ShrinkCallback(nsITimer *aTimer, void *aClosure)
{
static_cast<SimpleTextureClientPool*>(aClosure)->ShrinkToMinimumSize();
}
/* static */ void
SimpleTextureClientPool::RecycleCallback(TextureClient* aClient, void* aClosure)
{
SimpleTextureClientPool* pool =
static_cast<SimpleTextureClientPool*>(aClosure);
aClient->ClearRecycleCallback();
pool->ReturnTextureClient(aClient);
}
/* static */ void
SimpleTextureClientPool::WaitForCompositorRecycleCallback(TextureClient* aClient, void* aClosure)
{
// This will grab a reference that will be released once the compositor
// acknowledges the remote recycle. Once it is received the object
// will be fully recycled.
aClient->WaitForCompositorRecycle();
aClient->SetRecycleCallback(SimpleTextureClientPool::RecycleCallback, aClosure);
}
SimpleTextureClientPool::SimpleTextureClientPool(gfx::SurfaceFormat aFormat, gfx::IntSize aSize,
uint32_t aMaxTextureClients,
uint32_t aShrinkTimeoutMsec,
ISurfaceAllocator *aAllocator)
: mFormat(aFormat)
, mSize(aSize)
, mMaxTextureClients(aMaxTextureClients)
, mShrinkTimeoutMsec(aShrinkTimeoutMsec)
, mSurfaceAllocator(aAllocator)
{
mTimer = do_CreateInstance("@mozilla.org/timer;1");
}
TemporaryRef<TextureClient>
SimpleTextureClientPool::GetTextureClient(bool aAutoRecycle)
{
// Try to fetch a client from the pool
RefPtr<TextureClient> textureClient;
if (mAvailableTextureClients.size()) {
textureClient = mAvailableTextureClients.top();
mAvailableTextureClients.pop();
RECYCLE_LOG("%s Skip allocate (%i left), returning %p\n", (mFormat == SurfaceFormat::B8G8R8A8?"poolA":"poolX"), mAvailableTextureClients.size(), textureClient.get());
} else {
// No unused clients in the pool, create one
if (gfxPrefs::ForceShmemTiles()) {
textureClient = TextureClient::CreateForRawBufferAccess(mSurfaceAllocator,
mFormat, mSize, gfx::BackendType::NONE,
TextureFlags::IMMEDIATE_UPLOAD | TextureFlags::RECYCLE, ALLOC_DEFAULT);
} else {
textureClient = TextureClient::CreateForDrawing(mSurfaceAllocator,
mFormat, mSize, gfx::BackendType::NONE, TextureFlags::DEFAULT | TextureFlags::RECYCLE);
}
if (!textureClient) {
NS_WARNING("Failed to allocate a TextureClient!");
return nullptr;
}
RECYCLE_LOG("%s Must allocate (0 left), returning %p\n", (mFormat == SurfaceFormat::B8G8R8A8?"poolA":"poolX"), textureClient.get());
}
if (aAutoRecycle) {
mOutstandingTextureClients.push_back(textureClient);
textureClient->SetRecycleCallback(SimpleTextureClientPool::WaitForCompositorRecycleCallback, this);
}
return textureClient;
}
void
SimpleTextureClientPool::ReturnTextureClient(TextureClient *aClient)
{
if (!aClient) {
return;
}
// If we haven't hit our max cached client limit, add this one
if (mAvailableTextureClients.size() < mMaxTextureClients) {
mAvailableTextureClients.push(aClient);
RECYCLE_LOG("%s recycled %p (have %d)\n", (mFormat == SurfaceFormat::B8G8R8A8?"poolA":"poolX"), aClient, mAvailableTextureClients.size());
} else {
RECYCLE_LOG("%s did not recycle %p (have %d)\n", (mFormat == SurfaceFormat::B8G8R8A8?"poolA":"poolX"), aClient, mAvailableTextureClients.size());
}
// Kick off the pool shrinking timer if there are still more unused texture
// clients than our desired minimum cache size.
if (mAvailableTextureClients.size() > sMinCacheSize) {
mTimer->InitWithFuncCallback(SimpleTextureClientPool::ShrinkCallback, this, mShrinkTimeoutMsec,
nsITimer::TYPE_ONE_SHOT);
}
mOutstandingTextureClients.remove(aClient);
}
void
SimpleTextureClientPool::ShrinkToMinimumSize()
{
RECYCLE_LOG("%s ShrinkToMinimumSize, removing %d clients", (mFormat == SurfaceFormat::B8G8R8A8?"poolA":"poolX"), mAvailableTextureClients.size() > sMinCacheSize ? mAvailableTextureClients.size() - sMinCacheSize : 0);
mTimer->Cancel();
while (mAvailableTextureClients.size() > sMinCacheSize) {
mAvailableTextureClients.pop();
}
}
void
SimpleTextureClientPool::Clear()
{
while (!mAvailableTextureClients.empty()) {
mAvailableTextureClients.pop();
}
}
}
}

View File

@ -1,96 +0,0 @@
/* -*- 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/. */
#ifndef MOZILLA_GFX_SIMPLETEXTURECLIENTPOOL_H
#define MOZILLA_GFX_SIMPLETEXTURECLIENTPOOL_H
#include "mozilla/gfx/Types.h"
#include "mozilla/gfx/Point.h"
#include "mozilla/RefPtr.h"
#include "TextureClient.h"
#include "nsITimer.h"
#include <stack>
#include <list>
namespace mozilla {
namespace layers {
class ISurfaceAllocator;
class SimpleTextureClientPool
{
~SimpleTextureClientPool()
{
for (auto it = mOutstandingTextureClients.begin(); it != mOutstandingTextureClients.end(); ++it) {
(*it)->ClearRecycleCallback();
}
}
public:
NS_INLINE_DECL_REFCOUNTING(SimpleTextureClientPool)
SimpleTextureClientPool(gfx::SurfaceFormat aFormat, gfx::IntSize aSize,
uint32_t aMaxTextureClients,
uint32_t aShrinkTimeoutMsec,
ISurfaceAllocator *aAllocator);
/**
* If a TextureClient is AutoRecycled, when the last reference is
* released this object will be automatically return to the pool as
* soon as the compositor informs us it is done with it.
*/
TemporaryRef<TextureClient> GetTextureClient(bool aAutoRecycle = false);
TemporaryRef<TextureClient> GetTextureClientWithAutoRecycle() { return GetTextureClient(true); }
void ReturnTextureClient(TextureClient *aClient);
void ShrinkToMinimumSize();
void Clear();
private:
// The minimum size of the pool (the number of tiles that will be kept after
// shrinking).
static const uint32_t sMinCacheSize = 16;
static void ShrinkCallback(nsITimer *aTimer, void *aClosure);
static void RecycleCallback(TextureClient* aClient, void* aClosure);
static void WaitForCompositorRecycleCallback(TextureClient* aClient, void* aClosure);
gfx::SurfaceFormat mFormat;
gfx::IntSize mSize;
// This is the number of cached texture clients we don't want to exceed, even
// temporarily (pre-shrink)
uint32_t mMaxTextureClients;
// The time in milliseconds before the pool will be shrunk to the minimum
// size after returning a client.
uint32_t mShrinkTimeoutMsec;
// We use a std::stack and make sure to use it the following way:
// new (available to be used) elements are push()'d to the front
// requests are served from the front via pop()
// -- the thinking is that recently-used elements are most likely
// to be in any data cache, so we can get some wins there
// -- the converse though is that if there is some GPU locking going on
// the most recently used elements may also have the most contention;
// if we see that, then we should use push_back() to add new elements
// when we shrink this list, we use pop(), but should use pop_back() to
// nuke the oldest.
// We may need to switch to a std::deque
// On b2g gonk, std::queue might be a better choice.
// On ICS, fence wait happens implicitly before drawing.
// Since JB, fence wait happens explicitly when fetching a client from the pool.
std::stack<RefPtr<TextureClient> > mAvailableTextureClients;
std::list<RefPtr<TextureClient> > mOutstandingTextureClients;
nsRefPtr<nsITimer> mTimer;
RefPtr<ISurfaceAllocator> mSurfaceAllocator;
};
}
}
#endif /* MOZILLA_GFX_SIMPLETEXTURECLIENTPOOL_H */

View File

@ -1,327 +0,0 @@
/* -*- 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/SimpleTiledContentClient.h"
#include <math.h> // for ceil, ceilf, floor
#include "ClientTiledThebesLayer.h" // for ClientTiledThebesLayer
#include "GeckoProfiler.h" // for PROFILER_LABEL
#include "Units.h" // for ScreenIntRect, CSSPoint, etc
#include "UnitTransforms.h" // for TransformTo
#include "ClientLayerManager.h" // for ClientLayerManager
#include "CompositorChild.h" // for CompositorChild
#include "gfxContext.h" // for gfxContext, etc
#include "gfxPlatform.h" // for gfxPlatform
#include "gfxPrefs.h" // for gfxPrefs::LayersTileWidth/Height
#include "gfxRect.h" // for gfxRect
#include "mozilla/Attributes.h" // for MOZ_THIS_IN_INITIALIZER_LIST
#include "mozilla/MathAlgorithms.h" // for Abs
#include "mozilla/gfx/Point.h" // for IntSize
#include "mozilla/gfx/Rect.h" // for Rect
#include "mozilla/layers/CompositableForwarder.h"
#include "mozilla/layers/ShadowLayers.h" // for ShadowLayerForwarder
#include "SimpleTextureClientPool.h"
#include "nsDebug.h" // for NS_ASSERTION
#include "nsISupportsImpl.h" // for gfxContext::AddRef, etc
#include "nsSize.h" // for nsIntSize
#include "gfxReusableSharedImageSurfaceWrapper.h"
#include "nsMathUtils.h" // for NS_roundf
#include "gfx2DGlue.h"
#define ALOG(...) __android_log_print(ANDROID_LOG_INFO, "SimpleTiles", __VA_ARGS__)
namespace mozilla {
namespace layers {
using namespace mozilla::gfx;
void
SimpleTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion,
const nsIntRegion& aPaintRegion,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData)
{
mCallback = aCallback;
mCallbackData = aCallbackData;
#ifdef GFX_TILEDLAYER_PREF_WARNINGS
long start = PR_IntervalNow();
#endif
// If this region is empty XMost() - 1 will give us a negative value.
NS_ASSERTION(!aPaintRegion.GetBounds().IsEmpty(), "Empty paint region\n");
PROFILER_LABEL("SimpleTiledLayerBuffer", "PaintThebesUpdate",
js::ProfileEntry::Category::GRAPHICS);
Update(aNewValidRegion, aPaintRegion);
#ifdef GFX_TILEDLAYER_PREF_WARNINGS
if (PR_IntervalNow() - start > 10) {
const nsIntRect bounds = aPaintRegion.GetBounds();
printf_stderr("Time to tile [%i, %i, %i, %i] -> %i\n", bounds.x, bounds.y, bounds.width, bounds.height, PR_IntervalNow() - start);
}
#endif
mLastPaintOpaque = mThebesLayer->CanUseOpaqueSurface();
mCallback = nullptr;
mCallbackData = nullptr;
}
SimpleTiledLayerTile
SimpleTiledLayerBuffer::ValidateTile(SimpleTiledLayerTile aTile,
const nsIntPoint& aTileOrigin,
const nsIntRegion& aDirtyRegion)
{
PROFILER_LABEL("SimpleTiledLayerBuffer", "ValidateTile",
js::ProfileEntry::Category::GRAPHICS);
static gfx::IntSize kTileSize(gfxPrefs::LayersTileWidth(), gfxPrefs::LayersTileHeight());
gfx::SurfaceFormat tileFormat = gfxPlatform::GetPlatform()->Optimal2DFormatForContent(GetContentType());
// if this is true, we're using a separate buffer to do our drawing first
bool doBufferedDrawing = true;
bool fullPaint = false;
RefPtr<TextureClient> textureClient = mManager->GetSimpleTileTexturePool(tileFormat)->GetTextureClientWithAutoRecycle();
if (!textureClient) {
NS_WARNING("TextureClient allocation failed");
return SimpleTiledLayerTile();
}
if (!textureClient->Lock(OpenMode::OPEN_READ_WRITE)) {
NS_WARNING("TextureClient lock failed");
return SimpleTiledLayerTile();
}
if (!textureClient->CanExposeDrawTarget()) {
doBufferedDrawing = false;
}
RefPtr<DrawTarget> drawTarget;
unsigned char *bufferData = nullptr;
// these are set/updated differently based on doBufferedDrawing
nsIntRect drawBounds;
nsIntRegion drawRegion;
nsIntRegion invalidateRegion;
RefPtr<DrawTarget> srcDT;
uint8_t* srcData = nullptr;
int32_t srcStride = 0;
gfx::IntSize srcSize;
gfx::SurfaceFormat srcFormat = gfx::SurfaceFormat::UNKNOWN;
if (doBufferedDrawing) {
// try to directly access the pixels of the TextureClient
srcDT = textureClient->BorrowDrawTarget();
if (srcDT->LockBits(&srcData, &srcSize, &srcStride, &srcFormat)) {
if (!aTile.mCachedBuffer) {
aTile.mCachedBuffer = SharedBuffer::Create(srcStride * srcSize.height);
fullPaint = true;
}
bufferData = (unsigned char*) aTile.mCachedBuffer->Data();
drawTarget = gfxPlatform::GetPlatform()->CreateDrawTargetForData(bufferData,
kTileSize,
srcStride,
tileFormat);
if (fullPaint) {
drawBounds = nsIntRect(aTileOrigin.x, aTileOrigin.y, GetScaledTileSize().width, GetScaledTileSize().height);
drawRegion = nsIntRegion(drawBounds);
} else {
drawBounds = aDirtyRegion.GetBounds();
drawRegion = nsIntRegion(drawBounds);
if (GetContentType() == gfxContentType::COLOR_ALPHA)
drawTarget->ClearRect(Rect(drawBounds.x - aTileOrigin.x, drawBounds.y - aTileOrigin.y,
drawBounds.width, drawBounds.height));
}
} else {
// failed to obtain the client as an ImageSurface
doBufferedDrawing = false;
}
}
// this might get set above if we couldn't extract out a buffer
if (!doBufferedDrawing) {
drawTarget = textureClient->BorrowDrawTarget();
fullPaint = true;
drawBounds = nsIntRect(aTileOrigin.x, aTileOrigin.y, GetScaledTileSize().width, GetScaledTileSize().height);
drawRegion = nsIntRegion(drawBounds);
if (GetContentType() == gfxContentType::COLOR_ALPHA)
drawTarget->ClearRect(Rect(0, 0, drawBounds.width, drawBounds.height));
}
// do the drawing
RefPtr<gfxContext> ctxt = new gfxContext(drawTarget);
ctxt->SetMatrix(
ctxt->CurrentMatrix().Scale(mResolution, mResolution).
Translate(-aTileOrigin.x, -aTileOrigin.y));
mCallback(mThebesLayer, ctxt,
drawRegion,
fullPaint ? DrawRegionClip::CLIP_NONE : DrawRegionClip::DRAW_SNAPPED, // XXX DRAW or DRAW_SNAPPED?
invalidateRegion,
mCallbackData);
ctxt = nullptr;
if (doBufferedDrawing) {
memcpy(srcData, bufferData, srcSize.height * srcStride);
bufferData = nullptr;
srcDT->ReleaseBits(srcData);
srcDT = nullptr;
}
drawTarget = nullptr;
textureClient->Unlock();
if (!mCompositableClient->AddTextureClient(textureClient)) {
NS_WARNING("Failed to add tile TextureClient [simple]");
return SimpleTiledLayerTile();
}
// aTile.mCachedBuffer was set earlier
aTile.mTileBuffer = textureClient;
aTile.mManager = mManager;
aTile.mLastUpdate = TimeStamp::Now();
return aTile;
}
SurfaceDescriptorTiles
SimpleTiledLayerBuffer::GetSurfaceDescriptorTiles()
{
InfallibleTArray<TileDescriptor> tiles;
for (size_t i = 0; i < mRetainedTiles.Length(); i++) {
tiles.AppendElement(mRetainedTiles[i].GetTileDescriptor());
}
return SurfaceDescriptorTiles(mValidRegion, mPaintedRegion,
tiles, mRetainedWidth, mRetainedHeight,
mResolution, mFrameResolution.scale);
}
bool
SimpleTiledLayerBuffer::HasFormatChanged() const
{
return mThebesLayer->CanUseOpaqueSurface() != mLastPaintOpaque;
}
gfxContentType
SimpleTiledLayerBuffer::GetContentType() const
{
if (mThebesLayer->CanUseOpaqueSurface())
return gfxContentType::COLOR;
return gfxContentType::COLOR_ALPHA;
}
SimpleTiledContentClient::SimpleTiledContentClient(SimpleClientTiledThebesLayer* aThebesLayer,
ClientLayerManager* aManager)
: CompositableClient(aManager->AsShadowForwarder())
, mTiledBuffer(aThebesLayer, MOZ_THIS_IN_INITIALIZER_LIST(), aManager)
{
MOZ_COUNT_CTOR(SimpleTiledContentClient);
}
SimpleTiledContentClient::~SimpleTiledContentClient()
{
MOZ_COUNT_DTOR(SimpleTiledContentClient);
mTiledBuffer.Release();
}
void
SimpleTiledContentClient::UseTiledLayerBuffer()
{
mForwarder->UseTiledLayerBuffer(this, mTiledBuffer.GetSurfaceDescriptorTiles());
mTiledBuffer.ClearPaintedRegion();
}
SimpleClientTiledThebesLayer::SimpleClientTiledThebesLayer(ClientLayerManager* aManager,
ClientLayerManager::ThebesLayerCreationHint aCreationHint)
: ThebesLayer(aManager,
static_cast<ClientLayer*>(MOZ_THIS_IN_INITIALIZER_LIST()),
aCreationHint)
, mContentClient()
{
MOZ_COUNT_CTOR(SimpleClientTiledThebesLayer);
}
SimpleClientTiledThebesLayer::~SimpleClientTiledThebesLayer()
{
MOZ_COUNT_DTOR(SimpleClientTiledThebesLayer);
}
void
SimpleClientTiledThebesLayer::FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
{
aAttrs = ThebesLayerAttributes(GetValidRegion());
}
void
SimpleClientTiledThebesLayer::RenderLayer()
{
LayerManager::DrawThebesLayerCallback callback =
ClientManager()->GetThebesLayerCallback();
void *data = ClientManager()->GetThebesLayerCallbackData();
if (!callback) {
ClientManager()->SetTransactionIncomplete();
return;
}
// First time? Create a content client.
if (!mContentClient) {
mContentClient = new SimpleTiledContentClient(this, ClientManager());
mContentClient->Connect();
ClientManager()->AsShadowForwarder()->Attach(mContentClient, this);
MOZ_ASSERT(mContentClient->GetForwarder());
}
// If the format changed, nothing is valid
if (mContentClient->mTiledBuffer.HasFormatChanged()) {
mValidRegion = nsIntRegion();
}
nsIntRegion invalidRegion = mVisibleRegion;
invalidRegion.Sub(invalidRegion, mValidRegion);
if (invalidRegion.IsEmpty()) {
return;
}
// Only paint the mask layer on the first transaction.
if (GetMaskLayer() && !ClientManager()->IsRepeatTransaction()) {
ToClientLayer(GetMaskLayer())->RenderLayer();
}
// SimpleTiledContentClient doesn't support progressive updates or the low
// precision buffer yet.
MOZ_ASSERT(!gfxPrefs::UseProgressiveTilePainting() &&
!gfxPrefs::UseLowPrecisionBuffer());
mValidRegion = mVisibleRegion;
NS_ASSERTION(!ClientManager()->IsRepeatTransaction(), "Didn't paint our mask layer");
mContentClient->mTiledBuffer.PaintThebes(mValidRegion, invalidRegion,
callback, data);
ClientManager()->Hold(this);
mContentClient->UseTiledLayerBuffer();
}
}
}

View File

@ -1,196 +0,0 @@
/* -*- 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/. */
#ifndef MOZILLA_GFX_SIMPLETILEDCONTENTCLIENT_H
#define MOZILLA_GFX_SIMPLETILEDCONTENTCLIENT_H
// We include this header here so that we don't need to
// duplicate BasicTiledLayerPaintData
#include "TiledContentClient.h"
#include "SharedBuffer.h"
namespace mozilla {
namespace layers {
class ClientTiledThebesLayer;
struct SimpleTiledLayerTile;
class SimpleTiledLayerBuffer;
class SimpleClientTiledThebesLayer;
class SimpleTiledLayerBuffer;
#define GFX_SIMP_TILEDLAYER_DEBUG_OVERLAY
struct SimpleTiledLayerTile
{
RefPtr<TextureClient> mTileBuffer;
RefPtr<ClientLayerManager> mManager;
nsRefPtr<SharedBuffer> mCachedBuffer;
TimeStamp mLastUpdate;
SimpleTiledLayerTile() { }
SimpleTiledLayerTile(ClientLayerManager *aManager, TextureClient *aBuffer)
: mTileBuffer(aBuffer)
, mManager(aManager)
{ }
bool operator== (const SimpleTiledLayerTile& o) const
{
return mTileBuffer == o.mTileBuffer;
}
bool operator!= (const SimpleTiledLayerTile& o) const
{
return mTileBuffer != o.mTileBuffer;
}
void SetLayerManager(ClientLayerManager *aManager)
{
mManager = aManager;
}
bool IsPlaceholderTile()
{
return mTileBuffer == nullptr;
}
TileDescriptor GetTileDescriptor()
{
if (mTileBuffer)
return TexturedTileDescriptor(nullptr, mTileBuffer->GetIPDLActor(), null_t(), 0);
NS_NOTREACHED("Unhandled SimpleTiledLayerTile type");
return PlaceholderTileDescriptor();
}
void Release()
{
mTileBuffer = nullptr;
mCachedBuffer = nullptr;
}
};
class SimpleTiledLayerBuffer
: public TiledLayerBuffer<SimpleTiledLayerBuffer, SimpleTiledLayerTile>
{
friend class TiledLayerBuffer<SimpleTiledLayerBuffer, SimpleTiledLayerTile>;
public:
SimpleTiledLayerBuffer(SimpleClientTiledThebesLayer* aThebesLayer,
CompositableClient* aCompositableClient,
ClientLayerManager* aManager)
: mThebesLayer(aThebesLayer)
, mCompositableClient(aCompositableClient)
, mManager(aManager)
, mLastPaintOpaque(false)
{}
SimpleTiledLayerBuffer()
: mLastPaintOpaque(false)
{}
void PaintThebes(const nsIntRegion& aNewValidRegion,
const nsIntRegion& aPaintRegion,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData);
SurfaceDescriptorTiles GetSurfaceDescriptorTiles();
void Release() {
for (size_t i = 0; i < mRetainedTiles.Length(); i++) {
mRetainedTiles[i].Release();
}
}
const CSSToParentLayerScale& GetFrameResolution() const { return mFrameResolution; }
void SetFrameResolution(const CSSToParentLayerScale& aResolution) { mFrameResolution = aResolution; }
bool HasFormatChanged() const;
private:
SimpleClientTiledThebesLayer* mThebesLayer;
CompositableClient* mCompositableClient;
ClientLayerManager* mManager;
LayerManager::DrawThebesLayerCallback mCallback;
void* mCallbackData;
CSSToParentLayerScale mFrameResolution;
bool mLastPaintOpaque;
gfxContentType GetContentType() const;
SimpleTiledLayerTile ValidateTile(SimpleTiledLayerTile aTile,
const nsIntPoint& aTileOrigin,
const nsIntRegion& aDirtyRect);
SimpleTiledLayerTile GetPlaceholderTile() const { return SimpleTiledLayerTile(); }
void ReleaseTile(SimpleTiledLayerTile aTile) { aTile.Release(); }
void SwapTiles(SimpleTiledLayerTile& aTileA, SimpleTiledLayerTile& aTileB) { std::swap(aTileA, aTileB); }
void PostValidate(const nsIntRegion& aPaintRegion) {}
void UnlockTile(SimpleTiledLayerTile aTile) {}
};
class SimpleTiledContentClient : public CompositableClient
{
friend class SimpleClientTiledThebesLayer;
public:
SimpleTiledContentClient(SimpleClientTiledThebesLayer* aThebesLayer,
ClientLayerManager* aManager);
private:
~SimpleTiledContentClient();
virtual TextureInfo GetTextureInfo() const MOZ_OVERRIDE
{
return TextureInfo(CompositableType::BUFFER_SIMPLE_TILED);
}
void UseTiledLayerBuffer();
private:
SimpleTiledLayerBuffer mTiledBuffer;
};
class SimpleClientTiledThebesLayer : public ThebesLayer,
public ClientLayer
{
typedef ThebesLayer Base;
public:
explicit SimpleClientTiledThebesLayer(ClientLayerManager* const aManager,
ClientLayerManager::ThebesLayerCreationHint aCreationHint = LayerManager::NONE);
protected:
~SimpleClientTiledThebesLayer();
public:
// Thebes Layer
virtual Layer* AsLayer() { return this; }
virtual void InvalidateRegion(const nsIntRegion& aRegion) {
mInvalidRegion.Or(mInvalidRegion, aRegion);
mValidRegion.Sub(mValidRegion, aRegion);
}
// Shadow methods
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs);
virtual ShadowableLayer* AsShadowableLayer() { return this; }
virtual void Disconnect() { ClientLayer::Disconnect(); }
virtual void RenderLayer();
protected:
ClientLayerManager* ClientManager() { return static_cast<ClientLayerManager*>(mManager); }
RefPtr<SimpleTiledContentClient> mContentClient;
};
} // mozilla
} // layers
#endif

View File

@ -128,8 +128,6 @@ EXPORTS.mozilla.layers += [
'client/CompositableClient.h',
'client/ContentClient.h',
'client/ImageClient.h',
'client/SimpleTextureClientPool.h',
'client/SimpleTiledContentClient.h',
'client/TextureClient.h',
'client/TextureClientPool.h',
'client/TiledContentClient.h',
@ -272,8 +270,6 @@ UNIFIED_SOURCES += [
'client/CompositableClient.cpp',
'client/ContentClient.cpp',
'client/ImageClient.cpp',
'client/SimpleTextureClientPool.cpp',
'client/SimpleTiledContentClient.cpp',
'client/TextureClient.cpp',
'client/TextureClientPool.cpp',
'client/TiledContentClient.cpp',

View File

@ -246,7 +246,6 @@ private:
DECL_GFX_PREF(Once, "layers.enable-tiles", LayersTilesEnabled, bool, false);
DECL_GFX_PREF(Once, "layers.force-enable-tiles", LayersTilesForceEnabled, bool, false);
DECL_GFX_PREF(Once, "layers.simple-tiles", LayersUseSimpleTiles, bool, false);
DECL_GFX_PREF(Once, "layers.force-per-tile-drawing", PerTileDrawing, bool, false);
DECL_GFX_PREF(Once, "layers.tiled-drawtarget.enabled", TiledDrawTargetEnabled, bool, false);
// We allow for configurable and rectangular tile size to avoid wasting memory on devices whose