mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 13:23:07 +00:00
ca19b65a80
- Bug 1250873 - Rename HasInternalBuffer into HasIntermediateBuffer in layers. r=sotaro (578235105f) - Bug 1256045 - Add a null-check in BufferTextureHost::EnsureWrappingTextureSource. r=jnicol (943c73559d) - Bug 1251726 - Check if Compositor is set r=nical (550d5b0164) - Bug 1251427 - Require a full update when a TextureHost switches from a TextureSource to another. r=sotaro (bc59ac4cd7) - Bug 1256693 - ISurfaceAllocator cleanup. r=sotaro (098e824d4d) - Bug 1257939 - initialize BGRX alpha channel to opaque when clearing and ignore uninitialized alpha in texture clients. r=mchang (73d778496f) - more of reapply Bug 1200595 - Consolidate the TextureClient's destruction logic (74517415ed) - Bug 1256693 - Refer to ClientIPCAllocator instead of ISurfaceAllocator where it makes sense. r=sotaro (e81f2dd923) - Bug 1236112 - Block on d3d9 video frames to complete before returning them from the decoder. r=cpearce (25114bb3c4) - Bug 1196409 - Disable D3D11-DXVA for resolutions not supported in hardware. r=jya (3007b1ebff) - Bug 1196411 - Disable DXVA on 60fps 1080p videos for AMD cards that can't decode quick enough. r=jya (9f8f67e12b) - Bug 1200775 - Check intel specific h264 decoder when checking for DXVA support. r=cpearce (e7bcbb10be) - Bug 1257013 - Part 1: Use readback to synchronize d3d9 video. r=cpearce,Bas (d247a9bed6) - Bug 1257013 - Part 2: Use readback to synchronize d3d11 video. r=cpearce,Bas (43883c1607) - missing bit of Bug 1206568: P2 (58de11b22f) - Bug 1239093 - Add pref to allow overriding of hardcoded DXVA blacklist. r=jrmuizel (dfd5e57c2f) - Bug 1217185: To allow for sandboxing, use null HWNDs when creating the D3D device for video decoding. r=mattwoodrow (0c96e66a47) - Bug 1200775 - Followup to fix typo and indent issues (b1d1c76788) - bits of Bug 1207245 - part 3 (52a1939b74) - Bug 1224199 - Don't make the TextureClient wait for compositor recycle if the GLContext is shutting down - r=nical (9a0081f217) - more of Bug 1200595 (047201fd60) - Bug 1253094, part 2 - Stop using DebugOnly for class/struct members in gfx/. r=Bas (bab6569366)
225 lines
7.1 KiB
C++
225 lines
7.1 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 "mozilla/layers/SingleTiledContentClient.h"
|
|
|
|
#include "ClientTiledPaintedLayer.h"
|
|
|
|
namespace mozilla {
|
|
namespace layers {
|
|
|
|
|
|
SingleTiledContentClient::SingleTiledContentClient(ClientTiledPaintedLayer* aPaintedLayer,
|
|
ClientLayerManager* aManager)
|
|
: TiledContentClient(aManager, "Single")
|
|
{
|
|
MOZ_COUNT_CTOR(SingleTiledContentClient);
|
|
|
|
mTiledBuffer = new ClientSingleTiledLayerBuffer(aPaintedLayer, this, aManager);
|
|
}
|
|
|
|
void
|
|
SingleTiledContentClient::ClearCachedResources()
|
|
{
|
|
CompositableClient::ClearCachedResources();
|
|
mTiledBuffer->DiscardBuffers();
|
|
}
|
|
|
|
void
|
|
SingleTiledContentClient::UpdatedBuffer(TiledBufferType aType)
|
|
{
|
|
// Take a ReadLock on behalf of the TiledContentHost. This
|
|
// reference will be adopted when the descriptor is opened in
|
|
// TiledLayerBufferComposite.
|
|
mTiledBuffer->ReadLock();
|
|
|
|
mForwarder->UseTiledLayerBuffer(this, mTiledBuffer->GetSurfaceDescriptorTiles());
|
|
mTiledBuffer->ClearPaintedRegion();
|
|
}
|
|
|
|
/* static */ bool
|
|
SingleTiledContentClient::ClientSupportsLayerSize(const gfx::IntSize& aSize, ClientLayerManager* aManager)
|
|
{
|
|
int32_t maxTextureSize = aManager->GetMaxTextureSize();
|
|
return aSize.width <= maxTextureSize && aSize.height <= maxTextureSize;
|
|
}
|
|
|
|
bool
|
|
SingleTiledContentClient::SupportsLayerSize(const gfx::IntSize& aSize, ClientLayerManager* aManager) const
|
|
{
|
|
return ClientSupportsLayerSize(aSize, aManager);
|
|
}
|
|
|
|
ClientSingleTiledLayerBuffer::ClientSingleTiledLayerBuffer(ClientTiledPaintedLayer* aPaintedLayer,
|
|
CompositableClient* aCompositableClient,
|
|
ClientLayerManager* aManager)
|
|
: ClientTiledLayerBuffer(aPaintedLayer, aCompositableClient)
|
|
, mManager(aManager)
|
|
, mFormat(gfx::SurfaceFormat::UNKNOWN)
|
|
{
|
|
}
|
|
|
|
void
|
|
ClientSingleTiledLayerBuffer::ReadLock() {
|
|
if (!mTile.IsPlaceholderTile()) {
|
|
mTile.ReadLock();
|
|
}
|
|
}
|
|
|
|
void
|
|
ClientSingleTiledLayerBuffer::ReleaseTiles()
|
|
{
|
|
if (!mTile.IsPlaceholderTile()) {
|
|
mTile.DiscardBuffers();
|
|
}
|
|
mTile.SetTextureAllocator(nullptr);
|
|
}
|
|
|
|
void
|
|
ClientSingleTiledLayerBuffer::DiscardBuffers()
|
|
{
|
|
if (!mTile.IsPlaceholderTile()) {
|
|
mTile.DiscardFrontBuffer();
|
|
mTile.DiscardBackBuffer();
|
|
}
|
|
}
|
|
|
|
SurfaceDescriptorTiles
|
|
ClientSingleTiledLayerBuffer::GetSurfaceDescriptorTiles()
|
|
{
|
|
InfallibleTArray<TileDescriptor> tiles;
|
|
|
|
TileDescriptor tileDesc = mTile.GetTileDescriptor();
|
|
tiles.AppendElement(tileDesc);
|
|
mTile.mUpdateRect = gfx::IntRect();
|
|
|
|
return SurfaceDescriptorTiles(mValidRegion,
|
|
tiles,
|
|
mTilingOrigin,
|
|
mSize,
|
|
0, 0, 1, 1,
|
|
1.0,
|
|
mFrameResolution.xScale,
|
|
mFrameResolution.yScale);
|
|
}
|
|
|
|
already_AddRefed<TextureClient>
|
|
ClientSingleTiledLayerBuffer::GetTextureClient()
|
|
{
|
|
MOZ_ASSERT(mFormat != gfx::SurfaceFormat::UNKNOWN);
|
|
return mCompositableClient->CreateTextureClientForDrawing(
|
|
gfx::ImageFormatToSurfaceFormat(mFormat), mSize, BackendSelector::Content,
|
|
TextureFlags::DISALLOW_BIGIMAGE | TextureFlags::IMMEDIATE_UPLOAD);
|
|
}
|
|
|
|
void
|
|
ClientSingleTiledLayerBuffer::PaintThebes(const nsIntRegion& aNewValidRegion,
|
|
const nsIntRegion& aPaintRegion,
|
|
const nsIntRegion& aDirtyRegion,
|
|
LayerManager::DrawPaintedLayerCallback aCallback,
|
|
void* aCallbackData)
|
|
{
|
|
// Compare layer valid region size to current backbuffer size, discard if not matching.
|
|
gfx::IntSize size = aNewValidRegion.GetBounds().Size();
|
|
gfx::IntPoint origin = aNewValidRegion.GetBounds().TopLeft();
|
|
nsIntRegion paintRegion = aPaintRegion;
|
|
if (mSize != size ||
|
|
mTilingOrigin != origin) {
|
|
ResetPaintedAndValidState();
|
|
mSize = size;
|
|
mTilingOrigin = origin;
|
|
paintRegion = aNewValidRegion;
|
|
}
|
|
|
|
SurfaceMode mode;
|
|
gfxContentType content = GetContentType(&mode);
|
|
mFormat = gfxPlatform::GetPlatform()->OptimalFormatForContent(content);
|
|
|
|
if (mTile.IsPlaceholderTile()) {
|
|
mTile.SetLayerManager(mManager);
|
|
mTile.SetTextureAllocator(this);
|
|
}
|
|
mTile.SetCompositableClient(mCompositableClient);
|
|
|
|
// The dirty region relative to the top-left of the tile.
|
|
nsIntRegion tileDirtyRegion = paintRegion.MovedBy(-mTilingOrigin);
|
|
|
|
nsIntRegion extraPainted;
|
|
RefPtr<TextureClient> backBufferOnWhite;
|
|
RefPtr<TextureClient> backBuffer =
|
|
mTile.GetBackBuffer(tileDirtyRegion,
|
|
content, mode,
|
|
extraPainted,
|
|
&backBufferOnWhite);
|
|
|
|
mTile.mUpdateRect = tileDirtyRegion.GetBounds().Union(extraPainted.GetBounds());
|
|
|
|
extraPainted.MoveBy(mTilingOrigin);
|
|
extraPainted.And(extraPainted, aNewValidRegion);
|
|
mPaintedRegion.OrWith(paintRegion);
|
|
mPaintedRegion.OrWith(extraPainted);
|
|
|
|
if (!backBuffer) {
|
|
return;
|
|
}
|
|
|
|
RefPtr<gfx::DrawTarget> dt = backBuffer->BorrowDrawTarget();
|
|
RefPtr<gfx::DrawTarget> dtOnWhite;
|
|
if (backBufferOnWhite) {
|
|
dtOnWhite = backBufferOnWhite->BorrowDrawTarget();
|
|
}
|
|
|
|
if (mode != SurfaceMode::SURFACE_OPAQUE) {
|
|
for (auto iter = tileDirtyRegion.RectIter(); !iter.Done(); iter.Next()) {
|
|
const gfx::IntRect& rect = iter.Get();
|
|
if (dtOnWhite) {
|
|
dt->FillRect(gfx::Rect(rect.x, rect.y, rect.width, rect.height),
|
|
gfx::ColorPattern(gfx::Color(0.0, 0.0, 0.0, 1.0)));
|
|
dtOnWhite->FillRect(gfx::Rect(rect.x, rect.y, rect.width, rect.height),
|
|
gfx::ColorPattern(gfx::Color(1.0, 1.0, 1.0, 1.0)));
|
|
} else {
|
|
dt->ClearRect(gfx::Rect(rect.x, rect.y, rect.width, rect.height));
|
|
}
|
|
}
|
|
}
|
|
|
|
if (dtOnWhite) {
|
|
dt = gfx::Factory::CreateDualDrawTarget(dt, dtOnWhite);
|
|
dtOnWhite = nullptr;
|
|
}
|
|
|
|
{
|
|
RefPtr<gfxContext> ctx = new gfxContext(dt);
|
|
ctx->SetMatrix(ctx->CurrentMatrix().Translate(-mTilingOrigin.x, -mTilingOrigin.y));
|
|
|
|
aCallback(mPaintedLayer, ctx, paintRegion, paintRegion, DrawRegionClip::DRAW, nsIntRegion(), aCallbackData);
|
|
}
|
|
|
|
// Mark the area we just drew into the back buffer as invalid in the front buffer as they're
|
|
// now out of sync.
|
|
mTile.mInvalidFront.OrWith(tileDirtyRegion);
|
|
|
|
// The new buffer is now validated, remove the dirty region from it.
|
|
mTile.mInvalidBack.SubOut(tileDirtyRegion);
|
|
|
|
dt = nullptr;
|
|
|
|
mTile.Flip();
|
|
UnlockTile(mTile);
|
|
|
|
if (backBuffer->HasIntermediateBuffer()) {
|
|
// If our new buffer has an internal buffer, we don't want to keep another
|
|
// TextureClient around unnecessarily, so discard the back-buffer.
|
|
mTile.DiscardBackBuffer();
|
|
}
|
|
|
|
mValidRegion = aNewValidRegion;
|
|
mLastPaintSurfaceMode = mode;
|
|
mLastPaintContentType = content;
|
|
}
|
|
|
|
} // namespace layers
|
|
} // namespace mozilla
|