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 13:20:52 +04: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/ContentHost.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "LayersLogging.h" // for AppendToString
|
|
|
|
#include "gfx2DGlue.h" // for ContentForFormat
|
2013-12-20 20:46:28 +04:00
|
|
|
#include "mozilla/gfx/Point.h" // for IntSize
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
|
|
|
|
#include "mozilla/gfx/BaseRect.h" // for BaseRect
|
|
|
|
#include "mozilla/layers/Compositor.h" // for Compositor
|
|
|
|
#include "mozilla/layers/Effects.h" // for TexturedEffect, Effect, etc
|
2013-09-06 19:41:00 +04:00
|
|
|
#include "mozilla/layers/LayersMessages.h" // for ThebesBufferData
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "nsAString.h"
|
|
|
|
#include "nsPrintfCString.h" // for nsPrintfCString
|
|
|
|
#include "nsString.h" // for nsAutoCString
|
2014-04-02 10:45:02 +04:00
|
|
|
#include "mozilla/layers/TextureHostOGL.h" // for TextureHostOGL
|
2013-08-12 03:17:23 +04: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 13:20:52 +04:00
|
|
|
namespace mozilla {
|
|
|
|
using namespace gfx;
|
2013-08-12 03:17:23 +04: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 13:20:52 +04:00
|
|
|
namespace layers {
|
|
|
|
|
2013-11-28 01:16:35 +04:00
|
|
|
ContentHostBase::ContentHostBase(const TextureInfo& aTextureInfo)
|
2013-11-28 01:16:34 +04:00
|
|
|
: ContentHost(aTextureInfo)
|
|
|
|
, mInitialised(false)
|
|
|
|
{}
|
|
|
|
|
2013-11-28 01:16:35 +04:00
|
|
|
ContentHostBase::~ContentHostBase()
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-03-22 06:32:55 +03:00
|
|
|
ContentHostTexture::Composite(Compositor* aCompositor,
|
|
|
|
LayerComposite* aLayer,
|
2015-07-06 06:02:26 +03:00
|
|
|
EffectChain& aEffectChain,
|
2014-10-16 21:08:32 +04:00
|
|
|
float aOpacity,
|
|
|
|
const gfx::Matrix4x4& aTransform,
|
2016-05-25 19:01:18 +03:00
|
|
|
const SamplingFilter aSamplingFilter,
|
2016-05-13 23:15:17 +03:00
|
|
|
const IntRect& aClipRect,
|
2016-12-07 02:39:01 +03:00
|
|
|
const nsIntRegion* aVisibleRegion,
|
|
|
|
const Maybe<gfx::Polygon>& aGeometry)
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
|
|
|
NS_ASSERTION(aVisibleRegion, "Requires a visible region");
|
|
|
|
|
2014-06-22 21:06:00 +04:00
|
|
|
AutoLockCompositableHost lock(this);
|
2014-04-02 10:45:02 +04:00
|
|
|
if (lock.Failed()) {
|
2013-12-19 20:20:51 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-10-16 21:08:32 +04:00
|
|
|
if (!mTextureHost->BindTextureSource(mTextureSource)) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
MOZ_ASSERT(mTextureSource.get());
|
2013-12-05 22:39:22 +04:00
|
|
|
|
2014-10-16 21:08:32 +04:00
|
|
|
if (!mTextureHostOnWhite) {
|
|
|
|
mTextureSourceOnWhite = nullptr;
|
|
|
|
}
|
|
|
|
if (mTextureHostOnWhite && !mTextureHostOnWhite->BindTextureSource(mTextureSourceOnWhite)) {
|
2013-12-05 22:39:22 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<TexturedEffect> effect = CreateTexturedEffect(mTextureSource.get(),
|
2014-10-16 21:08:32 +04:00
|
|
|
mTextureSourceOnWhite.get(),
|
2017-02-14 23:29:39 +03:00
|
|
|
aSamplingFilter, true);
|
2014-01-07 20:20:11 +04:00
|
|
|
if (!effect) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-12-05 22:39:22 +04:00
|
|
|
aEffectChain.mPrimaryEffect = effect;
|
|
|
|
|
|
|
|
nsIntRegion tmpRegion;
|
|
|
|
const nsIntRegion* renderRegion;
|
2014-11-29 02:42:20 +03:00
|
|
|
#ifndef MOZ_IGNORE_PAINT_WILL_RESAMPLE
|
2013-12-05 22:39:22 +04:00
|
|
|
if (PaintWillResample()) {
|
|
|
|
// If we're resampling, then the texture image will contain exactly the
|
|
|
|
// entire visible region's bounds, and we should draw it all in one quad
|
|
|
|
// to avoid unexpected aliasing.
|
|
|
|
tmpRegion = aVisibleRegion->GetBounds();
|
|
|
|
renderRegion = &tmpRegion;
|
|
|
|
} else {
|
|
|
|
renderRegion = aVisibleRegion;
|
|
|
|
}
|
2014-11-29 02:42:20 +03:00
|
|
|
#else
|
|
|
|
renderRegion = aVisibleRegion;
|
|
|
|
#endif
|
2013-12-05 22:39:22 +04:00
|
|
|
|
|
|
|
nsIntRegion region(*renderRegion);
|
|
|
|
nsIntPoint origin = GetOriginOffset();
|
|
|
|
// translate into TexImage space, buffer origin might not be at texture (0,0)
|
|
|
|
region.MoveBy(-origin);
|
|
|
|
|
|
|
|
// Figure out the intersecting draw region
|
2014-10-16 21:08:32 +04:00
|
|
|
gfx::IntSize texSize = mTextureSource->GetSize();
|
2015-05-07 12:07:42 +03:00
|
|
|
IntRect textureRect = IntRect(0, 0, texSize.width, texSize.height);
|
2013-12-05 22:39:22 +04:00
|
|
|
textureRect.MoveBy(region.GetBounds().TopLeft());
|
|
|
|
nsIntRegion subregion;
|
|
|
|
subregion.And(region, textureRect);
|
|
|
|
if (subregion.IsEmpty()) {
|
|
|
|
// Region is empty, nothing to draw
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIntRegion screenRects;
|
|
|
|
nsIntRegion regionRects;
|
|
|
|
|
|
|
|
// Collect texture/screen coordinates for drawing
|
2016-01-19 04:20:58 +03:00
|
|
|
for (auto iter = subregion.RectIter(); !iter.Done(); iter.Next()) {
|
|
|
|
IntRect regionRect = iter.Get();
|
|
|
|
IntRect screenRect = iter.Get();
|
2013-12-05 22:39:22 +04:00
|
|
|
screenRect.MoveBy(origin);
|
|
|
|
|
|
|
|
screenRects.Or(screenRects, screenRect);
|
|
|
|
regionRects.Or(regionRects, regionRect);
|
|
|
|
}
|
|
|
|
|
2014-10-16 21:08:32 +04:00
|
|
|
BigImageIterator* bigImgIter = mTextureSource->AsBigImageIterator();
|
2014-04-28 15:27:25 +04:00
|
|
|
BigImageIterator* iterOnWhite = nullptr;
|
|
|
|
if (bigImgIter) {
|
|
|
|
bigImgIter->BeginBigImageIteration();
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
|
2014-10-16 21:08:32 +04:00
|
|
|
if (mTextureSourceOnWhite) {
|
|
|
|
iterOnWhite = mTextureSourceOnWhite->AsBigImageIterator();
|
2014-04-28 15:27:25 +04:00
|
|
|
MOZ_ASSERT(!bigImgIter || bigImgIter->GetTileCount() == iterOnWhite->GetTileCount(),
|
2013-12-05 22:39:22 +04:00
|
|
|
"Tile count mismatch on component alpha texture");
|
|
|
|
if (iterOnWhite) {
|
2014-04-28 15:27:25 +04:00
|
|
|
iterOnWhite->BeginBigImageIteration();
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-28 15:27:25 +04:00
|
|
|
bool usingTiles = (bigImgIter && bigImgIter->GetTileCount() > 1);
|
2013-12-05 22:39:22 +04:00
|
|
|
do {
|
2015-12-03 08:46:00 +03:00
|
|
|
if (iterOnWhite && bigImgIter) {
|
2014-04-28 15:27:25 +04:00
|
|
|
MOZ_ASSERT(iterOnWhite->GetTileRect() == bigImgIter->GetTileRect(),
|
2013-12-05 22:39:22 +04:00
|
|
|
"component alpha textures should be the same size.");
|
|
|
|
}
|
|
|
|
|
2015-05-07 12:07:42 +03:00
|
|
|
IntRect texRect = bigImgIter ? bigImgIter->GetTileRect()
|
|
|
|
: IntRect(0, 0,
|
2013-12-05 22:39:22 +04:00
|
|
|
texSize.width,
|
|
|
|
texSize.height);
|
|
|
|
|
|
|
|
// Draw texture. If we're using tiles, we do repeating manually, as texture
|
|
|
|
// repeat would cause each individual tile to repeat instead of the
|
|
|
|
// compound texture as a whole. This involves drawing at most 4 sections,
|
|
|
|
// 2 for each axis that has texture repeat.
|
|
|
|
for (int y = 0; y < (usingTiles ? 2 : 1); y++) {
|
|
|
|
for (int x = 0; x < (usingTiles ? 2 : 1); x++) {
|
2015-05-07 12:07:42 +03:00
|
|
|
IntRect currentTileRect(texRect);
|
2013-12-05 22:39:22 +04:00
|
|
|
currentTileRect.MoveBy(x * texSize.width, y * texSize.height);
|
|
|
|
|
2016-01-19 04:20:58 +03:00
|
|
|
for (auto screenIter = screenRects.RectIter(),
|
|
|
|
regionIter = regionRects.RectIter();
|
|
|
|
!screenIter.Done() && !regionIter.Done();
|
|
|
|
screenIter.Next(), regionIter.Next()) {
|
|
|
|
const IntRect& screenRect = screenIter.Get();
|
|
|
|
const IntRect& regionRect = regionIter.Get();
|
|
|
|
IntRect tileScreenRect(screenRect);
|
|
|
|
IntRect tileRegionRect(regionRect);
|
2013-12-05 22:39:22 +04:00
|
|
|
|
|
|
|
// When we're using tiles, find the intersection between the tile
|
|
|
|
// rect and this region rect. Tiling is then handled by the
|
|
|
|
// outer for-loops and modifying the tile rect.
|
|
|
|
if (usingTiles) {
|
|
|
|
tileScreenRect.MoveBy(-origin);
|
|
|
|
tileScreenRect = tileScreenRect.Intersect(currentTileRect);
|
|
|
|
tileScreenRect.MoveBy(origin);
|
|
|
|
|
|
|
|
if (tileScreenRect.IsEmpty())
|
|
|
|
continue;
|
|
|
|
|
2016-01-19 04:20:58 +03:00
|
|
|
tileRegionRect = regionRect.Intersect(currentTileRect);
|
2013-12-05 22:39:22 +04:00
|
|
|
tileRegionRect.MoveBy(-currentTileRect.TopLeft());
|
|
|
|
}
|
|
|
|
gfx::Rect rect(tileScreenRect.x, tileScreenRect.y,
|
|
|
|
tileScreenRect.width, tileScreenRect.height);
|
|
|
|
|
|
|
|
effect->mTextureCoords = Rect(Float(tileRegionRect.x) / texRect.width,
|
|
|
|
Float(tileRegionRect.y) / texRect.height,
|
|
|
|
Float(tileRegionRect.width) / texRect.width,
|
|
|
|
Float(tileRegionRect.height) / texRect.height);
|
2016-12-07 02:39:01 +03:00
|
|
|
|
2017-03-22 06:32:55 +03:00
|
|
|
aCompositor->DrawGeometry(rect, aClipRect, aEffectChain,
|
|
|
|
aOpacity, aTransform, aGeometry);
|
2016-12-07 02:39:01 +03:00
|
|
|
|
2013-12-05 22:39:22 +04:00
|
|
|
if (usingTiles) {
|
2014-04-26 06:34:06 +04:00
|
|
|
DiagnosticFlags diagnostics = DiagnosticFlags::CONTENT | DiagnosticFlags::BIGIMAGE;
|
|
|
|
if (iterOnWhite) {
|
|
|
|
diagnostics |= DiagnosticFlags::COMPONENT_ALPHA;
|
|
|
|
}
|
2017-03-22 06:32:55 +03:00
|
|
|
aCompositor->DrawDiagnostics(diagnostics, rect, aClipRect,
|
|
|
|
aTransform, mFlashCounter);
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (iterOnWhite) {
|
|
|
|
iterOnWhite->NextTile();
|
|
|
|
}
|
2014-04-28 15:27:25 +04:00
|
|
|
} while (usingTiles && bigImgIter->NextTile());
|
2013-12-05 22:39:22 +04:00
|
|
|
|
2014-04-28 15:27:25 +04:00
|
|
|
if (bigImgIter) {
|
|
|
|
bigImgIter->EndBigImageIteration();
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
if (iterOnWhite) {
|
2014-04-28 15:27:25 +04:00
|
|
|
iterOnWhite->EndBigImageIteration();
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
|
2014-04-26 06:34:06 +04:00
|
|
|
DiagnosticFlags diagnostics = DiagnosticFlags::CONTENT;
|
|
|
|
if (iterOnWhite) {
|
|
|
|
diagnostics |= DiagnosticFlags::COMPONENT_ALPHA;
|
|
|
|
}
|
2017-03-22 06:32:55 +03:00
|
|
|
aCompositor->DrawDiagnostics(diagnostics, nsIntRegion(mBufferRect), aClipRect,
|
|
|
|
aTransform, mFlashCounter);
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-05-04 13:59:02 +03:00
|
|
|
ContentHostTexture::UseTextureHost(const nsTArray<TimedTexture>& aTextures)
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
2015-05-04 13:59:02 +03:00
|
|
|
ContentHostBase::UseTextureHost(aTextures);
|
|
|
|
MOZ_ASSERT(aTextures.Length() == 1);
|
|
|
|
const TimedTexture& t = aTextures[0];
|
|
|
|
MOZ_ASSERT(t.mPictureRect.IsEqualInterior(
|
|
|
|
nsIntRect(nsIntPoint(0, 0), nsIntSize(t.mTexture->GetSize()))),
|
2015-07-04 01:52:42 +03:00
|
|
|
"Only default picture rect supported");
|
2015-10-25 18:00:59 +03:00
|
|
|
|
|
|
|
if (t.mTexture != mTextureHost) {
|
|
|
|
mReceivedNewHost = true;
|
|
|
|
}
|
|
|
|
|
2015-05-04 13:59:02 +03:00
|
|
|
mTextureHost = t.mTexture;
|
2014-02-06 15:28:29 +04:00
|
|
|
mTextureHostOnWhite = nullptr;
|
2014-10-16 21:08:32 +04:00
|
|
|
mTextureSourceOnWhite = nullptr;
|
|
|
|
if (mTextureHost) {
|
|
|
|
mTextureHost->PrepareTextureSource(mTextureSource);
|
|
|
|
}
|
2014-02-06 15:28:29 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-04-02 10:45:02 +04:00
|
|
|
ContentHostTexture::UseComponentAlphaTextures(TextureHost* aTextureOnBlack,
|
|
|
|
TextureHost* aTextureOnWhite)
|
2014-02-06 15:28:29 +04:00
|
|
|
{
|
2014-04-02 10:45:02 +04:00
|
|
|
ContentHostBase::UseComponentAlphaTextures(aTextureOnBlack, aTextureOnWhite);
|
2014-02-06 15:28:29 +04:00
|
|
|
mTextureHost = aTextureOnBlack;
|
|
|
|
mTextureHostOnWhite = aTextureOnWhite;
|
2014-10-16 21:08:32 +04:00
|
|
|
if (mTextureHost) {
|
|
|
|
mTextureHost->PrepareTextureSource(mTextureSource);
|
|
|
|
}
|
|
|
|
if (mTextureHostOnWhite) {
|
|
|
|
mTextureHostOnWhite->PrepareTextureSource(mTextureSourceOnWhite);
|
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-03-22 06:32:56 +03:00
|
|
|
ContentHostTexture::SetTextureSourceProvider(TextureSourceProvider* aProvider)
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
2017-03-22 06:32:56 +03:00
|
|
|
ContentHostBase::SetTextureSourceProvider(aProvider);
|
2013-12-05 22:39:22 +04:00
|
|
|
if (mTextureHost) {
|
2017-03-22 06:32:56 +03:00
|
|
|
mTextureHost->SetTextureSourceProvider(aProvider);
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
if (mTextureHostOnWhite) {
|
2017-03-22 06:32:56 +03:00
|
|
|
mTextureHostOnWhite->SetTextureSourceProvider(aProvider);
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-06-20 02:36:25 +04:00
|
|
|
ContentHostTexture::Dump(std::stringstream& aStream,
|
2014-04-02 10:45:02 +04:00
|
|
|
const char* aPrefix,
|
|
|
|
bool aDumpHtml)
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
2014-12-17 02:39:43 +03:00
|
|
|
#ifdef MOZ_DUMP_PAINTING
|
2015-05-12 16:16:54 +03:00
|
|
|
if (aDumpHtml) {
|
|
|
|
aStream << "<ul>";
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
if (mTextureHost) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << aPrefix;
|
2015-05-12 16:16:54 +03:00
|
|
|
if (aDumpHtml) {
|
|
|
|
aStream << "<li> <a href=";
|
|
|
|
} else {
|
|
|
|
aStream << "Front buffer: ";
|
|
|
|
}
|
2014-06-20 02:36:25 +04:00
|
|
|
DumpTextureHost(aStream, mTextureHost);
|
2015-05-12 16:16:54 +03:00
|
|
|
if (aDumpHtml) {
|
|
|
|
aStream << "> Front buffer </a></li> ";
|
|
|
|
} else {
|
|
|
|
aStream << "\n";
|
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
if (mTextureHostOnWhite) {
|
2015-05-12 16:16:54 +03:00
|
|
|
aStream << aPrefix;
|
|
|
|
if (aDumpHtml) {
|
|
|
|
aStream << "<li> <a href=";
|
|
|
|
} else {
|
|
|
|
aStream << "Front buffer on white: ";
|
|
|
|
}
|
2014-06-20 02:36:25 +04:00
|
|
|
DumpTextureHost(aStream, mTextureHostOnWhite);
|
2015-05-12 16:16:54 +03:00
|
|
|
if (aDumpHtml) {
|
|
|
|
aStream << "> Front buffer on white </a> </li> ";
|
|
|
|
} else {
|
|
|
|
aStream << "\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (aDumpHtml) {
|
|
|
|
aStream << "</ul>";
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
#endif
|
2014-12-17 02:39:43 +03:00
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
|
2014-04-09 13:15:17 +04:00
|
|
|
static inline void
|
|
|
|
AddWrappedRegion(const nsIntRegion& aInput, nsIntRegion& aOutput,
|
2015-06-03 14:45:24 +03:00
|
|
|
const IntSize& aSize, const nsIntPoint& aShift)
|
2014-04-09 13:15:17 +04:00
|
|
|
{
|
|
|
|
nsIntRegion tempRegion;
|
2015-05-07 12:07:42 +03:00
|
|
|
tempRegion.And(IntRect(aShift, aSize), aInput);
|
2014-04-09 13:15:17 +04:00
|
|
|
tempRegion.MoveBy(-aShift);
|
|
|
|
aOutput.Or(aOutput, tempRegion);
|
|
|
|
}
|
|
|
|
|
2014-02-20 17:05:32 +04:00
|
|
|
bool
|
2013-12-05 22:39:22 +04:00
|
|
|
ContentHostSingleBuffered::UpdateThebes(const ThebesBufferData& aData,
|
|
|
|
const nsIntRegion& aUpdated,
|
2016-12-07 02:34:54 +03:00
|
|
|
const nsIntRegion& aOldValidRegionBack)
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
|
|
|
if (!mTextureHost) {
|
|
|
|
mInitialised = false;
|
2014-02-20 17:05:32 +04:00
|
|
|
return true; // FIXME should we return false? Returning true for now
|
|
|
|
} // to preserve existing behavior of NOT causing IPC errors.
|
2013-12-05 22:39:22 +04:00
|
|
|
|
|
|
|
// updated is in screen coordinates. Convert it to buffer coordinates.
|
|
|
|
nsIntRegion destRegion(aUpdated);
|
2015-10-25 18:00:59 +03:00
|
|
|
|
|
|
|
if (mReceivedNewHost) {
|
|
|
|
destRegion.Or(destRegion, aOldValidRegionBack);
|
|
|
|
mReceivedNewHost = false;
|
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
destRegion.MoveBy(-aData.rect().TopLeft());
|
|
|
|
|
2014-04-09 13:15:17 +04:00
|
|
|
if (!aData.rect().Contains(aUpdated.GetBounds()) ||
|
|
|
|
aData.rotation().x > aData.rect().width ||
|
|
|
|
aData.rotation().y > aData.rect().height) {
|
|
|
|
NS_ERROR("Invalid update data");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// destRegion is now in logical coordinates relative to the buffer, but we
|
|
|
|
// need to account for rotation. We do that by moving the region to the
|
|
|
|
// rotation offset and then wrapping any pixels that extend off the
|
|
|
|
// bottom/right edges.
|
|
|
|
|
|
|
|
// Shift to the rotation point
|
2013-12-05 22:39:22 +04:00
|
|
|
destRegion.MoveBy(aData.rotation());
|
|
|
|
|
2015-06-03 14:45:24 +03:00
|
|
|
IntSize bufferSize = aData.rect().Size();
|
2013-12-05 22:39:22 +04:00
|
|
|
|
2014-04-09 13:15:17 +04:00
|
|
|
// Select only the pixels that are still within the buffer.
|
|
|
|
nsIntRegion finalRegion;
|
2015-04-21 18:04:57 +03:00
|
|
|
finalRegion.And(IntRect(IntPoint(), bufferSize), destRegion);
|
2014-04-09 13:15:17 +04:00
|
|
|
|
|
|
|
// For each of the overlap areas (right, bottom-right, bottom), select those
|
|
|
|
// pixels and wrap them around to the opposite edge of the buffer rect.
|
|
|
|
AddWrappedRegion(destRegion, finalRegion, bufferSize, nsIntPoint(aData.rect().width, 0));
|
|
|
|
AddWrappedRegion(destRegion, finalRegion, bufferSize, nsIntPoint(aData.rect().width, aData.rect().height));
|
|
|
|
AddWrappedRegion(destRegion, finalRegion, bufferSize, nsIntPoint(0, aData.rect().height));
|
|
|
|
|
2015-05-07 12:07:42 +03:00
|
|
|
MOZ_ASSERT(IntRect(0, 0, aData.rect().width, aData.rect().height).Contains(finalRegion.GetBounds()));
|
2013-12-05 22:39:22 +04:00
|
|
|
|
2014-04-09 13:15:17 +04:00
|
|
|
mTextureHost->Updated(&finalRegion);
|
2013-12-05 22:39:22 +04:00
|
|
|
if (mTextureHostOnWhite) {
|
2014-04-09 13:15:17 +04:00
|
|
|
mTextureHostOnWhite->Updated(&finalRegion);
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
mInitialised = true;
|
|
|
|
|
|
|
|
mBufferRect = aData.rect();
|
|
|
|
mBufferRotation = aData.rotation();
|
2014-02-20 17:05:32 +04:00
|
|
|
|
|
|
|
return true;
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
|
2014-02-20 17:05:32 +04:00
|
|
|
bool
|
2013-12-05 22:39:22 +04:00
|
|
|
ContentHostDoubleBuffered::UpdateThebes(const ThebesBufferData& aData,
|
|
|
|
const nsIntRegion& aUpdated,
|
2016-12-07 02:34:54 +03:00
|
|
|
const nsIntRegion& aOldValidRegionBack)
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
|
|
|
if (!mTextureHost) {
|
|
|
|
mInitialised = false;
|
2014-02-20 17:05:32 +04:00
|
|
|
return true;
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// We don't need to calculate an update region because we assume that if we
|
|
|
|
// are using double buffering then we have render-to-texture and thus no
|
|
|
|
// upload to do.
|
|
|
|
mTextureHost->Updated();
|
|
|
|
if (mTextureHostOnWhite) {
|
|
|
|
mTextureHostOnWhite->Updated();
|
|
|
|
}
|
|
|
|
mInitialised = true;
|
|
|
|
|
|
|
|
mBufferRect = aData.rect();
|
|
|
|
mBufferRotation = aData.rotation();
|
|
|
|
|
|
|
|
// Save the current valid region of our front buffer, because if
|
|
|
|
// we're double buffering, it's going to be the valid region for the
|
|
|
|
// next back buffer sent back to the renderer.
|
|
|
|
//
|
|
|
|
// NB: we rely here on the fact that mValidRegion is initialized to
|
|
|
|
// empty, and that the first time Swap() is called we don't have a
|
|
|
|
// valid front buffer that we're going to return to content.
|
|
|
|
mValidRegionForNextBackBuffer = aOldValidRegionBack;
|
2014-02-20 17:05:32 +04:00
|
|
|
|
|
|
|
return true;
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
|
2013-11-28 01:16:34 +04:00
|
|
|
void
|
2014-06-20 02:36:25 +04:00
|
|
|
ContentHostTexture::PrintInfo(std::stringstream& aStream, const char* aPrefix)
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << aPrefix;
|
|
|
|
aStream << nsPrintfCString("ContentHost (0x%p)", this).get();
|
2013-12-05 22:39:22 +04:00
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
AppendToString(aStream, mBufferRect, " [buffer-rect=", "]");
|
|
|
|
AppendToString(aStream, mBufferRotation, " [buffer-rotation=", "]");
|
2013-12-05 22:39:22 +04:00
|
|
|
if (PaintWillResample()) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << " [paint-will-resample]";
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mTextureHost) {
|
2014-05-03 01:29:29 +04:00
|
|
|
nsAutoCString pfx(aPrefix);
|
|
|
|
pfx += " ";
|
|
|
|
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "\n";
|
|
|
|
mTextureHost->PrintInfo(aStream, pfx.get());
|
2013-12-05 22:39:22 +04: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 13:20:52 +04:00
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<TexturedEffect>
|
2016-05-25 19:01:18 +03:00
|
|
|
ContentHostTexture::GenEffect(const gfx::SamplingFilter aSamplingFilter)
|
2014-10-16 21:08:32 +04:00
|
|
|
{
|
|
|
|
if (!mTextureHost) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
if (!mTextureHost->BindTextureSource(mTextureSource)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
if (!mTextureHostOnWhite) {
|
|
|
|
mTextureSourceOnWhite = nullptr;
|
|
|
|
}
|
|
|
|
if (mTextureHostOnWhite && !mTextureHostOnWhite->BindTextureSource(mTextureSourceOnWhite)) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return CreateTexturedEffect(mTextureSource.get(),
|
|
|
|
mTextureSourceOnWhite.get(),
|
2017-02-14 23:29:39 +03:00
|
|
|
aSamplingFilter, true);
|
2014-10-16 21:08:32 +04:00
|
|
|
}
|
|
|
|
|
2015-06-17 17:00:52 +03:00
|
|
|
already_AddRefed<gfx::DataSourceSurface>
|
2014-04-02 10:45:02 +04:00
|
|
|
ContentHostTexture::GetAsSurface()
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
|
|
|
if (!mTextureHost) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
return mTextureHost->GetAsSurface();
|
|
|
|
}
|
|
|
|
|
2013-07-30 13:59:51 +04:00
|
|
|
|
2015-05-07 12:07:42 +03:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|