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 {
|
2013-08-12 03:17:23 +04:00
|
|
|
namespace gfx {
|
|
|
|
class Matrix4x4;
|
|
|
|
}
|
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
|
|
|
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
|
2014-10-16 21:08:32 +04:00
|
|
|
ContentHostTexture::Composite(EffectChain& aEffectChain,
|
|
|
|
float aOpacity,
|
|
|
|
const gfx::Matrix4x4& aTransform,
|
|
|
|
const Filter& aFilter,
|
|
|
|
const Rect& aClipRect,
|
|
|
|
const nsIntRegion* aVisibleRegion)
|
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;
|
|
|
|
}
|
|
|
|
|
2014-10-16 21:08:32 +04:00
|
|
|
RefPtr<TexturedEffect> effect = CreateTexturedEffect(mTextureSource.get(),
|
|
|
|
mTextureSourceOnWhite.get(),
|
|
|
|
aFilter, 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();
|
2013-12-05 22:39:22 +04:00
|
|
|
nsIntRect textureRect = nsIntRect(0, 0, texSize.width, texSize.height);
|
|
|
|
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
|
|
|
|
nsIntRegionRectIterator iter(subregion);
|
|
|
|
while (const nsIntRect* iterRect = iter.Next()) {
|
|
|
|
nsIntRect regionRect = *iterRect;
|
|
|
|
nsIntRect screenRect = regionRect;
|
|
|
|
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 {
|
|
|
|
if (iterOnWhite) {
|
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.");
|
|
|
|
}
|
|
|
|
|
2014-04-28 15:27:25 +04:00
|
|
|
nsIntRect texRect = bigImgIter ? bigImgIter->GetTileRect()
|
2013-12-05 22:39:22 +04:00
|
|
|
: nsIntRect(0, 0,
|
|
|
|
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++) {
|
|
|
|
nsIntRect currentTileRect(texRect);
|
|
|
|
currentTileRect.MoveBy(x * texSize.width, y * texSize.height);
|
|
|
|
|
|
|
|
nsIntRegionRectIterator screenIter(screenRects);
|
|
|
|
nsIntRegionRectIterator regionIter(regionRects);
|
|
|
|
|
|
|
|
const nsIntRect* screenRect;
|
|
|
|
const nsIntRect* regionRect;
|
|
|
|
while ((screenRect = screenIter.Next()) &&
|
|
|
|
(regionRect = regionIter.Next())) {
|
|
|
|
nsIntRect tileScreenRect(*screenRect);
|
|
|
|
nsIntRect tileRegionRect(*regionRect);
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
|
|
tileRegionRect = regionRect->Intersect(currentTileRect);
|
|
|
|
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);
|
|
|
|
GetCompositor()->DrawQuad(rect, aClipRect, aEffectChain, aOpacity, aTransform);
|
|
|
|
if (usingTiles) {
|
2014-04-26 06:34:06 +04:00
|
|
|
DiagnosticFlags diagnostics = DiagnosticFlags::CONTENT | DiagnosticFlags::BIGIMAGE;
|
|
|
|
if (iterOnWhite) {
|
|
|
|
diagnostics |= DiagnosticFlags::COMPONENT_ALPHA;
|
|
|
|
}
|
2013-12-05 22:39:22 +04:00
|
|
|
GetCompositor()->DrawDiagnostics(diagnostics, rect, aClipRect,
|
2014-03-25 20:54:39 +04:00
|
|
|
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;
|
|
|
|
}
|
2014-09-24 01:48:17 +04:00
|
|
|
GetCompositor()->DrawDiagnostics(diagnostics, nsIntRegion(mBufferRect), aClipRect,
|
2014-03-25 20:54:39 +04:00
|
|
|
aTransform, mFlashCounter);
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2014-04-02 10:45:02 +04:00
|
|
|
ContentHostTexture::UseTextureHost(TextureHost* aTexture)
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
2014-04-02 10:45:02 +04:00
|
|
|
ContentHostBase::UseTextureHost(aTexture);
|
2014-02-06 15:28:29 +04:00
|
|
|
mTextureHost = aTexture;
|
|
|
|
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
|
2014-04-02 10:45:02 +04:00
|
|
|
ContentHostTexture::SetCompositor(Compositor* aCompositor)
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
2014-04-02 10:45:02 +04:00
|
|
|
ContentHostBase::SetCompositor(aCompositor);
|
2013-12-05 22:39:22 +04:00
|
|
|
if (mTextureHost) {
|
|
|
|
mTextureHost->SetCompositor(aCompositor);
|
|
|
|
}
|
|
|
|
if (mTextureHostOnWhite) {
|
|
|
|
mTextureHostOnWhite->SetCompositor(aCompositor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2013-12-05 22:39:22 +04:00
|
|
|
if (!aDumpHtml) {
|
|
|
|
return;
|
|
|
|
}
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << "<ul>";
|
2013-12-05 22:39:22 +04:00
|
|
|
if (mTextureHost) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << aPrefix;
|
|
|
|
aStream << "<li> <a href=";
|
|
|
|
DumpTextureHost(aStream, mTextureHost);
|
|
|
|
aStream << "> Front buffer </a></li> ";
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
if (mTextureHostOnWhite) {
|
2014-06-20 02:36:25 +04:00
|
|
|
aStream << aPrefix;
|
|
|
|
aStream << "<li> <a href=";
|
|
|
|
DumpTextureHost(aStream, mTextureHostOnWhite);
|
|
|
|
aStream << "> Front buffer on white </a> </li> ";
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
2014-06-20 02:36:25 +04:00
|
|
|
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,
|
|
|
|
const nsIntSize& aSize, const nsIntPoint& aShift)
|
|
|
|
{
|
|
|
|
nsIntRegion tempRegion;
|
|
|
|
tempRegion.And(nsIntRect(aShift, aSize), aInput);
|
|
|
|
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,
|
|
|
|
const nsIntRegion& aOldValidRegionBack,
|
|
|
|
nsIntRegion* aUpdatedRegionBack)
|
|
|
|
{
|
|
|
|
aUpdatedRegionBack->SetEmpty();
|
|
|
|
|
|
|
|
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);
|
|
|
|
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());
|
|
|
|
|
2014-04-09 13:15:17 +04:00
|
|
|
nsIntSize 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;
|
|
|
|
finalRegion.And(nsIntRect(nsIntPoint(), bufferSize), destRegion);
|
|
|
|
|
|
|
|
// 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));
|
|
|
|
|
|
|
|
MOZ_ASSERT(nsIntRect(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,
|
|
|
|
const nsIntRegion& aOldValidRegionBack,
|
|
|
|
nsIntRegion* aUpdatedRegionBack)
|
|
|
|
{
|
|
|
|
if (!mTextureHost) {
|
|
|
|
mInitialised = false;
|
|
|
|
|
|
|
|
*aUpdatedRegionBack = aUpdated;
|
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();
|
|
|
|
|
|
|
|
*aUpdatedRegionBack = aUpdated;
|
|
|
|
|
|
|
|
// 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
|
|
|
|
2013-11-28 01:16:34 +04:00
|
|
|
LayerRenderState
|
2014-04-02 10:45:02 +04:00
|
|
|
ContentHostTexture::GetRenderState()
|
2013-12-05 22:39:22 +04:00
|
|
|
{
|
|
|
|
if (!mTextureHost) {
|
|
|
|
return LayerRenderState();
|
|
|
|
}
|
|
|
|
|
|
|
|
LayerRenderState result = mTextureHost->GetRenderState();
|
|
|
|
|
|
|
|
if (mBufferRotation != nsIntPoint()) {
|
2014-04-26 06:34:05 +04:00
|
|
|
result.mFlags |= LayerRenderStateFlags::BUFFER_ROTATION;
|
2013-12-05 22:39:22 +04:00
|
|
|
}
|
|
|
|
result.SetOffset(GetOriginOffset());
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-10-16 21:08:32 +04:00
|
|
|
TemporaryRef<TexturedEffect>
|
|
|
|
ContentHostTexture::GenEffect(const gfx::Filter& aFilter)
|
|
|
|
{
|
|
|
|
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(),
|
|
|
|
aFilter, true);
|
|
|
|
}
|
|
|
|
|
2013-11-28 01:16:34 +04:00
|
|
|
TemporaryRef<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
|
|
|
|
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
|
|
|
|
} // namespace
|