Backout bug 626602, follow-ups and conflicting bug 631388 due to Win Tp4 permaorange causing a=CLOSED TREE

This commit is contained in:
Marco Bonardo 2011-02-09 15:48:12 +01:00
Родитель 6e8c35099b
Коммит 562557746d
66 изменённых файлов: 290 добавлений и 3146 удалений

Просмотреть файл

@ -1,70 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=8 et :
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Code.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Jones <jones.chris.g@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
include protocol PPluginInstance;
namespace mozilla {
namespace plugins {
/**
* This protocol exists to allow us to correctly destroy background
* surfaces. The browser owns the surfaces, but shares a "reference"
* with the plugin. The browser needs to notify the plugin when the
* background is going to be destroyed, but it can't rely on the
* plugin to destroy it because the plugin may crash at any time. So
* the plugin instance relinquishes destruction of the its old
* background to actors of this protocol, which can deal with crashy
* corner cases more easily than the instance.
*/
protocol PPluginBackgroundDestroyer {
manager PPluginInstance;
// The ctor message for this protocol serves double-duty as
// notification that that the background is stale.
parent:
__delete__();
state DESTROYING:
recv __delete__;
};
} // namespace plugins
} // namespace mozilla

Просмотреть файл

@ -37,7 +37,6 @@
*
* ***** END LICENSE BLOCK ***** */
include protocol PPluginBackgroundDestroyer;
include protocol PPluginModule;
include protocol PPluginScriptableObject;
include protocol PBrowserStream;
@ -58,7 +57,6 @@ using mozilla::gfxSurfaceType;
using gfxIntSize;
using mozilla::null_t;
using mozilla::plugins::WindowsSharedMemoryHandle;
using nsIntRect;
namespace mozilla {
namespace plugins {
@ -85,7 +83,6 @@ rpc protocol PPluginInstance
{
manager PPluginModule;
manages PPluginBackgroundDestroyer;
manages PPluginScriptableObject;
manages PBrowserStream;
manages PPluginStream;
@ -129,13 +126,6 @@ child:
// with type equals to surfaceType
async AsyncSetWindow(gfxSurfaceType surfaceType, NPRemoteWindow window);
// There is now an opaque background behind this instance (or the
// background was updated). The changed area is |rect|. The
// browser owns the background surface, and it's read-only from
// within the plugin process. |background| is either null_t to
// refer to the existing background or a fresh descriptor.
async UpdateBackground(SurfaceDescriptor background, nsIntRect rect);
rpc NPP_Destroy()
returns (NPError rv);
@ -246,8 +236,6 @@ parent:
child:
rpc SetPluginFocus();
rpc UpdateWindow();
async PPluginBackgroundDestroyer();
};
} // namespace plugins

Просмотреть файл

@ -1,108 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: sw=4 ts=8 et :
*/
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Code.
*
* The Initial Developer of the Original Code is
* The Mozilla Foundation
* Portions created by the Initial Developer are Copyright (C) 2010
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Chris Jones <jones.chris.g@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef dom_plugins_PluginBackgroundDestroyer
#define dom_plugins_PluginBackgroundDestroyer
#include "mozilla/plugins/PPluginBackgroundDestroyerChild.h"
#include "mozilla/plugins/PPluginBackgroundDestroyerParent.h"
#include "gfxASurface.h"
#include "gfxSharedImageSurface.h"
namespace mozilla {
namespace plugins {
/**
* When instances of this class are destroyed, the old background goes
* along with them, completing the destruction process (whether or not
* the plugin stayed alive long enough to ack).
*/
class PluginBackgroundDestroyerParent : public PPluginBackgroundDestroyerParent {
public:
PluginBackgroundDestroyerParent(gfxASurface* aDyingBackground)
: mDyingBackground(aDyingBackground)
{ }
virtual ~PluginBackgroundDestroyerParent() { }
private:
NS_OVERRIDE
virtual void ActorDestroy(ActorDestroyReason why)
{
switch(why) {
case Deletion:
case AncestorDeletion:
if (gfxSharedImageSurface::IsSharedImage(mDyingBackground)) {
gfxSharedImageSurface* s =
static_cast<gfxSharedImageSurface*>(mDyingBackground.get());
DeallocShmem(s->GetShmem());
}
break;
default:
// We're shutting down or crashed, let automatic cleanup
// take care of our shmem, if we have one.
break;
}
}
nsRefPtr<gfxASurface> mDyingBackground;
};
/**
* This class exists solely to instruct its instance to release its
* current background, a new one may be coming.
*/
class PluginBackgroundDestroyerChild : public PPluginBackgroundDestroyerChild {
public:
PluginBackgroundDestroyerChild() { }
virtual ~PluginBackgroundDestroyerChild() { }
private:
// Implementing this for good hygiene.
NS_OVERRIDE
virtual void ActorDestroy(ActorDestroyReason why)
{ }
};
} // namespace plugins
} // namespace mozilla
#endif // dom_plugins_PluginBackgroundDestroyer

Просмотреть файл

@ -37,7 +37,6 @@
*
* ***** END LICENSE BLOCK ***** */
#include "PluginBackgroundDestroyer.h"
#include "PluginInstanceChild.h"
#include "PluginModuleChild.h"
#include "BrowserStreamChild.h"
@ -167,6 +166,7 @@ PluginInstanceChild::PluginInstanceChild(const NPPluginFuncs* aPluginIface)
#endif // OS_WIN
#if defined(OS_WIN)
InitPopupMenuHook();
HookSystemParametersInfo();
#endif // OS_WIN
#ifdef MOZ_X11
// Maemo flash can render plugin with any provided rectangle and not require this quirk.
@ -924,11 +924,6 @@ PluginInstanceChild::AnswerNPP_SetWindow(const NPRemoteWindow& aWindow)
}
#endif
PLUGIN_LOG_DEBUG(
("[InstanceChild][%p] Answer_SetWindow w=<x=%d,y=%d, w=%d,h=%d>, clip=<l=%d,t=%d,r=%d,b=%d>",
this, mWindow.x, mWindow.y, mWindow.width, mWindow.height,
mWindow.clipRect.left, mWindow.clipRect.top, mWindow.clipRect.right, mWindow.clipRect.bottom));
if (mPluginIface->setwindow)
(void) mPluginIface->setwindow(&mData, &mWindow);
@ -1233,6 +1228,47 @@ PluginInstanceChild::PluginWindowProc(HWND hWnd,
return res;
}
/* system parameters info hook for flash */
typedef BOOL (WINAPI *User32SystemParametersInfoW)(UINT uiAction,
UINT uiParam,
PVOID pvParam,
UINT fWinIni);
static User32SystemParametersInfoW sUser32SystemParametersInfoWStub = NULL;
static BOOL WINAPI User32SystemParametersInfoHook(UINT uiAction,
UINT uiParam,
PVOID pvParam,
UINT fWinIni)
{
if (!sUser32SystemParametersInfoWStub) {
NS_NOTREACHED("sUser32SystemParametersInfoWStub not set??");
return FALSE;
}
// Tell them cleartype is disabled, so they don't mess with
// the alpha channel in our buffers.
if (uiAction == SPI_GETFONTSMOOTHINGTYPE && pvParam) {
*((UINT*)(pvParam)) = FE_FONTSMOOTHINGSTANDARD;
return TRUE;
}
return sUser32SystemParametersInfoWStub(uiAction, uiParam, pvParam, fWinIni);
}
void
PluginInstanceChild::HookSystemParametersInfo()
{
if (!(GetQuirks() & PluginModuleChild::QUIRK_FLASH_MASK_CLEARTYPE_SETTINGS))
return;
if (sUser32SystemParametersInfoWStub)
return;
sUser32Intercept.Init("gdi32.dll");
sUser32Intercept.AddHook("SystemParametersInfoW", User32SystemParametersInfoHook,
(void**) &sUser32SystemParametersInfoWStub);
}
/* set window long ptr hook for flash */
/*
@ -2251,10 +2287,6 @@ PluginInstanceChild::DoAsyncSetWindow(const gfxSurfaceType& aSurfaceType,
const NPRemoteWindow& aWindow,
bool aIsAsync)
{
PLUGIN_LOG_DEBUG(
("[InstanceChild][%p] AsyncSetWindow to <x=%d,y=%d, w=%d,h=%d>",
this, aWindow.x, aWindow.y, aWindow.width, aWindow.height));
AssertPluginThread();
NS_ASSERTION(!aWindow.window, "Remote window should be null.");
NS_ASSERTION(!mPendingPluginCall, "Can't do SetWindow during plugin call!");
@ -2268,10 +2300,6 @@ PluginInstanceChild::DoAsyncSetWindow(const gfxSurfaceType& aSurfaceType,
mWindow.window = NULL;
if (mWindow.width != aWindow.width || mWindow.height != aWindow.height) {
// We weakly assume here that the SetWindow arrives before the
// next UpdateBackground, for the new window size, if we were
// going to get one.
mBackground = nsnull;
ClearCurrentSurface();
mAccumulatedInvalidRect = nsIntRect(0, 0, aWindow.width, aWindow.height);
}
@ -2319,11 +2347,9 @@ PluginInstanceChild::CreateOptSurface(void)
NS_ASSERTION(!mCurrentSurface, "mCurrentSurfaceActor can get out of sync.");
nsRefPtr<gfxASurface> retsurf;
// Use an opaque surface unless we're transparent and *don't* have
// a background to source from.
gfxASurface::gfxImageFormat format =
(mIsTransparent && !mBackground) ? gfxASurface::ImageFormatARGB32 :
gfxASurface::ImageFormatRGB24;
mIsTransparent ? gfxASurface::ImageFormatARGB32 :
gfxASurface::ImageFormatRGB24;
#if (MOZ_PLATFORM_MAEMO == 5) || (MOZ_PLATFORM_MAEMO == 6)
// On Maemo 5, we must send the Visibility event to activate the plugin
@ -2361,12 +2387,10 @@ PluginInstanceChild::CreateOptSurface(void)
#ifdef XP_WIN
if (mSurfaceType == gfxASurface::SurfaceTypeWin32 ||
mSurfaceType == gfxASurface::SurfaceTypeD2D) {
bool willHaveTransparentPixels = mIsTransparent && !mBackground;
SharedDIBSurface* s = new SharedDIBSurface();
if (!s->Create(reinterpret_cast<HDC>(mWindow.window),
mWindow.width, mWindow.height,
willHaveTransparentPixels))
mWindow.width, mWindow.height, mIsTransparent))
return false;
mCurrentSurface = s;
@ -2447,8 +2471,6 @@ PluginInstanceChild::MaybeCreatePlatformHelperSurface(void)
return false;
}
}
#elif defined(XP_WIN)
mDoAlphaExtraction = mIsTransparent && !mBackground;
#endif
return true;
@ -2507,7 +2529,7 @@ PluginInstanceChild::UpdateWindowAttributes(bool aForceSetWindow)
mWindow.window = nsnull;
mWsInfo.depth = gfxUtils::ImageFormatToDepth(img->Format());
mWsInfo.colormap = 0;
needWindowUpdate = true;
needWindowUpdate = PR_TRUE;
}
}
#endif // MAEMO
@ -2573,11 +2595,6 @@ PluginInstanceChild::UpdateWindowAttributes(bool aForceSetWindow)
}
#endif
PLUGIN_LOG_DEBUG(
("[InstanceChild][%p] UpdateWindow w=<x=%d,y=%d, w=%d,h=%d>, clip=<l=%d,t=%d,r=%d,b=%d>",
this, mWindow.x, mWindow.y, mWindow.width, mWindow.height,
mWindow.clipRect.left, mWindow.clipRect.top, mWindow.clipRect.right, mWindow.clipRect.bottom));
if (mPluginIface->setwindow) {
mPluginIface->setwindow(&mData, &mWindow);
}
@ -2587,6 +2604,12 @@ void
PluginInstanceChild::PaintRectToPlatformSurface(const nsIntRect& aRect,
gfxASurface* aSurface)
{
bool temporarilyMakeVisible = !IsVisible() && !mHasPainted;
if (temporarilyMakeVisible) {
mWindow.clipRect.right = mWindow.width;
mWindow.clipRect.bottom = mWindow.height;
}
UpdateWindowAttributes();
#ifdef MOZ_X11
@ -2675,6 +2698,14 @@ PluginInstanceChild::PaintRectToPlatformSurface(const nsIntRect& aRect,
#else
NS_RUNTIMEABORT("Surface type not implemented.");
#endif
if (temporarilyMakeVisible) {
mWindow.clipRect.right = mWindow.clipRect.bottom = 0;
if (mPluginIface->setwindow) {
mPluginIface->setwindow(&mData, &mWindow);
}
}
}
void
@ -2704,7 +2735,7 @@ PluginInstanceChild::PaintRectToSurface(const nsIntRect& aRect,
}
#endif
if (aColor.a > 0.0) {
if (mIsTransparent) {
// Clear surface content for transparent rendering
nsRefPtr<gfxContext> ctx = new gfxContext(renderSurface);
ctx->SetColor(aColor);
@ -2761,9 +2792,6 @@ PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
// We always use a temporary "white image"
whiteImage = new gfxImageSurface(targetSize, gfxASurface::ImageFormatRGB24);
if (whiteImage->CairoStatus()) {
return;
}
#ifdef XP_WIN
// On windows, we need an HDC and so can't paint directly to
@ -2830,14 +2858,6 @@ PluginInstanceChild::PaintRectWithAlphaExtraction(const nsIntRect& aRect,
}
}
bool
PluginInstanceChild::CanPaintOnBackground()
{
return (mBackground &&
mCurrentSurface &&
mCurrentSurface->GetSize() == mBackground->GetSize());
}
bool
PluginInstanceChild::ShowPluginFrame()
{
@ -2852,20 +2872,11 @@ PluginInstanceChild::ShowPluginFrame()
return false;
}
bool temporarilyMakeVisible = !IsVisible() && !mHasPainted;
if (temporarilyMakeVisible) {
mWindow.clipRect.right = mWindow.width;
mWindow.clipRect.bottom = mWindow.height;
} else if (!IsVisible()) {
// If we're not visible, don't bother painting a <0,0,0,0>
// rect. If we're eventually made visible, the visibility
// change will invalidate our window.
return true;
}
NS_ASSERTION(mWindow.width == (mWindow.clipRect.right - mWindow.clipRect.left) &&
mWindow.height == (mWindow.clipRect.bottom - mWindow.clipRect.top),
"Clip rect should be same size as window when using layers");
// Make expose rect not bigger than clip rect
mAccumulatedInvalidRect.IntersectRect(mAccumulatedInvalidRect,
nsIntRect(mWindow.clipRect.left, mWindow.clipRect.top,
mWindow.clipRect.right - mWindow.clipRect.left,
mWindow.clipRect.bottom - mWindow.clipRect.top));
// Clear accRect here to be able to pass
// test_invalidate_during_plugin_paint test
@ -2873,54 +2884,17 @@ PluginInstanceChild::ShowPluginFrame()
mAccumulatedInvalidRect.Empty();
if (!ReadbackDifferenceRect(rect)) {
// We couldn't read back the pixels that differ between the
// current surface and last, so we have to invalidate the
// entire window.
// Just repaint whole plugin, because we cannot read back from Shmem which is owned by another process
rect.SetRect(0, 0, mWindow.width, mWindow.height);
}
bool haveTransparentPixels =
gfxASurface::CONTENT_COLOR_ALPHA == mCurrentSurface->GetContentType();
PLUGIN_LOG_DEBUG(
("[InstanceChild][%p] Painting%s <x=%d,y=%d, w=%d,h=%d>",
this, haveTransparentPixels ? " with alpha" : "",
rect.x, rect.y, rect.width, rect.height));
if (CanPaintOnBackground()) {
PLUGIN_LOG_DEBUG((" (on background)"));
// Source the background pixels ...
{
nsRefPtr<gfxContext> ctx = new gfxContext(mCurrentSurface);
ctx->SetSource(mBackground);
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
ctx->Rectangle(gfxRect(rect.x, rect.y, rect.width, rect.height));
ctx->Fill();
}
// ... and hand off to the plugin
// BEWARE: mBackground may die during this call
PaintRectToSurface(rect, mCurrentSurface, gfxRGBA(0.0, 0.0, 0.0, 0.0));
} else if (mDoAlphaExtraction) {
PLUGIN_LOG_DEBUG((" (with alpha recovery)"));
if (mDoAlphaExtraction) {
PaintRectWithAlphaExtraction(rect, mCurrentSurface);
} else {
PLUGIN_LOG_DEBUG((" (onto opaque surface)"));
PaintRectToSurface(rect, mCurrentSurface, gfxRGBA(0.0, 0.0, 0.0, 0.0));
}
mHasPainted = true;
if (temporarilyMakeVisible) {
mWindow.clipRect.right = mWindow.clipRect.bottom = 0;
PLUGIN_LOG_DEBUG(
("[InstanceChild][%p] Undoing temporary clipping w=<x=%d,y=%d, w=%d,h=%d>, clip=<l=%d,t=%d,r=%d,b=%d>",
this, mWindow.x, mWindow.y, mWindow.width, mWindow.height,
mWindow.clipRect.left, mWindow.clipRect.top, mWindow.clipRect.right, mWindow.clipRect.bottom));
if (mPluginIface->setwindow) {
mPluginIface->setwindow(&mData, &mWindow);
}
}
NPRect r = { (uint16_t)rect.y, (uint16_t)rect.x,
(uint16_t)rect.YMost(), (uint16_t)rect.XMost() };
SurfaceDescriptor currSurf;
@ -2944,7 +2918,7 @@ PluginInstanceChild::ShowPluginFrame()
mCurrentSurfaceActor =
SendPPluginSurfaceConstructor(handle,
mCurrentSurface->GetSize(),
haveTransparentPixels);
mIsTransparent);
}
currSurf = mCurrentSurfaceActor;
s->Flush();
@ -2988,17 +2962,9 @@ PluginInstanceChild::ReadbackDifferenceRect(const nsIntRect& rect)
return false;
#endif
if (mCurrentSurface->GetContentType() != mBackSurface->GetContentType())
return false;
if (mSurfaceDifferenceRect.IsEmpty())
return true;
PLUGIN_LOG_DEBUG(
("[InstanceChild][%p] Reading back part of <x=%d,y=%d, w=%d,h=%d>",
this, mSurfaceDifferenceRect.x, mSurfaceDifferenceRect.y,
mSurfaceDifferenceRect.width, mSurfaceDifferenceRect.height));
// Read back previous content
nsRefPtr<gfxContext> ctx = new gfxContext(mCurrentSurface);
ctx->SetOperator(gfxContext::OPERATOR_SOURCE);
@ -3075,110 +3041,6 @@ PluginInstanceChild::InvalidateRect(NPRect* aInvalidRect)
SendNPN_InvalidateRect(*aInvalidRect);
}
bool
PluginInstanceChild::RecvUpdateBackground(const SurfaceDescriptor& aBackground,
const nsIntRect& aRect)
{
NS_ABORT_IF_FALSE(mIsTransparent, "Only transparent plugins use backgrounds");
if (SurfaceDescriptor::Tnull_t == aBackground.type()) {
// null_t here means "use existing background". We're
// notified when we lose our background through
// PPluginBackgroundDestroyer. We might have already dropped
// our background from an ill-timed SetWindow, though.
if (!mBackground) {
return true;
}
} else {
NS_ABORT_IF_FALSE(!mBackground, "Shouldn't have background here");
// Now that we have a new background, our choice of surface
// format and/or size should have changed.
ClearCurrentSurface();
// XXX refactor me
switch (aBackground.type()) {
#ifdef MOZ_X11
case SurfaceDescriptor::TSurfaceDescriptorX11: {
SurfaceDescriptorX11 xdesc = aBackground.get_SurfaceDescriptorX11();
XRenderPictFormat pf;
pf.id = xdesc.xrenderPictID();
XRenderPictFormat *incFormat =
XRenderFindFormat(DefaultXDisplay(), PictFormatID, &pf, 0);
mBackground =
new gfxXlibSurface(DefaultScreenOfDisplay(DefaultXDisplay()),
xdesc.XID(), incFormat, xdesc.size());
break;
}
#endif
case SurfaceDescriptor::TShmem: {
mBackground = gfxSharedImageSurface::Open(aBackground.get_Shmem());
break;
}
default:
NS_RUNTIMEABORT("Unexpected background surface descriptor");
}
}
if (!mBackground) {
return false;
}
// XXX refactor me
mAccumulatedInvalidRect.UnionRect(aRect, mAccumulatedInvalidRect);
// The browser is limping along with a stale copy of our pixels.
// Try to repaint ASAP.
if (!ShowPluginFrame()) {
NS_WARNING("Couldn't immediately repaint plugin instance");
AsyncShowPluginFrame();
}
return true;
}
PPluginBackgroundDestroyerChild*
PluginInstanceChild::AllocPPluginBackgroundDestroyer()
{
return new PluginBackgroundDestroyerChild();
}
bool
PluginInstanceChild::RecvPPluginBackgroundDestroyerConstructor(
PPluginBackgroundDestroyerChild* aActor)
{
// Our background changed, so we have to invalidate the area
// painted with the old background. If the background was
// destroyed because we have a new background, then we expect to
// be notified of that "soon", before processing the asynchronous
// invalidation here. If we're *not* getting a new background,
// our current front surface is stale and we want to repaint
// "soon" so that we can hand the browser back a surface with
// alpha values. (We should be notified of that invalidation soon
// too, but we don't assume that here.)
if (mBackground) {
gfxIntSize bgsize = mBackground->GetSize();
mAccumulatedInvalidRect.UnionRect(
nsIntRect(0, 0, bgsize.width, bgsize.height), mAccumulatedInvalidRect);
AsyncShowPluginFrame();
// NB: we don't have to XSync here because only ShowPluginFrame()
// uses mBackground, and it always XSyncs after finishing.
mBackground = nsnull;
ClearCurrentSurface();
}
return PPluginBackgroundDestroyerChild::Send__delete__(aActor);
}
bool
PluginInstanceChild::DeallocPPluginBackgroundDestroyer(
PPluginBackgroundDestroyerChild* aActor)
{
delete aActor;
return true;
}
uint32_t
PluginInstanceChild::ScheduleTimer(uint32_t interval, bool repeat,
TimerFunc func)
@ -3268,8 +3130,7 @@ PluginInstanceChild::SwapSurfaces()
// Outdated back surface... not usable anymore due to changed plugin size.
// Dropping obsolete surface
if (mCurrentSurface && mBackSurface &&
(mCurrentSurface->GetSize() != mBackSurface->GetSize() ||
mCurrentSurface->GetContentType() != mBackSurface->GetContentType())) {
mCurrentSurface->GetSize() != mBackSurface->GetSize()) {
mCurrentSurface = nsnull;
#ifdef XP_WIN
if (mCurrentSurfaceActor) {

Просмотреть файл

@ -236,22 +236,6 @@ private:
InternalGetNPObjectForValue(NPNVariable aValue,
NPObject** aObject);
NS_OVERRIDE
virtual bool RecvUpdateBackground(const SurfaceDescriptor& aBackground,
const nsIntRect& aRect);
NS_OVERRIDE
virtual PPluginBackgroundDestroyerChild*
AllocPPluginBackgroundDestroyer();
NS_OVERRIDE
virtual bool
RecvPPluginBackgroundDestroyerConstructor(PPluginBackgroundDestroyerChild* aActor);
NS_OVERRIDE
virtual bool
DeallocPPluginBackgroundDestroyer(PPluginBackgroundDestroyerChild* aActor);
#if defined(OS_WIN)
static bool RegisterWindowClass();
bool CreatePluginWindow();
@ -306,6 +290,7 @@ private:
int nIndex,
LONG newLong);
#endif
void HookSystemParametersInfo();
class FlashThrottleAsyncMsg : public ChildAsyncCall
{
@ -422,8 +407,6 @@ private:
const NPCocoaEvent *mCurrentEvent;
#endif
bool CanPaintOnBackground();
bool IsVisible() {
return mWindow.clipRect.top != 0 ||
mWindow.clipRect.left != 0 ||
@ -505,13 +488,6 @@ private:
// surface which is on ParentProcess side
nsRefPtr<gfxASurface> mBackSurface;
// (Not to be confused with mBackSurface). This is a recent copy
// of the opaque pixels under our object frame, if
// |mIsTransparent|. We ask the plugin render directly onto a
// copy of the background pixels if available, and fall back on
// alpha recovery otherwise.
nsRefPtr<gfxASurface> mBackground;
#ifdef XP_WIN
// These actors mirror mCurrentSurface/mBackSurface
PPluginSurfaceChild* mCurrentSurfaceActor;

Просмотреть файл

@ -40,7 +40,6 @@
#include "PluginInstanceParent.h"
#include "BrowserStreamParent.h"
#include "PluginBackgroundDestroyer.h"
#include "PluginModuleParent.h"
#include "PluginStreamParent.h"
#include "StreamNotifyParent.h"
@ -109,7 +108,6 @@ PluginInstanceParent::PluginInstanceParent(PluginModuleParent* parent,
, mDrawingModel(NPDrawingModelCoreGraphics)
, mIOSurface(nsnull)
#endif
, mNewBackground(false)
{
InitQuirksModes(aMimeType);
}
@ -500,12 +498,6 @@ PluginInstanceParent::RecvShow(const NPRect& updatedRect,
const SurfaceDescriptor& newSurface,
SurfaceDescriptor* prevSurface)
{
PLUGIN_LOG_DEBUG(
("[InstanceParent][%p] RecvShow for <x=%d,y=%d, w=%d,h=%d>",
this, updatedRect.left, updatedRect.top,
updatedRect.right - updatedRect.left,
updatedRect.bottom - updatedRect.top));
nsRefPtr<gfxASurface> surface;
if (newSurface.type() == SurfaceDescriptor::TShmem) {
if (!newSurface.get_Shmem().IsReadable()) {
@ -537,11 +529,6 @@ PluginInstanceParent::RecvShow(const NPRect& updatedRect,
#ifdef MOZ_X11
if (mFrontSurface &&
mFrontSurface->GetType() == gfxASurface::SurfaceTypeXlib)
// This is the "old front buffer" we're about to hand back to
// the plugin. We might still have drawing operations
// referencing it, so we XSync here to let them finish before
// the plugin starts scribbling on it again, or worse,
// destroys it.
XSync(DefaultXDisplay(), False);
#endif
@ -553,9 +540,6 @@ PluginInstanceParent::RecvShow(const NPRect& updatedRect,
mFrontSurface = surface;
RecvNPN_InvalidateRect(updatedRect);
PLUGIN_LOG_DEBUG((" (RecvShow invalidated for surface %p)",
mFrontSurface.get()));
return true;
}
@ -588,175 +572,6 @@ PluginInstanceParent::GetSurface(gfxASurface** aSurface)
return NS_ERROR_NOT_AVAILABLE;
}
nsresult
PluginInstanceParent::SetBackgroundUnknown()
{
PLUGIN_LOG_DEBUG(("[InstanceParent][%p] SetBackgroundUnknown", this));
NS_ABORT_IF_FALSE(!mNewBackground, "Forgot EndUpdateBackground?");
if (mBackground) {
DestroyBackground();
NS_ABORT_IF_FALSE(!mBackground, "Background not destroyed");
}
return NS_OK;
}
nsresult
PluginInstanceParent::BeginUpdateBackground(const nsIntRect& aRect,
gfxContext** aCtx)
{
PLUGIN_LOG_DEBUG(
("[InstanceParent][%p] BeginUpdateBackground for <x=%d,y=%d, w=%d,h=%d>",
this, aRect.x, aRect.y, aRect.width, aRect.height));
NS_ABORT_IF_FALSE(!mNewBackground, "Forgot EndUpdateBackground?");
if (!mBackground) {
// XXX if we failed to create a background surface on one
// update, there's no guarantee that later updates will be for
// the entire background area until successful. We might want
// to fix that eventually.
NS_ABORT_IF_FALSE(aRect.TopLeft() == nsIntPoint(0, 0),
"Expecting rect for whole frame");
if (!CreateBackground(aRect.Size())) {
*aCtx = nsnull;
return NS_OK;
}
// The new background forwarded over in EndUpdate below.
mNewBackground = true;
}
#ifdef DEBUG
gfxIntSize sz = mBackground->GetSize();
NS_ABORT_IF_FALSE(nsIntRect(0, 0, sz.width, sz.height).Contains(aRect),
"Update outside of background area");
#endif
nsRefPtr<gfxContext> ctx = new gfxContext(mBackground);
*aCtx = ctx.forget().get();
return NS_OK;
}
nsresult
PluginInstanceParent::EndUpdateBackground(gfxContext* aCtx,
const nsIntRect& aRect)
{
PLUGIN_LOG_DEBUG(
("[InstanceParent][%p] EndUpdateBackground for <x=%d,y=%d, w=%d,h=%d>",
this, aRect.x, aRect.y, aRect.width, aRect.height));
#ifdef MOZ_X11
// Have to XSync here to avoid the plugin trying to draw with this
// surface racing with its creation in the X server. We also want
// to avoid the plugin drawing onto stale pixels, then handing us
// back a front surface from those pixels that we might
// recomposite for "a while" until the next update. This XSync
// still doesn't guarantee that the plugin draws onto a consistent
// view of its background, but it does mean that the plugin is
// drawing onto pixels no older than those in the latest
// EndUpdateBackground().
XSync(DefaultXDisplay(), False);
#endif
unused << SendUpdateBackground(
mNewBackground ? BackgroundDescriptor() : SurfaceDescriptor(null_t()),
aRect);
mNewBackground = false;
return NS_OK;
}
bool
PluginInstanceParent::CreateBackground(const nsIntSize& aSize)
{
NS_ABORT_IF_FALSE(!mBackground, "Already have a background");
// XXX refactor me
#if defined(MOZ_X11)
Screen* screen = DefaultScreenOfDisplay(DefaultXDisplay());
Visual* visual = DefaultVisualOfScreen(screen);
mBackground = gfxXlibSurface::Create(screen, visual,
gfxIntSize(aSize.width, aSize.height));
return !!mBackground;
#elif defined(XP_WIN)
// We have chosen to create an unsafe surface in which the plugin
// can read from the region while we're writing to it.
mBackground =
gfxSharedImageSurface::CreateUnsafe(
this,
gfxIntSize(aSize.width, aSize.height),
gfxASurface::ImageFormatRGB24);
return !!mBackground;
#else
return nsnull;
#endif
}
void
PluginInstanceParent::DestroyBackground()
{
if (!mBackground) {
return;
}
// Relinquish ownership of |mBackground| to its destroyer
PPluginBackgroundDestroyerParent* pbd =
new PluginBackgroundDestroyerParent(mBackground);
mBackground = nsnull;
// If this fails, there's no problem: |bd| will be destroyed along
// with the old background surface.
unused << SendPPluginBackgroundDestroyerConstructor(pbd);
}
SurfaceDescriptor
PluginInstanceParent::BackgroundDescriptor()
{
NS_ABORT_IF_FALSE(mBackground, "Need a background here");
// XXX refactor me
#ifdef MOZ_X11
gfxXlibSurface* xsurf = static_cast<gfxXlibSurface*>(mBackground.get());
return SurfaceDescriptorX11(xsurf->XDrawable(), xsurf->XRenderFormat()->id,
xsurf->GetSize());
#endif
#ifdef XP_WIN
NS_ABORT_IF_FALSE(gfxSharedImageSurface::IsSharedImage(mBackground),
"Expected shared image surface");
gfxSharedImageSurface* shmem =
static_cast<gfxSharedImageSurface*>(mBackground.get());
return shmem->GetShmem();
#endif
// If this is ever used, which it shouldn't be, it will trigger a
// hard assertion in IPDL-generated code.
return SurfaceDescriptor();
}
PPluginBackgroundDestroyerParent*
PluginInstanceParent::AllocPPluginBackgroundDestroyer()
{
NS_RUNTIMEABORT("'Power-user' ctor is used exclusively");
return nsnull;
}
bool
PluginInstanceParent::DeallocPPluginBackgroundDestroyer(
PPluginBackgroundDestroyerParent* aActor)
{
delete aActor;
return true;
}
NPError
PluginInstanceParent::NPP_SetWindow(const NPWindow* aWindow)
{

Просмотреть файл

@ -277,27 +277,8 @@ public:
nsresult AsyncSetWindow(NPWindow* window);
nsresult GetSurface(gfxASurface** aSurface);
nsresult SetBackgroundUnknown();
nsresult BeginUpdateBackground(const nsIntRect& aRect,
gfxContext** aCtx);
nsresult EndUpdateBackground(gfxContext* aCtx,
const nsIntRect& aRect);
private:
// Create an appropriate platform surface for a background of size
// |aSize|. Return true if successful.
bool CreateBackground(const nsIntSize& aSize);
void DestroyBackground();
SurfaceDescriptor BackgroundDescriptor() /*const*/;
NS_OVERRIDE
virtual PPluginBackgroundDestroyerParent*
AllocPPluginBackgroundDestroyer();
NS_OVERRIDE
virtual bool
DeallocPPluginBackgroundDestroyer(PPluginBackgroundDestroyerParent* aActor);
// Quirks mode support for various plugin mime types
enum PluginQuirks {
// OSX: Don't use the refresh timer for plug-ins
@ -354,19 +335,6 @@ private:
// ObjectFrame layer wrapper
nsRefPtr<gfxASurface> mFrontSurface;
// For windowless+transparent instances, this surface contains a
// "pretty recent" copy of the pixels under its <object> frame.
// On the plugin side, we use this surface to avoid doing alpha
// recovery when possible. This surface is created and owned by
// the browser, but a "read-only" reference is sent to the plugin.
//
// We have explicitly chosen not to provide any guarantees about
// the consistency of the pixels in |mBackground|. A plugin may
// be able to observe partial updates to the background.
nsRefPtr<gfxASurface> mBackground;
// True when we just created a background and it needs to be
// shared to the plugin subprocess.
bool mNewBackground;
};

Просмотреть файл

@ -46,11 +46,9 @@
#include "nsTArray.h"
#include "nsPluginError.h"
class gfxASurface;
class gfxContext;
class nsCString;
struct nsIntRect;
class nsNPAPIPlugin;
class gfxASurface;
class nsCString;
namespace mozilla {
@ -91,16 +89,6 @@ public:
virtual nsresult AsyncSetWindow(NPP instance, NPWindow* window) = 0;
virtual nsresult GetSurface(NPP instance, gfxASurface** aSurface) = 0;
virtual bool UseAsyncPainting() = 0;
/**
* The next three methods are the third leg in the trip to
* PluginInstanceParent. They approximately follow the ReadbackSink
* API.
*/
virtual nsresult SetBackgroundUnknown(NPP instance) = 0;
virtual nsresult BeginUpdateBackground(NPP instance,
const nsIntRect&, gfxContext**) = 0;
virtual nsresult EndUpdateBackground(NPP instance,
gfxContext*, const nsIntRect&) = 0;
};

Просмотреть файл

@ -137,9 +137,14 @@ PluginModuleChild::~PluginModuleChild()
if (mLibrary) {
PR_UnloadLibrary(mLibrary);
}
DeinitGraphics();
#ifdef MOZ_WIDGET_QT
nsQAppInstance::Release();
if (sGtkLib) {
PR_UnloadLibrary(sGtkLib);
sGtkLib = nsnull;
s_gtk_init = nsnull;
}
#endif
gInstance = nsnull;
}
@ -554,26 +559,6 @@ PluginModuleChild::InitGraphics()
return true;
}
void
PluginModuleChild::DeinitGraphics()
{
#ifdef MOZ_WIDGET_QT
nsQAppInstance::Release();
if (sGtkLib) {
PR_UnloadLibrary(sGtkLib);
sGtkLib = nsnull;
s_gtk_init = nsnull;
}
#endif
#if defined(MOZ_X11) && defined(NS_FREE_PERMANENT_DATA)
// We free some data off of XDisplay close hooks, ensure they're
// run. Closing the display is pretty scary, so we only do it to
// silence leak checkers.
XCloseDisplay(DefaultXDisplay());
#endif
}
bool
PluginModuleChild::AnswerNP_Shutdown(NPError *rv)
{
@ -1876,6 +1861,7 @@ PluginModuleChild::InitQuirksModes(const nsCString& aMimeType)
mQuirks |= QUIRK_FLASH_THROTTLE_WMUSER_EVENTS;
mQuirks |= QUIRK_FLASH_HOOK_SETLONGPTR;
mQuirks |= QUIRK_FLASH_HOOK_GETWINDOWINFO;
mQuirks |= QUIRK_FLASH_MASK_CLEARTYPE_SETTINGS;
}
#endif
}

Просмотреть файл

@ -246,6 +246,9 @@ public:
// results so mouse input works when flash is displaying it's settings
// window.
QUIRK_FLASH_HOOK_GETWINDOWINFO = 1 << 5,
// Win: Flash trashes the alpha channel in our buffers when cleartype
// is enabled. Mask this setting so they don't know it's enabled.
QUIRK_FLASH_MASK_CLEARTYPE_SETTINGS = 1 << 6,
};
int GetQuirks() { return mQuirks; }
@ -258,7 +261,6 @@ public:
private:
void InitQuirksModes(const nsCString& aMimeType);
bool InitGraphics();
void DeinitGraphics();
#if defined(MOZ_WIDGET_GTK2)
static gboolean DetectNestedEventLoop(gpointer data);
static gboolean ProcessBrowserEvents(gpointer data);

Просмотреть файл

@ -682,40 +682,6 @@ PluginModuleParent::GetSurface(NPP instance, gfxASurface** aSurface)
return i->GetSurface(aSurface);
}
nsresult
PluginModuleParent::SetBackgroundUnknown(NPP instance)
{
PluginInstanceParent* i = InstCast(instance);
if (!i)
return NS_ERROR_FAILURE;
return i->SetBackgroundUnknown();
}
nsresult
PluginModuleParent::BeginUpdateBackground(NPP instance,
const nsIntRect& aRect,
gfxContext** aCtx)
{
PluginInstanceParent* i = InstCast(instance);
if (!i)
return NS_ERROR_FAILURE;
return i->BeginUpdateBackground(aRect, aCtx);
}
nsresult
PluginModuleParent::EndUpdateBackground(NPP instance,
gfxContext* aCtx,
const nsIntRect& aRect)
{
PluginInstanceParent* i = InstCast(instance);
if (!i)
return NS_ERROR_FAILURE;
return i->EndUpdateBackground(aCtx, aRect);
}
#if defined(XP_UNIX) && !defined(XP_MACOSX)
nsresult
PluginModuleParent::NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error)

Просмотреть файл

@ -232,16 +232,6 @@ private:
virtual nsresult AsyncSetWindow(NPP instance, NPWindow* window);
virtual nsresult GetSurface(NPP instance, gfxASurface** aSurface);
NS_OVERRIDE virtual bool UseAsyncPainting() { return true; }
NS_OVERRIDE
virtual nsresult SetBackgroundUnknown(NPP instance);
NS_OVERRIDE
virtual nsresult BeginUpdateBackground(NPP instance,
const nsIntRect& aRect,
gfxContext** aCtx);
NS_OVERRIDE
virtual nsresult EndUpdateBackground(NPP instance,
gfxContext* aCtx,
const nsIntRect& aRect);
#if defined(XP_UNIX) && !defined(XP_MACOSX)
virtual nsresult NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs, NPError* error);

Просмотреть файл

@ -35,7 +35,6 @@
# ***** END LICENSE BLOCK *****
IPDLSRCS = \
PPluginBackgroundDestroyer.ipdl \
PPluginModule.ipdl \
PPluginIdentifier.ipdl \
PPluginInstance.ipdl \

Просмотреть файл

@ -45,7 +45,6 @@
#include "ImageLayers.h"
#include "Layers.h"
#include "gfxPlatform.h"
#include "ReadbackLayer.h"
using namespace mozilla::layers;
@ -66,15 +65,6 @@ namespace {
// XXX pretty general utilities, could centralize
nsACString&
AppendToString(nsACString& s, const void* p,
const char* pfx="", const char* sfx="")
{
s += pfx;
s += nsPrintfCString(64, "%p", p);
return s += sfx;
}
nsACString&
AppendToString(nsACString& s, const gfxPattern::GraphicsFilter& f,
const char* pfx="", const char* sfx="")
@ -401,30 +391,6 @@ ContainerLayer::ComputeEffectiveTransformsForChildren(const gfx3DMatrix& aTransf
}
}
void
ContainerLayer::DidRemoveChild(Layer* aLayer)
{
ThebesLayer* tl = aLayer->AsThebesLayer();
if (tl && tl->UsedForReadback()) {
for (Layer* l = mFirstChild; l; l = l->GetNextSibling()) {
if (l->GetType() == TYPE_READBACK) {
static_cast<ReadbackLayer*>(l)->NotifyThebesLayerRemoved(tl);
}
}
}
if (aLayer->GetType() == TYPE_READBACK) {
static_cast<ReadbackLayer*>(aLayer)->NotifyRemoved();
}
}
void
ContainerLayer::DidInsertChild(Layer* aLayer)
{
if (aLayer->GetType() == TYPE_READBACK) {
mMayHaveReadbackChild = PR_TRUE;
}
}
#ifdef MOZ_LAYERS_HAVE_LOG
static nsACString& PrintInfo(nsACString& aTo, ShadowLayer* aShadowLayer);
@ -568,22 +534,6 @@ ImageLayer::PrintInfo(nsACString& aTo, const char* aPrefix)
return aTo;
}
nsACString&
ReadbackLayer::PrintInfo(nsACString& aTo, const char* aPrefix)
{
Layer::PrintInfo(aTo, aPrefix);
AppendToString(aTo, mSize, " [size=", "]");
if (mBackgroundLayer) {
AppendToString(aTo, mBackgroundLayer, " [backgroundLayer=", "]");
AppendToString(aTo, mBackgroundLayerOffset, " [backgroundOffset=", "]");
} else if (mBackgroundColor.a == 1.0) {
AppendToString(aTo, mBackgroundColor, " [backgroundColor=", "]");
} else {
aTo += " [nobackground]";
}
return aTo;
}
//--------------------------------------------------
// LayerManager
@ -715,10 +665,6 @@ nsACString&
ImageLayer::PrintInfo(nsACString& aTo, const char* aPrefix)
{ return aTo; }
nsACString&
ReadbackLayer::PrintInfo(nsACString& aTo, const char* aPrefix)
{ return aTo; }
void LayerManager::Dump(FILE* aFile, const char* aPrefix) {}
void LayerManager::DumpSelf(FILE* aFile, const char* aPrefix) {}
void LayerManager::Log(const char* aPrefix) {}

Просмотреть файл

@ -78,8 +78,6 @@ class ColorLayer;
class ImageContainer;
class CanvasLayer;
class ShadowLayer;
class ReadbackLayer;
class ReadbackProcessor;
class SpecificLayerAttributes;
/**
@ -396,11 +394,6 @@ public:
* Create a CanvasLayer for this manager's layer tree.
*/
virtual already_AddRefed<CanvasLayer> CreateCanvasLayer() = 0;
/**
* CONSTRUCTION PHASE ONLY
* Create a ReadbackLayer for this manager's layer tree.
*/
virtual already_AddRefed<ReadbackLayer> CreateReadbackLayer() { return nsnull; }
/**
* Can be called anytime
@ -510,15 +503,13 @@ class THEBES_API Layer {
NS_INLINE_DECL_REFCOUNTING(Layer)
public:
// Keep these in alphabetical order
enum LayerType {
TYPE_CANVAS,
TYPE_COLOR,
TYPE_THEBES,
TYPE_CONTAINER,
TYPE_IMAGE,
TYPE_READBACK,
TYPE_SHADOW,
TYPE_THEBES
TYPE_COLOR,
TYPE_CANVAS,
TYPE_SHADOW
};
virtual ~Layer() {}
@ -937,16 +928,12 @@ public:
mEffectiveTransform = SnapTransform(idealTransform, gfxRect(0, 0, 0, 0), nsnull);
}
bool UsedForReadback() { return mUsedForReadback; }
void SetUsedForReadback(bool aUsed) { mUsedForReadback = aUsed; }
protected:
ThebesLayer(LayerManager* aManager, void* aImplData)
: Layer(aManager, aImplData)
, mValidRegion()
, mXResolution(1.0)
, mYResolution(1.0)
, mUsedForReadback(false)
{
mContentFlags = 0; // Clear NO_TEXT, NO_TEXT_OVER_TRANSPARENT
}
@ -969,11 +956,6 @@ protected:
// sense for all backends to fully support it.
float mXResolution;
float mYResolution;
/**
* Set when this ThebesLayer is participating in readback, i.e. some
* ReadbackLayer (may) be getting its background from this layer.
*/
bool mUsedForReadback;
};
/**
@ -1043,18 +1025,12 @@ public:
PRBool SupportsComponentAlphaChildren() { return mSupportsComponentAlphaChildren; }
protected:
friend class ReadbackProcessor;
void DidInsertChild(Layer* aLayer);
void DidRemoveChild(Layer* aLayer);
ContainerLayer(LayerManager* aManager, void* aImplData)
: Layer(aManager, aImplData),
mFirstChild(nsnull),
mLastChild(nsnull),
mUseIntermediateSurface(PR_FALSE),
mSupportsComponentAlphaChildren(PR_FALSE),
mMayHaveReadbackChild(PR_FALSE)
mSupportsComponentAlphaChildren(PR_FALSE)
{
mContentFlags = 0; // Clear NO_TEXT, NO_TEXT_OVER_TRANSPARENT
}
@ -1077,7 +1053,6 @@ protected:
FrameMetrics mFrameMetrics;
PRPackedBool mUseIntermediateSurface;
PRPackedBool mSupportsComponentAlphaChildren;
PRPackedBool mMayHaveReadbackChild;
};
/**

Просмотреть файл

@ -68,14 +68,12 @@ EXPORTS = \
Layers.h \
LayerManagerOGL.h \
LayerManagerOGLProgram.h \
ReadbackLayer.h \
$(NULL)
CPPSRCS = \
Layers.cpp \
BasicImages.cpp \
BasicLayers.cpp \
Layers.cpp \
ReadbackProcessor.cpp \
ThebesLayerBuffer.cpp \
CanvasLayerOGL.cpp \
ColorLayerOGL.cpp \
@ -106,7 +104,6 @@ endif
ifdef MOZ_ENABLE_D3D10_LAYER
EXPORTS += \
LayerManagerD3D10.h \
ReadbackManagerD3D10.h \
$(NULL)
CPPSRCS += \
@ -116,7 +113,6 @@ CPPSRCS += \
ImageLayerD3D10.cpp \
ColorLayerD3D10.cpp \
CanvasLayerD3D10.cpp \
ReadbackManagerD3D10.cpp \
$(NULL)
endif
endif

Просмотреть файл

@ -1,220 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Robert O'Callahan <robert@ocallahan.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef GFX_READBACKLAYER_H
#define GFX_READBACKLAYER_H
#include "Layers.h"
namespace mozilla {
namespace layers {
class ReadbackProcessor;
/**
* A ReadbackSink receives a stream of updates to a rectangle of pixels.
* These update callbacks are always called on the main thread, either during
* EndTransaction or from the event loop.
*/
class THEBES_API ReadbackSink {
public:
ReadbackSink() {}
virtual ~ReadbackSink() {}
/**
* Sends an update to indicate that the background is currently unknown.
*/
virtual void SetUnknown(PRUint64 aSequenceNumber) = 0;
/**
* Called by the layer system to indicate that the contents of part of
* the readback area are changing.
* @param aRect is the rectangle of content that is being updated,
* in the coordinate system of the ReadbackLayer.
* @param aSequenceNumber updates issued out of order should be ignored.
* Only use updates whose sequence counter is greater than all other updates
* seen so far. Return null when a non-fresh sequence value is given.
* @return a context into which the update should be drawn. This should be
* set up to clip to aRect. Zero should never be passed as a sequence number.
* If this returns null, EndUpdate should NOT be called. If it returns
* non-null, EndUpdate must be called.
*
* We don't support partially unknown backgrounds. Therefore, the
* first BeginUpdate after a SetUnknown will have the complete background.
*/
virtual already_AddRefed<gfxContext>
BeginUpdate(const nsIntRect& aRect, PRUint64 aSequenceNumber) = 0;
/**
* EndUpdate must be called immediately after BeginUpdate, without returning
* to the event loop.
* @param aContext the context returned by BeginUpdate
* Implicitly Restore()s the state of aContext.
*/
virtual void EndUpdate(gfxContext* aContext, const nsIntRect& aRect) = 0;
};
/**
* A ReadbackLayer never renders anything. It enables clients to extract
* the rendered contents of the layer tree below the ReadbackLayer.
* The rendered contents are delivered asynchronously via calls to a
* ReadbackSink object supplied by the client.
*
* This is a "best effort" API; it is possible for the layer system to tell
* the ReadbackSink that the contents of the readback area are unknown.
*
* This API exists to work around the limitations of transparent windowless
* plugin rendering APIs. It should not be used for anything else.
*/
class THEBES_API ReadbackLayer : public Layer {
public:
MOZ_LAYER_DECL_NAME("ReadbackLayer", TYPE_READBACK)
virtual void ComputeEffectiveTransforms(const gfx3DMatrix& aTransformToSurface)
{
// Snap our local transform first, and snap the inherited transform as well.
// This makes our snapping equivalent to what would happen if our content
// was drawn into a ThebesLayer (gfxContext would snap using the local
// transform, then we'd snap again when compositing the ThebesLayer).
mEffectiveTransform =
SnapTransform(GetLocalTransform(), gfxRect(0, 0, mSize.width, mSize.height),
nsnull)*
SnapTransform(aTransformToSurface, gfxRect(0, 0, 0, 0), nsnull);
}
/**
* CONSTRUCTION PHASE ONLY
* Set the callback object to which readback updates will be delivered.
* This also resets the "needed rectangle" so that on the next layer tree
* transaction we will try to deliver the full contents of the readback
* area to the sink.
* This layer takes ownership of the sink. It will be deleted when the
* layer is destroyed or when a new sink is set.
* Initially the contents of the readback area are completely unknown.
*/
void SetSink(ReadbackSink* aSink)
{
SetUnknown();
mSink = aSink;
}
ReadbackSink* GetSink() { return mSink; }
/**
* CONSTRUCTION PHASE ONLY
* Set the size of content that should be read back. The readback area
* has its top-left at 0,0 and has size aSize.
* Can only be called while the sink is null!
*/
void SetSize(const nsIntSize& aSize)
{
NS_ASSERTION(!mSink, "Should have no sink while changing size!");
mSize = aSize;
}
const nsIntSize& GetSize() { return mSize; }
nsIntRect GetRect() { return nsIntRect(nsIntPoint(0, 0), mSize); }
PRBool IsBackgroundKnown()
{
return mBackgroundLayer || mBackgroundColor.a == 1.0;
}
void NotifyRemoved() {
SetUnknown();
mSink = nsnull;
}
void NotifyThebesLayerRemoved(ThebesLayer* aLayer)
{
if (mBackgroundLayer == aLayer) {
mBackgroundLayer = nsnull;
}
}
const nsIntPoint& GetBackgroundLayerOffset() { return mBackgroundLayerOffset; }
PRUint64 AllocateSequenceNumber() { return ++mSequenceCounter; }
void SetUnknown()
{
if (IsBackgroundKnown()) {
if (mSink) {
mSink->SetUnknown(AllocateSequenceNumber());
}
mBackgroundLayer = nsnull;
mBackgroundColor = gfxRGBA(0,0,0,0);
}
}
protected:
friend class ReadbackProcessor;
ReadbackLayer(LayerManager* aManager, void* aImplData) :
Layer(aManager, aImplData),
mSequenceCounter(0),
mSize(0,0),
mBackgroundLayer(nsnull),
mBackgroundLayerOffset(0, 0),
mBackgroundColor(gfxRGBA(0,0,0,0))
{}
// Print interesting information about this into aTo. Internally
// used to implement Dump*() and Log*().
virtual nsACString& PrintInfo(nsACString& aTo, const char* aPrefix);
PRUint64 mSequenceCounter;
nsAutoPtr<ReadbackSink> mSink;
nsIntSize mSize;
// This can refer to any (earlier) sibling ThebesLayer. That ThebesLayer
// must have mUsedForReadback set on it. If the ThebesLayer is removed
// for the container, this will be set to null by NotifyThebesLayerRemoved.
// This ThebesLayer contains the contents which have previously been reported
// to mSink. The ThebesLayer had only an integer translation transform,
// and it covered the entire readback area. This layer also had only an
// integer translation transform.
ThebesLayer* mBackgroundLayer;
// When mBackgroundLayer is non-null, this is the offset to add to
// convert from the coordinates of mBackgroundLayer to the coordinates
// of this layer.
nsIntPoint mBackgroundLayerOffset;
// When mBackgroundColor is opaque, this is the color of the ColorLayer
// that contained the contents we reported to mSink, which covered the
// entire readback area.
gfxRGBA mBackgroundColor;
};
}
}
#endif /* GFX_READBACKLAYER_H */

Просмотреть файл

@ -1,198 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Robert O'Callahan <robert@ocallahan.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "ReadbackProcessor.h"
namespace mozilla {
namespace layers {
void
ReadbackProcessor::BuildUpdates(ContainerLayer* aContainer)
{
NS_ASSERTION(mAllUpdates.IsEmpty(), "Some updates not processed?");
if (!aContainer->mMayHaveReadbackChild)
return;
aContainer->mMayHaveReadbackChild = PR_FALSE;
// go backwards so the updates read from earlier layers are later in the
// array.
for (Layer* l = aContainer->GetLastChild(); l; l = l->GetPrevSibling()) {
if (l->GetType() == Layer::TYPE_READBACK) {
aContainer->mMayHaveReadbackChild = PR_TRUE;
BuildUpdatesForLayer(static_cast<ReadbackLayer*>(l));
}
}
}
static Layer*
FindBackgroundLayer(ReadbackLayer* aLayer, nsIntPoint* aOffset)
{
gfxMatrix transform;
if (!aLayer->GetTransform().Is2D(&transform) ||
transform.HasNonIntegerTranslation())
return nsnull;
nsIntPoint transformOffset(PRInt32(transform.x0), PRInt32(transform.y0));
for (Layer* l = aLayer->GetPrevSibling(); l; l = l->GetPrevSibling()) {
gfxMatrix backgroundTransform;
if (!l->GetTransform().Is2D(&backgroundTransform) ||
backgroundTransform.HasNonIntegerTranslation())
return nsnull;
nsIntPoint backgroundOffset(PRInt32(backgroundTransform.x0), PRInt32(backgroundTransform.y0));
nsIntRect rectInBackground(transformOffset - backgroundOffset, aLayer->GetSize());
const nsIntRegion& visibleRegion = l->GetEffectiveVisibleRegion();
if (!visibleRegion.Intersects(rectInBackground))
continue;
// Since l is present in the background, from here on we either choose l
// or nothing.
if (!visibleRegion.Contains(rectInBackground))
return nsnull;
if (l->GetEffectiveOpacity() != 1.0 ||
!(l->GetContentFlags() & Layer::CONTENT_OPAQUE))
return nsnull;
// cliprects are post-transform
const nsIntRect* clipRect = l->GetEffectiveClipRect();
if (clipRect && !clipRect->Contains(nsIntRect(transformOffset, aLayer->GetSize())))
return nsnull;
Layer::LayerType type = l->GetType();
if (type != Layer::TYPE_COLOR && type != Layer::TYPE_THEBES)
return nsnull;
*aOffset = backgroundOffset - transformOffset;
return l;
}
return nsnull;
}
void
ReadbackProcessor::BuildUpdatesForLayer(ReadbackLayer* aLayer)
{
if (!aLayer->mSink)
return;
nsIntPoint offset;
Layer* newBackground = FindBackgroundLayer(aLayer, &offset);
if (!newBackground) {
aLayer->SetUnknown();
return;
}
if (newBackground->GetType() == Layer::TYPE_COLOR) {
ColorLayer* colorLayer = static_cast<ColorLayer*>(newBackground);
if (aLayer->mBackgroundColor != colorLayer->GetColor()) {
aLayer->mBackgroundLayer = nsnull;
aLayer->mBackgroundColor = colorLayer->GetColor();
NS_ASSERTION(aLayer->mBackgroundColor.a == 1.0,
"Color layer said it was opaque!");
nsRefPtr<gfxContext> ctx =
aLayer->mSink->BeginUpdate(aLayer->GetRect(),
aLayer->AllocateSequenceNumber());
if (ctx) {
ctx->SetColor(aLayer->mBackgroundColor);
nsIntSize size = aLayer->GetSize();
ctx->Rectangle(gfxRect(0, 0, size.width, size.height));
ctx->Fill();
aLayer->mSink->EndUpdate(ctx, aLayer->GetRect());
}
}
} else {
NS_ASSERTION(newBackground->AsThebesLayer(), "Must be ThebesLayer");
ThebesLayer* thebesLayer = static_cast<ThebesLayer*>(newBackground);
// updateRect is relative to the ThebesLayer
nsIntRect updateRect = aLayer->GetRect() - offset;
if (thebesLayer != aLayer->mBackgroundLayer ||
offset != aLayer->mBackgroundLayerOffset) {
aLayer->mBackgroundLayer = thebesLayer;
aLayer->mBackgroundLayerOffset = offset;
aLayer->mBackgroundColor = gfxRGBA(0,0,0,0);
thebesLayer->SetUsedForReadback(true);
} else {
nsIntRegion invalid;
invalid.Sub(updateRect, thebesLayer->GetValidRegion());
updateRect = invalid.GetBounds();
}
Update update = { aLayer, updateRect, aLayer->AllocateSequenceNumber() };
mAllUpdates.AppendElement(update);
}
}
void
ReadbackProcessor::GetThebesLayerUpdates(ThebesLayer* aLayer,
nsTArray<Update>* aUpdates,
nsIntRegion* aUpdateRegion)
{
// All ThebesLayers used for readback are in mAllUpdates (some possibly
// with an empty update rect).
aLayer->SetUsedForReadback(false);
if (aUpdateRegion) {
aUpdateRegion->SetEmpty();
}
for (PRUint32 i = mAllUpdates.Length(); i > 0; --i) {
const Update& update = mAllUpdates[i - 1];
if (update.mLayer->mBackgroundLayer == aLayer) {
aLayer->SetUsedForReadback(true);
// Don't bother asking for updates if we have an empty update rect.
if (!update.mUpdateRect.IsEmpty()) {
aUpdates->AppendElement(update);
if (aUpdateRegion) {
aUpdateRegion->Or(*aUpdateRegion, update.mUpdateRect);
}
}
mAllUpdates.RemoveElementAt(i - 1);
}
}
}
ReadbackProcessor::~ReadbackProcessor()
{
for (PRUint32 i = mAllUpdates.Length(); i > 0; --i) {
const Update& update = mAllUpdates[i - 1];
// Unprocessed update. Notify the readback sink that this content is
// unknown.
update.mLayer->SetUnknown();
}
}
}
}

Просмотреть файл

@ -1,105 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Robert O'Callahan <robert@ocallahan.org>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef GFX_READBACKPROCESSOR_H
#define GFX_READBACKPROCESSOR_H
#include "ReadbackLayer.h"
#include "ThebesLayerBuffer.h"
namespace mozilla {
namespace layers {
class ReadbackProcessor {
public:
/**
* Called by the container before processing any child layers. Call this
* if any child layer might have changed in any way (other than content-only
* changes to layers other than ColorLayers and ThebesLayers).
*
* This method recomputes the relationship between ReadbackLayers and
* sibling layers, and dispatches changes to ReadbackLayers. Except that
* if a ThebesLayer needs its contents sent to some ReadbackLayer, we'll
* just record that internally and later the ThebesLayer should call
* GetThebesLayerUpdates when it paints, to find out which rectangle needs
* to be sent, and the ReadbackLayer it needs to be sent to.
*/
void BuildUpdates(ContainerLayer* aContainer);
struct Update {
/**
* The layer a ThebesLayer should send its contents to.
*/
ReadbackLayer* mLayer;
/**
* The rectangle of content that it should send, in the ThebesLayer's
* coordinate system. This rectangle is guaranteed to be in the ThebesLayer's
* visible region. Translate it to mLayer's coordinate system
* by adding mLayer->GetBackgroundLayerOffset().
*/
nsIntRect mUpdateRect;
/**
* The sequence counter value to use when calling DoUpdate
*/
PRUint64 mSequenceCounter;
};
/**
* Appends any ReadbackLayers that need to be updated, and the rects that
* need to be updated, to aUpdates. Only need to call this for ThebesLayers
* that have been marked UsedForReadback().
* Each Update's mLayer's mBackgroundLayer will have been set to aLayer.
* If a ThebesLayer doesn't call GetThebesLayerUpdates, then all the
* ReadbackLayers that needed data from that ThebesLayer will be marked
* as having unknown backgrounds.
* @param aUpdateRegion if non-null, this region is set to the union
* of the mUpdateRects.
*/
void GetThebesLayerUpdates(ThebesLayer* aLayer,
nsTArray<Update>* aUpdates,
nsIntRegion* aUpdateRegion = nsnull);
~ReadbackProcessor();
protected:
void BuildUpdatesForLayer(ReadbackLayer* aLayer);
nsTArray<Update> mAllUpdates;
};
}
}
#endif /* GFX_READBACKPROCESSOR_H */

Просмотреть файл

@ -58,7 +58,6 @@
#include "gfxUtils.h"
#include "ThebesLayerBuffer.h"
#include "nsIWidget.h"
#include "ReadbackProcessor.h"
#include "GLContext.h"
@ -107,16 +106,9 @@ public:
* set up to account for all the properties of the layer (transform,
* opacity, etc).
*/
virtual void Paint(gfxContext* aContext) {}
/**
* Like Paint() but called for ThebesLayers with the additional parameters
* they need.
*/
virtual void PaintThebes(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData,
ReadbackProcessor* aReadback) {}
virtual void Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData) {}
virtual ShadowableLayer* AsShadowableLayer() { return nsnull; }
@ -244,6 +236,8 @@ ContainerInsertAfter(Layer* aChild, Layer* aAfter, Container* aContainer)
aAfter->GetParent() == aContainer),
"aAfter is not our child");
NS_ADDREF(aChild);
aChild->SetParent(aContainer);
if (aAfter == aContainer->mLastChild) {
aContainer->mLastChild = aChild;
@ -254,8 +248,6 @@ ContainerInsertAfter(Layer* aChild, Layer* aAfter, Container* aContainer)
aContainer->mFirstChild->SetPrevSibling(aChild);
}
aContainer->mFirstChild = aChild;
NS_ADDREF(aChild);
aContainer->DidInsertChild(aChild);
return;
}
@ -266,8 +258,6 @@ ContainerInsertAfter(Layer* aChild, Layer* aAfter, Container* aContainer)
next->SetPrevSibling(aChild);
}
aAfter->SetNextSibling(aChild);
NS_ADDREF(aChild);
aContainer->DidInsertChild(aChild);
}
template<class Container>
@ -296,7 +286,6 @@ ContainerRemoveChild(Layer* aChild, Container* aContainer)
aChild->SetPrevSibling(nsnull);
aChild->SetParent(nsnull);
aContainer->DidRemoveChild(aChild);
NS_RELEASE(aChild);
}
@ -388,10 +377,9 @@ public:
mValidRegion.Sub(mValidRegion, aRegion);
}
virtual void PaintThebes(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData,
ReadbackProcessor* aReadback);
virtual void Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData);
virtual void ClearCachedResources() { mBuffer.Clear(); mValidRegion.SetEmpty(); }
@ -516,20 +504,14 @@ PushGroupForLayer(gfxContext* aContext, Layer* aLayer, const nsIntRegion& aRegio
}
void
BasicThebesLayer::PaintThebes(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData,
ReadbackProcessor* aReadback)
BasicThebesLayer::Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData)
{
NS_ASSERTION(BasicManager()->InDrawing(),
"Can only draw in drawing phase");
nsRefPtr<gfxASurface> targetSurface = aContext->CurrentSurface();
nsTArray<ReadbackProcessor::Update> readbackUpdates;
if (aReadback && UsedForReadback()) {
aReadback->GetThebesLayerUpdates(this, &readbackUpdates);
}
PRBool canUseOpaqueSurface = CanUseOpaqueSurface();
Buffer::ContentType contentType =
canUseOpaqueSurface ? gfxASurface::CONTENT_COLOR :
@ -540,8 +522,6 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
(!canUseOpaqueSurface &&
(mContentFlags & CONTENT_COMPONENT_ALPHA) &&
!MustRetainContent())) {
NS_ASSERTION(readbackUpdates.IsEmpty(), "Can't do readback for non-retained layer");
mValidRegion.SetEmpty();
mBuffer.Clear();
@ -604,20 +584,6 @@ BasicThebesLayer::PaintThebes(gfxContext* aContext,
}
mBuffer.DrawTo(this, aContext, opacity);
for (PRUint32 i = 0; i < readbackUpdates.Length(); ++i) {
ReadbackProcessor::Update& update = readbackUpdates[i];
nsIntPoint offset = update.mLayer->GetBackgroundLayerOffset();
nsRefPtr<gfxContext> ctx =
update.mLayer->GetSink()->BeginUpdate(update.mUpdateRect + offset,
update.mSequenceCounter);
if (ctx) {
NS_ASSERTION(opacity == 1.0, "Should only read back opaque layers");
ctx->Translate(gfxPoint(offset.x, offset.y));
mBuffer.DrawTo(this, ctx, 1.0);
update.mLayer->GetSink()->EndUpdate(ctx, update.mUpdateRect + offset);
}
}
}
static PRBool
@ -698,7 +664,9 @@ public:
ImageLayer::SetVisibleRegion(aRegion);
}
virtual void Paint(gfxContext* aContext);
virtual void Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData);
static void PaintContext(gfxPattern* aPattern,
const nsIntRegion& aVisible,
@ -720,7 +688,9 @@ protected:
};
void
BasicImageLayer::Paint(gfxContext* aContext)
BasicImageLayer::Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData)
{
nsRefPtr<gfxPattern> dontcare =
GetAndPaintCurrentImage(aContext, GetEffectiveOpacity());
@ -826,7 +796,9 @@ public:
ColorLayer::SetVisibleRegion(aRegion);
}
virtual void Paint(gfxContext* aContext)
virtual void Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData)
{
PaintColorTo(mColor, GetEffectiveOpacity(), aContext);
}
@ -872,7 +844,9 @@ public:
virtual void Initialize(const Data& aData);
virtual void Updated(const nsIntRect& aRect);
virtual void Paint(gfxContext* aContext);
virtual void Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData);
virtual void PaintWithOpacity(gfxContext* aContext,
float aOpacity);
@ -982,7 +956,9 @@ BasicCanvasLayer::Updated(const nsIntRect& aRect)
}
void
BasicCanvasLayer::Paint(gfxContext* aContext)
BasicCanvasLayer::Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData)
{
PaintWithOpacity(aContext, GetEffectiveOpacity());
}
@ -1019,34 +995,6 @@ BasicCanvasLayer::PaintWithOpacity(gfxContext* aContext,
mUpdatedRect.Empty();
}
class BasicReadbackLayer : public ReadbackLayer,
BasicImplData
{
public:
BasicReadbackLayer(BasicLayerManager* aLayerManager) :
ReadbackLayer(aLayerManager, static_cast<BasicImplData*>(this))
{
MOZ_COUNT_CTOR(BasicReadbackLayer);
}
virtual ~BasicReadbackLayer()
{
MOZ_COUNT_DTOR(BasicReadbackLayer);
}
virtual void SetVisibleRegion(const nsIntRegion& aRegion)
{
NS_ASSERTION(BasicManager()->InConstruction(),
"Can only set properties in construction phase");
ReadbackLayer::SetVisibleRegion(aRegion);
}
protected:
BasicLayerManager* BasicManager()
{
return static_cast<BasicLayerManager*>(mManager);
}
};
static nsIntRect
ToOutsideIntRect(const gfxRect &aRect)
{
@ -1349,7 +1297,7 @@ BasicLayerManager::EndTransactionInternal(DrawThebesLayerCallback aCallback,
MarkLeafLayersCoveredByOpaque(mRoot,
mRoot->GetEffectiveVisibleRegion().GetBounds(),
region);
PaintLayer(mRoot, aCallback, aCallbackData, nsnull);
PaintLayer(mRoot, aCallback, aCallbackData);
// If we're doing manual double-buffering, we need to avoid drawing
// the results of an incomplete transaction to the destination surface.
@ -1420,8 +1368,7 @@ BasicLayerManager::SetRoot(Layer* aLayer)
void
BasicLayerManager::PaintLayer(Layer* aLayer,
DrawThebesLayerCallback aCallback,
void* aCallbackData,
ReadbackProcessor* aReadback)
void* aCallbackData)
{
const nsIntRect* clipRect = aLayer->GetEffectiveClipRect();
const gfx3DMatrix& effectiveTransform = aLayer->GetEffectiveTransform();
@ -1483,21 +1430,11 @@ BasicLayerManager::PaintLayer(Layer* aLayer,
(void*)aLayer, data->IsCoveredByOpaque()));
#endif
if (!data->IsCoveredByOpaque()) {
if (aLayer->GetType() == Layer::TYPE_THEBES) {
data->PaintThebes(mTarget, aCallback, aCallbackData, aReadback);
} else {
data->Paint(mTarget);
}
data->Paint(mTarget, aCallback, aCallbackData);
}
} else {
ReadbackProcessor readback;
if (IsRetained()) {
ContainerLayer* container = static_cast<ContainerLayer*>(aLayer);
readback.BuildUpdates(container);
}
for (; child; child = child->GetNextSibling()) {
PaintLayer(child, aCallback, aCallbackData, &readback);
PaintLayer(child, aCallback, aCallbackData);
if (mTransactionIncomplete)
break;
}
@ -1581,13 +1518,6 @@ BasicLayerManager::CreateCanvasLayer()
return layer.forget();
}
already_AddRefed<ReadbackLayer>
BasicLayerManager::CreateReadbackLayer()
{
NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
nsRefPtr<ReadbackLayer> layer = new BasicReadbackLayer(this);
return layer.forget();
}
#ifdef MOZ_IPC
@ -1644,19 +1574,6 @@ ToShadowable(Layer* aLayer)
return ToData(aLayer)->AsShadowableLayer();
}
// Some layers, like ReadbackLayers, can't be shadowed and shadowing
// them doesn't make sense anyway
static bool
ShouldShadow(Layer* aLayer)
{
if (!ToShadowable(aLayer)) {
NS_ABORT_IF_FALSE(aLayer->GetType() == Layer::TYPE_READBACK,
"Only expect not to shadow ReadbackLayers");
return false;
}
return true;
}
template<class OpT>
static BasicShadowableLayer*
GetBasicShadowable(const OpT& op)
@ -1704,10 +1621,7 @@ private:
void
BasicShadowableContainerLayer::InsertAfter(Layer* aChild, Layer* aAfter)
{
if (HasShadow() && ShouldShadow(aChild)) {
while (aAfter && !ShouldShadow(aAfter)) {
aAfter = aAfter->GetPrevSibling();
}
if (HasShadow()) {
ShadowManager()->InsertAfter(ShadowManager()->Hold(this),
ShadowManager()->Hold(aChild),
aAfter ? ShadowManager()->Hold(aAfter) : nsnull);
@ -1718,7 +1632,7 @@ BasicShadowableContainerLayer::InsertAfter(Layer* aChild, Layer* aAfter)
void
BasicShadowableContainerLayer::RemoveChild(Layer* aChild)
{
if (HasShadow() && ShouldShadow(aChild)) {
if (HasShadow()) {
ShadowManager()->RemoveChild(ShadowManager()->Hold(this),
ShadowManager()->Hold(aChild));
}
@ -1942,7 +1856,9 @@ public:
MOZ_COUNT_DTOR(BasicShadowableImageLayer);
}
virtual void Paint(gfxContext* aContext);
virtual void Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData);
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
{
@ -1973,7 +1889,9 @@ private:
};
void
BasicShadowableImageLayer::Paint(gfxContext* aContext)
BasicShadowableImageLayer::Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData)
{
gfxIntSize oldSize = mSize;
nsRefPtr<gfxPattern> pat = GetAndPaintCurrentImage(aContext, GetEffectiveOpacity());
@ -2058,7 +1976,9 @@ public:
}
virtual void Initialize(const Data& aData);
virtual void Paint(gfxContext* aContext);
virtual void Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData);
virtual void FillSpecificAttributes(SpecificLayerAttributes& aAttrs)
{
@ -2119,9 +2039,11 @@ BasicShadowableCanvasLayer::Initialize(const Data& aData)
}
void
BasicShadowableCanvasLayer::Paint(gfxContext* aContext)
BasicShadowableCanvasLayer::Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData)
{
BasicCanvasLayer::Paint(aContext);
BasicCanvasLayer::Paint(aContext, aCallback, aCallbackData);
if (!HasShadow())
return;
@ -2244,10 +2166,9 @@ public:
}
}
virtual void PaintThebes(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData,
ReadbackProcessor* aReadback);
virtual void Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData);
private:
BasicShadowLayerManager* BasicManager()
@ -2339,10 +2260,9 @@ BasicShadowThebesLayer::Swap(const ThebesBuffer& aNewFront,
}
void
BasicShadowThebesLayer::PaintThebes(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData,
ReadbackProcessor* aReadback)
BasicShadowThebesLayer::Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData)
{
NS_ASSERTION(BasicManager()->InDrawing(),
"Can only draw in drawing phase");
@ -2436,7 +2356,9 @@ public:
mFrontSurface = nsnull;
}
virtual void Paint(gfxContext* aContext);
virtual void Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData);
protected:
BasicShadowLayerManager* BasicManager()
@ -2467,7 +2389,9 @@ BasicShadowImageLayer::Swap(gfxSharedImageSurface* newFront)
}
void
BasicShadowImageLayer::Paint(gfxContext* aContext)
BasicShadowImageLayer::Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData)
{
if (!mFrontSurface) {
return;
@ -2493,7 +2417,9 @@ public:
MOZ_COUNT_DTOR(BasicShadowColorLayer);
}
virtual void Paint(gfxContext* aContext)
virtual void Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData)
{
BasicColorLayer::PaintColorTo(mColor, GetEffectiveOpacity(), aContext);
}
@ -2535,7 +2461,9 @@ public:
mFrontSurface = nsnull;
}
virtual void Paint(gfxContext* aContext);
virtual void Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData);
private:
BasicShadowLayerManager* BasicManager()
@ -2567,7 +2495,9 @@ BasicShadowCanvasLayer::Swap(gfxSharedImageSurface* newFront)
}
void
BasicShadowCanvasLayer::Paint(gfxContext* aContext)
BasicShadowCanvasLayer::Paint(gfxContext* aContext,
LayerManager::DrawThebesLayerCallback aCallback,
void* aCallbackData)
{
NS_ASSERTION(BasicManager()->InDrawing(),
"Can only draw in drawing phase");
@ -2738,7 +2668,7 @@ BasicShadowLayerManager::Mutated(Layer* aLayer)
BasicLayerManager::Mutated(aLayer);
NS_ASSERTION(InConstruction() || InDrawing(), "wrong phase");
if (HasShadowManager() && ShouldShadow(aLayer)) {
if (HasShadowManager()) {
ShadowLayerForwarder::Mutated(Hold(aLayer));
}
}

Просмотреть файл

@ -60,7 +60,6 @@ class ShadowContainerLayer;
class ShadowImageLayer;
class ShadowCanvasLayer;
class ShadowColorLayer;
class ReadbackProcessor;
/**
* This is a cairo/Thebes-only, main-thread-only implementation of layers.
@ -153,17 +152,16 @@ public:
virtual already_AddRefed<CanvasLayer> CreateCanvasLayer();
virtual already_AddRefed<ImageContainer> CreateImageContainer();
virtual already_AddRefed<ColorLayer> CreateColorLayer();
virtual already_AddRefed<ReadbackLayer> CreateReadbackLayer();
virtual already_AddRefed<ShadowThebesLayer> CreateShadowThebesLayer()
{ return nsnull; }
{ return NULL; }
virtual already_AddRefed<ShadowContainerLayer> CreateShadowContainerLayer()
{ return nsnull; }
{ return NULL; }
virtual already_AddRefed<ShadowImageLayer> CreateShadowImageLayer()
{ return nsnull; }
{ return NULL; }
virtual already_AddRefed<ShadowColorLayer> CreateShadowColorLayer()
{ return nsnull; }
{ return NULL; }
virtual already_AddRefed<ShadowCanvasLayer> CreateShadowCanvasLayer()
{ return nsnull; }
{ return NULL; }
virtual LayersBackend GetBackendType() { return LAYERS_BASIC; }
virtual void GetBackendName(nsAString& name) { name.AssignLiteral("Basic"); }
@ -199,8 +197,7 @@ protected:
// Paints aLayer to mTarget.
void PaintLayer(Layer* aLayer,
DrawThebesLayerCallback aCallback,
void* aCallbackData,
ReadbackProcessor* aReadback);
void* aCallbackData);
// Clear the contents of a layer
void ClearLayer(Layer* aLayer);

Просмотреть файл

@ -36,8 +36,8 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef GFX_CANVASLAYERD3D10_H
#define GFX_CANVASLAYERD3D10_H
#ifndef GFX_CANVASLAYEROGL_H
#define GFX_CANVASLAYEROGL_H
#include "LayerManagerD3D10.h"
#include "GLContext.h"

Просмотреть файл

@ -40,9 +40,6 @@
#include "gfxUtils.h"
#include "nsRect.h"
#include "ThebesLayerD3D10.h"
#include "ReadbackProcessor.h"
namespace mozilla {
namespace layers {
@ -75,7 +72,6 @@ ContainerLayerD3D10::InsertAfter(Layer* aChild, Layer* aAfter)
mLastChild = aChild;
}
NS_ADDREF(aChild);
DidInsertChild(aChild);
return;
}
for (Layer *child = GetFirstChild();
@ -91,7 +87,6 @@ ContainerLayerD3D10::InsertAfter(Layer* aChild, Layer* aAfter)
}
aChild->SetPrevSibling(child);
NS_ADDREF(aChild);
DidInsertChild(aChild);
return;
}
}
@ -111,7 +106,6 @@ ContainerLayerD3D10::RemoveChild(Layer *aChild)
aChild->SetNextSibling(nsnull);
aChild->SetPrevSibling(nsnull);
aChild->SetParent(nsnull);
DidRemoveChild(aChild);
NS_RELEASE(aChild);
return;
}
@ -129,7 +123,6 @@ ContainerLayerD3D10::RemoveChild(Layer *aChild)
child->SetNextSibling(nsnull);
child->SetPrevSibling(nsnull);
child->SetParent(nsnull);
DidRemoveChild(aChild);
NS_RELEASE(aChild);
return;
}
@ -405,16 +398,9 @@ ContainerLayerD3D10::Validate()
(mParent && mParent->SupportsComponentAlphaChildren());
}
ReadbackProcessor readback;
readback.BuildUpdates(this);
Layer *layer = GetFirstChild();
while (layer) {
if (layer->GetType() == TYPE_THEBES) {
static_cast<ThebesLayerD3D10*>(layer)->Validate(&readback);
} else {
static_cast<LayerD3D10*>(layer->ImplData())->Validate();
}
static_cast<LayerD3D10*>(layer->ImplData())->Validate();
layer = layer->GetNextSibling();
}
}

Просмотреть файл

@ -39,7 +39,6 @@
#include "LayerManagerD3D10Effect.h"
#include "gfxWindowsPlatform.h"
#include "gfxD2DSurface.h"
#include "gfxFailure.h"
#include "cairo-win32.h"
#include "dxgi.h"
@ -47,7 +46,6 @@
#include "ThebesLayerD3D10.h"
#include "ColorLayerD3D10.h"
#include "CanvasLayerD3D10.h"
#include "ReadbackLayerD3D10.h"
#include "ImageLayerD3D10.h"
#include "../d3d9/Nv3DVUtils.h"
@ -69,12 +67,15 @@ struct Vertex
float position[2];
};
// {592BF306-0EED-4F76-9D03-A0846450F472}
static const GUID sDeviceAttachments =
{ 0x592bf306, 0xeed, 0x4f76, { 0x9d, 0x3, 0xa0, 0x84, 0x64, 0x50, 0xf4, 0x72 } };
// {716AEDB1-C9C3-4B4D-8332-6F65D44AF6A8}
static const GUID sLayerManagerCount =
{ 0x716aedb1, 0xc9c3, 0x4b4d, { 0x83, 0x32, 0x6f, 0x65, 0xd4, 0x4a, 0xf6, 0xa8 } };
// {17F88CCB-1F49-4c08-8002-ADA7BD44856D}
static const GUID sEffect =
{ 0x17f88ccb, 0x1f49, 0x4c08, { 0x80, 0x2, 0xad, 0xa7, 0xbd, 0x44, 0x85, 0x6d } };
// {19599D91-912C-4C2F-A8C5-299DE85FBD34}
static const GUID sInputLayout =
{ 0x19599d91, 0x912c, 0x4c2f, { 0xa8, 0xc5, 0x29, 0x9d, 0xe8, 0x5f, 0xbd, 0x34 } };
// {293157D2-09C7-4680-AE27-C28E370E418B}
static const GUID sVertexBuffer =
{ 0x293157d2, 0x9c7, 0x4680, { 0xae, 0x27, 0xc2, 0x8e, 0x37, 0xe, 0x41, 0x8b } };
cairo_user_data_key_t gKeyD3D10Texture;
@ -83,36 +84,8 @@ LayerManagerD3D10::LayerManagerD3D10(nsIWidget *aWidget)
{
}
struct DeviceAttachments
{
nsRefPtr<ID3D10Effect> mEffect;
nsRefPtr<ID3D10InputLayout> mInputLayout;
nsRefPtr<ID3D10Buffer> mVertexBuffer;
nsRefPtr<ReadbackManagerD3D10> mReadbackManager;
};
LayerManagerD3D10::~LayerManagerD3D10()
{
if (mDevice) {
int referenceCount = 0;
UINT size = sizeof(referenceCount);
HRESULT hr = mDevice->GetPrivateData(sLayerManagerCount, &size, &referenceCount);
NS_ASSERTION(SUCCEEDED(hr), "Reference count not found on device.");
referenceCount--;
mDevice->SetPrivateData(sLayerManagerCount, sizeof(referenceCount), &referenceCount);
if (!referenceCount) {
DeviceAttachments *attachments;
size = sizeof(attachments);
mDevice->GetPrivateData(sDeviceAttachments, &size, &attachments);
// No LayerManagers left for this device. Clear out interfaces stored which
// hold a reference to the device.
mDevice->SetPrivateData(sDeviceAttachments, 0, NULL);
delete attachments;
}
}
Destroy();
}
@ -156,19 +129,8 @@ LayerManagerD3D10::Initialize()
mNv3DVUtils->SetDeviceInfo(devUnknown);
}
int referenceCount = 0;
UINT size = sizeof(referenceCount);
// If this isn't there yet it'll fail, count will remain 0, which is correct.
mDevice->GetPrivateData(sLayerManagerCount, &size, &referenceCount);
referenceCount++;
mDevice->SetPrivateData(sLayerManagerCount, sizeof(referenceCount), &referenceCount);
DeviceAttachments *attachments;
size = sizeof(DeviceAttachments*);
if (FAILED(mDevice->GetPrivateData(sDeviceAttachments, &size, &attachments))) {
attachments = new DeviceAttachments;
mDevice->SetPrivateData(sDeviceAttachments, sizeof(attachments), &attachments);
UINT size = sizeof(ID3D10Effect*);
if (FAILED(mDevice->GetPrivateData(sEffect, &size, mEffect.StartAssignment()))) {
D3D10CreateEffectFromMemoryFunc createEffect = (D3D10CreateEffectFromMemoryFunc)
GetProcAddress(LoadLibraryA("d3d10_1.dll"), "D3D10CreateEffectFromMemory");
@ -187,8 +149,11 @@ LayerManagerD3D10::Initialize()
return false;
}
attachments->mEffect = mEffect;
mDevice->SetPrivateDataInterface(sEffect, mEffect);
}
size = sizeof(ID3D10InputLayout*);
if (FAILED(mDevice->GetPrivateData(sInputLayout, &size, mInputLayout.StartAssignment()))) {
D3D10_INPUT_ELEMENT_DESC layout[] =
{
{ "POSITION", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 0, D3D10_INPUT_PER_VERTEX_DATA, 0 },
@ -207,8 +172,11 @@ LayerManagerD3D10::Initialize()
return false;
}
attachments->mInputLayout = mInputLayout;
mDevice->SetPrivateDataInterface(sInputLayout, mInputLayout);
}
size = sizeof(ID3D10Buffer*);
if (FAILED(mDevice->GetPrivateData(sVertexBuffer, &size, mVertexBuffer.StartAssignment()))) {
Vertex vertices[] = { {0.0, 0.0}, {1.0, 0.0}, {0.0, 1.0}, {1.0, 1.0} };
CD3D10_BUFFER_DESC bufferDesc(sizeof(vertices), D3D10_BIND_VERTEX_BUFFER);
D3D10_SUBRESOURCE_DATA data;
@ -220,11 +188,7 @@ LayerManagerD3D10::Initialize()
return false;
}
attachments->mVertexBuffer = mVertexBuffer;
} else {
mEffect = attachments->mEffect;
mVertexBuffer = attachments->mVertexBuffer;
mInputLayout = attachments->mInputLayout;
mDevice->SetPrivateDataInterface(sVertexBuffer, mVertexBuffer);
}
nsRefPtr<IDXGIDevice> dxgiDevice;
@ -369,13 +333,6 @@ LayerManagerD3D10::CreateCanvasLayer()
return layer.forget();
}
already_AddRefed<ReadbackLayer>
LayerManagerD3D10::CreateReadbackLayer()
{
nsRefPtr<ReadbackLayer> layer = new ReadbackLayerD3D10(this);
return layer.forget();
}
already_AddRefed<ImageContainer>
LayerManagerD3D10::CreateImageContainer()
{
@ -425,13 +382,6 @@ LayerManagerD3D10::CreateOptimalSurface(const gfxIntSize &aSize,
return surface.forget();
}
ReadbackManagerD3D10*
LayerManagerD3D10::readbackManager()
{
EnsureReadbackManager();
return mReadbackManager;
}
void
LayerManagerD3D10::SetViewport(const nsIntSize &aViewport)
{
@ -545,32 +495,6 @@ LayerManagerD3D10::VerifyBufferSize()
}
void
LayerManagerD3D10::EnsureReadbackManager()
{
if (mReadbackManager) {
return;
}
DeviceAttachments *attachments;
UINT size = sizeof(DeviceAttachments*);
if (FAILED(mDevice->GetPrivateData(sDeviceAttachments, &size, &attachments))) {
// Strange! This shouldn't happen ... return a readback manager for this
// layer manager only.
mReadbackManager = new ReadbackManagerD3D10();
gfx::LogFailure(NS_LITERAL_CSTRING("Couldn't get device attachments for device."));
return;
}
if (attachments->mReadbackManager) {
mReadbackManager = attachments->mReadbackManager;
return;
}
mReadbackManager = new ReadbackManagerD3D10();
attachments->mReadbackManager = mReadbackManager;
}
void
LayerManagerD3D10::Render()
{

Просмотреть файл

@ -46,8 +46,6 @@
#include "gfxContext.h"
#include "nsIWidget.h"
#include "ReadbackManagerD3D10.h"
namespace mozilla {
namespace layers {
@ -125,8 +123,6 @@ public:
virtual already_AddRefed<CanvasLayer> CreateCanvasLayer();
virtual already_AddRefed<ReadbackLayer> CreateReadbackLayer();
virtual already_AddRefed<ImageContainer> CreateImageContainer();
virtual already_AddRefed<gfxASurface>
@ -146,8 +142,6 @@ public:
ID3D10Effect *effect() const { return mEffect; }
ReadbackManagerD3D10 *readbackManager();
void SetViewport(const nsIntSize &aViewport);
const nsIntSize &GetViewport() { return mViewport; }
@ -162,7 +156,6 @@ private:
void SetupPipeline();
void UpdateRenderTarget();
void VerifyBufferSize();
void EnsureReadbackManager();
void Render();
@ -171,7 +164,6 @@ private:
nsRefPtr<ID3D10Effect> mEffect;
nsRefPtr<ID3D10InputLayout> mInputLayout;
nsRefPtr<ID3D10Buffer> mVertexBuffer;
nsRefPtr<ReadbackManagerD3D10> mReadbackManager;
nsRefPtr<ID3D10RenderTargetView> mRTView;

Просмотреть файл

@ -1,65 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bas Schouten <bschouten@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef GFX_READBACKLAYERD3D10_H
#define GFX_READBACKLAYERD3D10_H
#include "LayerManagerD3D10.h"
#include "ReadbackLayer.h"
namespace mozilla {
namespace layers {
class THEBES_API ReadbackLayerD3D10 :
public ReadbackLayer,
public LayerD3D10
{
public:
ReadbackLayerD3D10(LayerManagerD3D10 *aManager)
: ReadbackLayer(aManager, NULL),
LayerD3D10(aManager)
{
mImplData = static_cast<LayerD3D10*>(this);
}
virtual Layer* GetLayer() { return this; }
virtual void RenderLayer() {}
};
} /* layers */
} /* mozilla */
#endif /* GFX_READBACKLAYERD3D10_H */

Просмотреть файл

@ -1,250 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bas Schouten <bschouten@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "ReadbackManagerD3D10.h"
#include "ReadbackProcessor.h"
#include "nsIThread.h"
#include "nsThreadUtils.h"
#include "gfxImageSurface.h"
namespace mozilla {
namespace layers {
// Structure that contains the information required to execute a readback task,
// the only member accessed off the main thread here is mReadbackTexture. Since
// mLayer may be released only on the main thread this object should always be
// destroyed on the main thread!
struct ReadbackTask {
// The texture that we copied the contents of the thebeslayer to.
nsRefPtr<ID3D10Texture2D> mReadbackTexture;
// This exists purely to keep the ReadbackLayer alive for the lifetime of
// mUpdate. Note that this addref and release should occur -solely- on the
// main thread.
nsRefPtr<ReadbackLayer> mLayer;
ReadbackProcessor::Update mUpdate;
// The origin in ThebesLayer coordinates of mReadbackTexture.
gfxPoint mOrigin;
// mLayer->GetBackgroundOffset() when the task is created. We have
// to save this in the ReadbackTask because it might change before
// the update is delivered to the readback sink.
nsIntPoint mBackgroundOffset;
};
// This class is created and dispatched from the Readback thread but it must be
// destroyed by the main thread.
class ReadbackResultWriter : public nsIRunnable
{
NS_DECL_ISUPPORTS
public:
ReadbackResultWriter(ReadbackTask *aTask) : mTask(aTask) {}
NS_IMETHODIMP Run()
{
ReadbackProcessor::Update *update = &mTask->mUpdate;
if (!update->mLayer->GetSink()) {
// This can happen when a plugin is destroyed.
return NS_OK;
}
nsIntPoint offset = mTask->mBackgroundOffset;
D3D10_TEXTURE2D_DESC desc;
mTask->mReadbackTexture->GetDesc(&desc);
D3D10_MAPPED_TEXTURE2D mappedTex;
// We know this map will immediately succeed, as we've already mapped this
// copied data on our task thread.
HRESULT hr = mTask->mReadbackTexture->Map(0, D3D10_MAP_READ, 0, &mappedTex);
if (FAILED(hr)) {
// If this fails we're never going to get our ThebesLayer content.
update->mLayer->GetSink()->SetUnknown(update->mSequenceCounter);
return NS_OK;
}
nsRefPtr<gfxImageSurface> sourceSurface =
new gfxImageSurface((unsigned char*)mappedTex.pData,
gfxIntSize(desc.Width, desc.Height),
mappedTex.RowPitch,
gfxASurface::ImageFormatRGB24);
nsRefPtr<gfxContext> ctx =
update->mLayer->GetSink()->BeginUpdate(update->mUpdateRect + offset,
update->mSequenceCounter);
if (ctx) {
ctx->Translate(gfxPoint(offset.x, offset.y));
ctx->SetSource(sourceSurface, gfxPoint(mTask->mOrigin.x,
mTask->mOrigin.y));
ctx->Paint();
update->mLayer->GetSink()->EndUpdate(ctx, update->mUpdateRect + offset);
}
mTask->mReadbackTexture->Unmap(0);
return NS_OK;
}
private:
nsAutoPtr<ReadbackTask> mTask;
};
NS_IMPL_THREADSAFE_ISUPPORTS1(ReadbackResultWriter, nsIRunnable)
DWORD WINAPI StartTaskThread(void *aManager)
{
static_cast<ReadbackManagerD3D10*>(aManager)->ProcessTasks();
return 0;
}
ReadbackManagerD3D10::ReadbackManagerD3D10()
: mRefCnt(0)
{
::InitializeCriticalSection(&mTaskMutex);
mShutdownEvent = ::CreateEventA(NULL, FALSE, FALSE, "ReadbackShutdownEvent");
mTaskSemaphore = ::CreateSemaphoreA(NULL, 0, 1000000, "ReadbackTaskSemaphore");
mTaskThread = ::CreateThread(NULL, 0, StartTaskThread, this, 0, 0);
}
ReadbackManagerD3D10::~ReadbackManagerD3D10()
{
::SetEvent(mShutdownEvent);
// This shouldn't take longer than 5 seconds, if it does we're going to choose
// to leak the thread and its synchronisation in favor of crashing or freezing
DWORD result = ::WaitForSingleObject(mTaskThread, 5000);
if (result != WAIT_TIMEOUT) {
::DeleteCriticalSection(&mTaskMutex);
::CloseHandle(mShutdownEvent);
::CloseHandle(mTaskSemaphore);
::CloseHandle(mTaskThread);
} else {
NS_WARNING("ReadbackManager: Task thread did not shutdown in 5 seconds. Leaking.");
}
}
void
ReadbackManagerD3D10::PostTask(ID3D10Texture2D *aTexture, void *aUpdate, const gfxPoint &aOrigin)
{
ReadbackTask *task = new ReadbackTask;
task->mReadbackTexture = aTexture;
task->mUpdate = *static_cast<ReadbackProcessor::Update*>(aUpdate);
task->mOrigin = aOrigin;
task->mLayer = task->mUpdate.mLayer;
task->mBackgroundOffset = task->mLayer->GetBackgroundLayerOffset();
::EnterCriticalSection(&mTaskMutex);
mPendingReadbackTasks.AppendElement(task);
::LeaveCriticalSection(&mTaskMutex);
::ReleaseSemaphore(mTaskSemaphore, 1, NULL);
}
HRESULT
ReadbackManagerD3D10::QueryInterface(REFIID riid, void **ppvObject)
{
if (!ppvObject) {
return E_POINTER;
}
if (riid == IID_IUnknown) {
*ppvObject = this;
} else {
return E_NOINTERFACE;
}
return S_OK;
}
ULONG
ReadbackManagerD3D10::AddRef()
{
NS_ASSERTION(NS_IsMainThread(),
"ReadbackManagerD3D10 should only be refcounted on main thread.");
return ++mRefCnt;
}
ULONG
ReadbackManagerD3D10::Release()
{
NS_ASSERTION(NS_IsMainThread(),
"ReadbackManagerD3D10 should only be refcounted on main thread.");
ULONG newRefCnt = --mRefCnt;
if (!newRefCnt) {
mRefCnt++;
delete this;
}
return newRefCnt;
}
void
ReadbackManagerD3D10::ProcessTasks()
{
HANDLE handles[] = { mTaskSemaphore, mShutdownEvent };
while (true) {
DWORD result = ::WaitForMultipleObjects(2, handles, FALSE, INFINITE);
if (result != WAIT_OBJECT_0) {
return;
}
::EnterCriticalSection(&mTaskMutex);
ReadbackTask *nextReadbackTask = mPendingReadbackTasks[0].forget();
mPendingReadbackTasks.RemoveElementAt(0);
::LeaveCriticalSection(&mTaskMutex);
// We want to block here until the texture contents are available, the
// easiest thing is to simply map and unmap.
D3D10_MAPPED_TEXTURE2D mappedTex;
nextReadbackTask->mReadbackTexture->Map(0, D3D10_MAP_READ, 0, &mappedTex);
nextReadbackTask->mReadbackTexture->Unmap(0);
// We can only send the update to the sink on the main thread, so post an
// event there to do so. Ownership of the task is passed from
// mPendingReadbackTasks to ReadbackResultWriter here.
nsCOMPtr<nsIThread> thread = do_GetMainThread();
thread->Dispatch(new ReadbackResultWriter(nextReadbackTask),
nsIEventTarget::DISPATCH_NORMAL);
}
}
}
}

Просмотреть файл

@ -1,107 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2009
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Bas Schouten <bschouten@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef GFX_READBACKMANAGERD3D10_H
#define GFX_READBACKMANAGERD3D10_H
#include <windows.h>
#include <d3d10_1.h>
#include "nsTArray.h"
#include "nsAutoPtr.h"
#include "gfxPoint.h"
namespace mozilla {
namespace layers {
DWORD WINAPI StartTaskThread(void *aManager);
struct ReadbackTask;
class ReadbackManagerD3D10 : public IUnknown
{
public:
ReadbackManagerD3D10();
~ReadbackManagerD3D10();
/**
* Tell the readback manager to post a readback task.
*
* @param aTexture D3D10_USAGE_STAGING texture that will contain the data that
* was readback.
* @param aUpdate ReadbackProcessor::Update object. This is a void pointer
* since we cannot forward declare a nested class, and do not
* export ReadbackProcessor.h
* @param aOrigin Origin of the aTexture surface in the ThebesLayer
* coordinate system.
*/
void PostTask(ID3D10Texture2D *aTexture, void *aUpdate, const gfxPoint &aOrigin);
virtual HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid,
void **ppvObject);
virtual ULONG STDMETHODCALLTYPE AddRef(void);
virtual ULONG STDMETHODCALLTYPE Release(void);
private:
friend DWORD WINAPI StartTaskThread(void *aManager);
void ProcessTasks();
// The invariant maintained by |mTaskSemaphore| is that the readback thread
// will awaken from WaitForMultipleObjects() at least once per readback
// task enqueued by the main thread. Since the readback thread processes
// exactly one task per wakeup (with one exception), no tasks are lost. The
// exception is when the readback thread is shut down, which orphans the
// remaining tasks, on purpose.
HANDLE mTaskSemaphore;
// Event signaled when the task thread should shutdown
HANDLE mShutdownEvent;
// Handle to the task thread
HANDLE mTaskThread;
// FiFo list of readback tasks that are to be executed. Access is synchronized
// by mTaskMutex.
CRITICAL_SECTION mTaskMutex;
nsTArray<nsAutoPtr<ReadbackTask>> mPendingReadbackTasks;
ULONG mRefCnt;
};
}
}
#endif /* GFX_READBACKMANAGERD3D10_H */

Просмотреть файл

@ -45,8 +45,6 @@
#include "gfxTeeSurface.h"
#include "gfxUtils.h"
#include "ReadbackLayer.h"
#include "ReadbackProcessor.h"
namespace mozilla {
namespace layers {
@ -170,7 +168,7 @@ ThebesLayerD3D10::RenderLayer()
}
void
ThebesLayerD3D10::Validate(ReadbackProcessor *aReadback)
ThebesLayerD3D10::Validate()
{
if (mVisibleRegion.IsEmpty()) {
return;
@ -193,12 +191,6 @@ ThebesLayerD3D10::Validate(ReadbackProcessor *aReadback)
mTextureOnWhite = nsnull;
}
nsTArray<ReadbackProcessor::Update> readbackUpdates;
nsIntRegion readbackRegion;
if (aReadback && UsedForReadback()) {
aReadback->GetThebesLayerUpdates(this, &readbackUpdates, &readbackRegion);
}
nsIntRect visibleRect = mVisibleRegion.GetBounds();
if (mTexture) {
@ -272,23 +264,6 @@ ThebesLayerD3D10::Validate(ReadbackProcessor *aReadback)
DrawRegion(region, mode);
if (readbackUpdates.Length() > 0) {
CD3D10_TEXTURE2D_DESC desc(DXGI_FORMAT_B8G8R8A8_UNORM,
visibleRect.width, visibleRect.height,
1, 1, 0, D3D10_USAGE_STAGING,
D3D10_CPU_ACCESS_READ);
nsRefPtr<ID3D10Texture2D> readbackTexture;
device()->CreateTexture2D(&desc, NULL, getter_AddRefs(readbackTexture));
device()->CopyResource(readbackTexture, mTexture);
for (int i = 0; i < readbackUpdates.Length(); i++) {
mD3DManager->readbackManager()->PostTask(readbackTexture,
&readbackUpdates[i],
gfxPoint(visibleRect.x, visibleRect.y));
}
}
mValidRegion = mVisibleRegion;
}
}

Просмотреть файл

@ -51,15 +51,13 @@ public:
ThebesLayerD3D10(LayerManagerD3D10 *aManager);
virtual ~ThebesLayerD3D10();
void Validate(ReadbackProcessor *aReadback);
/* ThebesLayer implementation */
void InvalidateRegion(const nsIntRegion& aRegion);
/* LayerD3D10 implementation */
virtual Layer* GetLayer();
virtual void RenderLayer();
virtual void Validate() { Validate(nsnull); }
virtual void Validate();
virtual void LayerManagerDestroyed();
private:

Просмотреть файл

@ -36,8 +36,8 @@
*
* ***** END LICENSE BLOCK ***** */
#ifndef GFX_CANVASLAYERD3D9_H
#define GFX_CANVASLAYERD3D9_H
#ifndef GFX_CANVASLAYEROGL_H
#define GFX_CANVASLAYEROGL_H
#include "LayerManagerD3D9.h"
#include "GLContext.h"

Просмотреть файл

@ -38,8 +38,6 @@
#include "ContainerLayerD3D9.h"
#include "gfxUtils.h"
#include "nsRect.h"
#include "ThebesLayerD3D9.h"
#include "ReadbackProcessor.h"
namespace mozilla {
namespace layers {
@ -73,7 +71,6 @@ ContainerLayerD3D9::InsertAfter(Layer* aChild, Layer* aAfter)
mLastChild = aChild;
}
NS_ADDREF(aChild);
DidInsertChild(aChild);
return;
}
for (Layer *child = GetFirstChild();
@ -89,7 +86,6 @@ ContainerLayerD3D9::InsertAfter(Layer* aChild, Layer* aAfter)
}
aChild->SetPrevSibling(child);
NS_ADDREF(aChild);
DidInsertChild(aChild);
return;
}
}
@ -109,7 +105,6 @@ ContainerLayerD3D9::RemoveChild(Layer *aChild)
aChild->SetNextSibling(nsnull);
aChild->SetPrevSibling(nsnull);
aChild->SetParent(nsnull);
DidRemoveChild(aChild);
NS_RELEASE(aChild);
return;
}
@ -127,7 +122,6 @@ ContainerLayerD3D9::RemoveChild(Layer *aChild)
child->SetNextSibling(nsnull);
child->SetPrevSibling(nsnull);
child->SetParent(nsnull);
DidRemoveChild(aChild);
NS_RELEASE(aChild);
return;
}
@ -181,9 +175,6 @@ ContainerLayerD3D9::RenderLayer()
device()->GetScissorRect(&containerClipRect);
ReadbackProcessor readback;
readback.BuildUpdates(this);
nsIntRect visibleRect = mVisibleRegion.GetBounds();
PRBool useIntermediate = UseIntermediateSurface();
@ -324,11 +315,7 @@ ContainerLayerD3D9::RenderLayer()
device()->SetScissorRect(&r);
}
if (layerToRender->GetLayer()->GetType() == TYPE_THEBES) {
static_cast<ThebesLayerD3D9*>(layerToRender)->RenderThebesLayer(&readback);
} else {
layerToRender->RenderLayer();
}
layerToRender->RenderLayer();
if (clipRect && !useIntermediate) {
// In this situation we've set a new scissor rect and we will continue

Просмотреть файл

@ -42,7 +42,6 @@
#include "ImageLayerD3D9.h"
#include "ColorLayerD3D9.h"
#include "CanvasLayerD3D9.h"
#include "ReadbackLayerD3D9.h"
#include "gfxWindowsPlatform.h"
#include "nsIGfxInfo.h"
#include "nsServiceManagerUtils.h"
@ -229,13 +228,6 @@ LayerManagerD3D9::CreateCanvasLayer()
return layer.forget();
}
already_AddRefed<ReadbackLayer>
LayerManagerD3D9::CreateReadbackLayer()
{
nsRefPtr<ReadbackLayer> layer = new ReadbackLayerD3D9(this);
return layer.forget();
}
already_AddRefed<ImageContainer>
LayerManagerD3D9::CreateImageContainer()
{

Просмотреть файл

@ -149,8 +149,6 @@ public:
virtual already_AddRefed<CanvasLayer> CreateCanvasLayer();
virtual already_AddRefed<ReadbackLayer> CreateReadbackLayer();
virtual already_AddRefed<ImageContainer> CreateImageContainer();
virtual LayersBackend GetBackendType() { return LAYERS_D3D9; }

Просмотреть файл

@ -1,65 +0,0 @@
/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Corporation code.
*
* The Initial Developer of the Original Code is Mozilla Foundation.
* Portions created by the Initial Developer are Copyright (C) 2011
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Robert O'Callahan <rocallahan@mozilla.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef GFX_READBACKLAYERD3D9_H
#define GFX_READBACKLAYERD3D9_H
#include "LayerManagerD3D9.h"
#include "ReadbackLayer.h"
namespace mozilla {
namespace layers {
class THEBES_API ReadbackLayerD3D9 :
public ReadbackLayer,
public LayerD3D9
{
public:
ReadbackLayerD3D9(LayerManagerD3D9 *aManager)
: ReadbackLayer(aManager, NULL),
LayerD3D9(aManager)
{
mImplData = static_cast<LayerD3D9*>(this);
}
virtual Layer* GetLayer() { return this; }
virtual void RenderLayer() {}
};
} /* layers */
} /* mozilla */
#endif /* GFX_READBACKLAYERD3D9_H */

Просмотреть файл

@ -41,7 +41,6 @@
#include "gfxWindowsPlatform.h"
#include "gfxTeeSurface.h"
#include "gfxUtils.h"
#include "ReadbackProcessor.h"
namespace mozilla {
namespace layers {
@ -202,7 +201,7 @@ ThebesLayerD3D9::RenderVisibleRegion()
}
void
ThebesLayerD3D9::RenderThebesLayer(ReadbackProcessor* aReadback)
ThebesLayerD3D9::RenderLayer()
{
if (mVisibleRegion.IsEmpty()) {
return;
@ -220,30 +219,22 @@ ThebesLayerD3D9::RenderThebesLayer(ReadbackProcessor* aReadback)
return;
}
nsTArray<ReadbackProcessor::Update> readbackUpdates;
nsIntRegion readbackRegion;
if (aReadback && UsedForReadback()) {
aReadback->GetThebesLayerUpdates(this, &readbackUpdates, &readbackRegion);
}
// Because updates to D3D9 ThebesLayers are rendered with the CPU, we don't
// have to do readback from D3D9 surfaces. Instead we make sure that any area
// needed for readback is included in the drawRegion we ask layout to render.
// Then the readback areas we need can be copied out of the temporary
// destinationSurface in DrawRegion.
nsIntRegion drawRegion;
drawRegion.Sub(mVisibleRegion, mValidRegion);
drawRegion.Or(drawRegion, readbackRegion);
// NS_ASSERTION(mVisibleRegion.Contains(region), "Bad readback region!");
if (!drawRegion.IsEmpty()) {
if (!mValidRegion.IsEqual(mVisibleRegion)) {
LayerManagerD3D9::CallbackInfo cbInfo = mD3DManager->GetCallbackInfo();
if (!cbInfo.Callback) {
NS_ERROR("D3D9 should never need to update ThebesLayers in an empty transaction");
return;
}
DrawRegion(drawRegion, mode, readbackUpdates);
/* We use the bounds of the visible region because we draw the bounds of
* this region when we draw this entire texture. We have to make sure that
* the areas that aren't filled with content get their background drawn.
* This is an issue for opaque surfaces, which otherwise won't get their
* background painted.
*/
nsIntRegion region;
region.Sub(mVisibleRegion, mValidRegion);
DrawRegion(region, mode);
mValidRegion = mVisibleRegion;
}
@ -416,8 +407,7 @@ FillSurface(gfxASurface* aSurface, const nsIntRegion& aRegion,
}
void
ThebesLayerD3D9::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode,
const nsTArray<ReadbackProcessor::Update>& aReadbackUpdates)
ThebesLayerD3D9::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode)
{
HRESULT hr;
nsIntRect visibleRect = mVisibleRegion.GetBounds();
@ -490,22 +480,6 @@ ThebesLayerD3D9::DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode,
LayerManagerD3D9::CallbackInfo cbInfo = mD3DManager->GetCallbackInfo();
cbInfo.Callback(this, context, aRegion, nsIntRegion(), cbInfo.CallbackData);
for (PRUint32 i = 0; i < aReadbackUpdates.Length(); ++i) {
NS_ASSERTION(aMode == SURFACE_OPAQUE,
"Transparent surfaces should not be used for readback");
const ReadbackProcessor::Update& update = aReadbackUpdates[i];
nsIntPoint offset = update.mLayer->GetBackgroundLayerOffset();
nsRefPtr<gfxContext> ctx =
update.mLayer->GetSink()->BeginUpdate(update.mUpdateRect + offset,
update.mSequenceCounter);
if (ctx) {
ctx->Translate(gfxPoint(offset.x, offset.y));
ctx->SetSource(destinationSurface, gfxPoint(bounds.x, bounds.y));
ctx->Paint();
update.mLayer->GetSink()->EndUpdate(ctx, update.mUpdateRect + offset);
}
}
nsAutoTArray<IDirect3DTexture9*,2> srcTextures;
nsAutoTArray<IDirect3DTexture9*,2> destTextures;
switch (aMode)

Просмотреть файл

@ -41,13 +41,10 @@
#include "Layers.h"
#include "LayerManagerD3D9.h"
#include "gfxImageSurface.h"
#include "ReadbackProcessor.h"
namespace mozilla {
namespace layers {
class ReadbackProcessor;
class ThebesLayerD3D9 : public ThebesLayer,
public LayerD3D9
{
@ -61,12 +58,10 @@ public:
/* LayerD3D9 implementation */
Layer* GetLayer();
virtual PRBool IsEmpty();
virtual void RenderLayer() { RenderThebesLayer(nsnull); }
virtual void RenderLayer();
virtual void CleanResources();
virtual void LayerManagerDestroyed();
void RenderThebesLayer(ReadbackProcessor* aReadback);
private:
/*
* D3D9 texture
@ -101,8 +96,7 @@ private:
void RenderVisibleRegion();
/* Have a region of our layer drawn */
void DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode,
const nsTArray<ReadbackProcessor::Update>& aReadbackUpdates);
void DrawRegion(nsIntRegion &aRegion, SurfaceMode aMode);
/* Create a new texture */
void CreateNewTextures(const gfxIntSize &aSize, SurfaceMode aMode);

Просмотреть файл

@ -57,7 +57,6 @@ ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter)
aContainer->mLastChild = aChild;
}
NS_ADDREF(aChild);
aContainer->DidInsertChild(aChild);
return;
}
for (Layer *child = aContainer->GetFirstChild();
@ -73,7 +72,6 @@ ContainerInsertAfter(Container* aContainer, Layer* aChild, Layer* aAfter)
}
aChild->SetPrevSibling(child);
NS_ADDREF(aChild);
aContainer->DidInsertChild(aChild);
return;
}
}
@ -94,7 +92,6 @@ ContainerRemoveChild(Container* aContainer, Layer* aChild)
aChild->SetNextSibling(nsnull);
aChild->SetPrevSibling(nsnull);
aChild->SetParent(nsnull);
aContainer->DidRemoveChild(aChild);
NS_RELEASE(aChild);
return;
}
@ -112,7 +109,6 @@ ContainerRemoveChild(Container* aContainer, Layer* aChild)
child->SetNextSibling(nsnull);
child->SetPrevSibling(nsnull);
child->SetParent(nsnull);
aContainer->DidRemoveChild(aChild);
NS_RELEASE(aChild);
return;
}

Просмотреть файл

@ -243,10 +243,6 @@ struct THEBES_API gfxRGBA {
{
return r == other.r && g == other.g && b == other.b && a == other.a;
}
bool operator!=(const gfxRGBA& other) const
{
return !(*this == other);
}
/**
* Returns this color value as a packed 32-bit integer. This reconstructs

Просмотреть файл

@ -60,13 +60,6 @@ struct THEBES_API gfxIntSize {
int operator!=(const gfxIntSize& s) const {
return ((width != s.width) || (height != s.height));
}
bool operator<(const gfxIntSize& s) const {
return (operator<=(s) &&
(width < s.width || height < s.height));
}
bool operator<=(const gfxIntSize& s) const {
return (width <= s.width) && (height <= s.height);
}
gfxIntSize operator+(const gfxIntSize& s) const {
return gfxIntSize(width + s.width, height + s.height);
}

Просмотреть файл

@ -78,7 +78,6 @@ enum Type {
TYPE_PAGE_CONTENT,
TYPE_PAGE_SEQUENCE,
TYPE_PLUGIN,
TYPE_PLUGIN_READBACK,
TYPE_PRINT_PREVIEW_BACKGROUND,
TYPE_PRINT_PLUGIN,
TYPE_REMOTE,

Просмотреть файл

@ -375,7 +375,7 @@ nsDisplayList::ComputeVisibilityForRoot(nsDisplayListBuilder* aBuilder,
r.And(*aVisibleRegion, GetBounds(aBuilder));
PRBool notUsed;
return ComputeVisibilityForSublist(aBuilder, aVisibleRegion,
r.GetBounds(), r.GetBounds(), notUsed);
r.GetBounds(), notUsed);
}
static nsRegion
@ -397,7 +397,6 @@ PRBool
nsDisplayList::ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aListVisibleBounds,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
#ifdef DEBUG
nsRegion r;
@ -430,7 +429,7 @@ nsDisplayList::ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder,
item->mVisibleRect = itemVisible.GetBounds();
PRBool containsRootContentDocBG = PR_FALSE;
if (item->ComputeVisibility(aBuilder, aVisibleRegion, aAllowVisibleRegionExpansion,
if (item->ComputeVisibility(aBuilder, aVisibleRegion,
containsRootContentDocBG)) {
if (containsRootContentDocBG) {
aContainsRootContentDocBG = PR_TRUE;
@ -745,11 +744,8 @@ PRBool nsDisplayItem::RecomputeVisibility(nsDisplayListBuilder* aBuilder,
itemVisible.And(*aVisibleRegion, bounds);
mVisibleRect = itemVisible.GetBounds();
// When we recompute visibility within layers we don't need to
// expand the visible region for content behind plugins (the plugin
// is not in the layer).
PRBool notUsed;
if (!ComputeVisibility(aBuilder, aVisibleRegion, nsRect(), notUsed))
if (!ComputeVisibility(aBuilder, aVisibleRegion, notUsed))
return PR_FALSE;
PRBool forceTransparentBackground;
@ -767,11 +763,9 @@ void nsDisplaySolidColor::Paint(nsDisplayListBuilder* aBuilder,
PRBool
nsDisplaySolidColor::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
PRBool retval = nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG);
if (retval && IsRootContentDocBackground()) {
aContainsRootContentDocBG = PR_TRUE;
@ -929,11 +923,9 @@ nsDisplayBackground::HitTest(nsDisplayListBuilder* aBuilder,
PRBool
nsDisplayBackground::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
if (!nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG)) {
return PR_FALSE;
}
@ -1206,10 +1198,8 @@ nsDisplayOutline::Paint(nsDisplayListBuilder* aBuilder,
PRBool
nsDisplayOutline::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
if (!nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG)) {
return PR_FALSE;
}
@ -1253,10 +1243,8 @@ nsDisplayCaret::Paint(nsDisplayListBuilder* aBuilder,
PRBool
nsDisplayBorder::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
if (!nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG)) {
return PR_FALSE;
}
@ -1354,10 +1342,8 @@ nsDisplayBoxShadowOuter::GetBounds(nsDisplayListBuilder* aBuilder) {
PRBool
nsDisplayBoxShadowOuter::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
if (!nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG)) {
return PR_FALSE;
}
@ -1402,10 +1388,8 @@ nsDisplayBoxShadowInner::Paint(nsDisplayListBuilder* aBuilder,
PRBool
nsDisplayBoxShadowInner::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
if (!nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG)) {
return PR_FALSE;
}
@ -1445,11 +1429,9 @@ nsDisplayWrapList::GetBounds(nsDisplayListBuilder* aBuilder) {
PRBool
nsDisplayWrapList::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
return mList.ComputeVisibilityForSublist(aBuilder, aVisibleRegion,
mVisibleRect,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG);
}
@ -1636,7 +1618,6 @@ nsDisplayOpacity::GetLayerState(nsDisplayListBuilder* aBuilder,
PRBool nsDisplayOpacity::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
// Our children are translucent so we should not allow them to subtract
// area from aVisibleRegion. We do need to find out what is visible under
@ -1649,11 +1630,9 @@ PRBool nsDisplayOpacity::ComputeVisibility(nsDisplayListBuilder* aBuilder,
// do not pass up the aContainsRootContentDocBG value because anything under
// us is not opaque
PRBool notUsed;
nsRect allowExpansion;
allowExpansion.IntersectRect(bounds, aAllowVisibleRegionExpansion);
return
nsDisplayWrapList::ComputeVisibility(aBuilder, &visibleUnderChildren,
allowExpansion, notUsed);
notUsed);
}
PRBool nsDisplayOpacity::TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem) {
@ -1729,7 +1708,6 @@ nsDisplayScrollLayer::BuildLayer(nsDisplayListBuilder* aBuilder,
PRBool
nsDisplayScrollLayer::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
nsPresContext* presContext = mFrame->PresContext();
@ -1744,17 +1722,14 @@ nsDisplayScrollLayer::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRect boundedRect;
boundedRect.IntersectRect(childVisibleRegion.GetBounds(), mList.GetBounds(aBuilder));
nsRect allowExpansion;
allowExpansion.IntersectRect(allowExpansion, boundedRect);
PRBool visible = mList.ComputeVisibilityForSublist(
aBuilder, &childVisibleRegion, boundedRect, allowExpansion, aContainsRootContentDocBG);
aBuilder, &childVisibleRegion, boundedRect, aContainsRootContentDocBG);
mVisibleRect = boundedRect;
return visible;
} else {
return nsDisplayOwnLayer::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG);
}
}
@ -1805,17 +1780,13 @@ void nsDisplayClip::Paint(nsDisplayListBuilder* aBuilder,
PRBool nsDisplayClip::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
nsRegion clipped;
clipped.And(*aVisibleRegion, mClip);
nsRegion finalClipped(clipped);
nsRect allowExpansion;
allowExpansion.IntersectRect(mClip, aAllowVisibleRegionExpansion);
PRBool anyVisible =
nsDisplayWrapList::ComputeVisibility(aBuilder, &finalClipped,
allowExpansion,
aContainsRootContentDocBG);
nsRegion removed;
@ -1909,14 +1880,13 @@ nsDisplayClipRoundedRect::WrapWithClone(nsDisplayListBuilder* aBuilder,
PRBool nsDisplayClipRoundedRect::ComputeVisibility(
nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
nsRegion clipped;
clipped.And(*aVisibleRegion, mClip);
PRBool notUsed;
return nsDisplayWrapList::ComputeVisibility(aBuilder, &clipped, nsRect(), notUsed);
return nsDisplayWrapList::ComputeVisibility(aBuilder, &clipped, notUsed);
// FIXME: Remove a *conservative* opaque region from aVisibleRegion
// (like in nsDisplayClip::ComputeVisibility).
}
@ -1979,7 +1949,6 @@ void nsDisplayZoom::Paint(nsDisplayListBuilder* aBuilder,
PRBool nsDisplayZoom::ComputeVisibility(nsDisplayListBuilder *aBuilder,
nsRegion *aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
// Convert the passed in visible region to our appunits.
@ -1989,12 +1958,9 @@ PRBool nsDisplayZoom::ComputeVisibility(nsDisplayListBuilder *aBuilder,
nsRect transformedVisibleRect =
mVisibleRect.ConvertAppUnitsRoundOut(mParentAPD, mAPD);
nsRect allowExpansion =
aAllowVisibleRegionExpansion.ConvertAppUnitsRoundIn(mParentAPD, mAPD);
PRBool retval =
mList.ComputeVisibilityForSublist(aBuilder, &visibleRegion,
transformedVisibleRect,
allowExpansion,
aContainsRootContentDocBG);
nsRegion removed;
@ -2192,7 +2158,6 @@ nsDisplayTransform::GetLayerState(nsDisplayListBuilder* aBuilder,
PRBool nsDisplayTransform::ComputeVisibility(nsDisplayListBuilder *aBuilder,
nsRegion *aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
/* As we do this, we need to be sure to
@ -2475,7 +2440,6 @@ void nsDisplaySVGEffects::Paint(nsDisplayListBuilder* aBuilder,
PRBool nsDisplaySVGEffects::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG) {
nsPoint offset = aBuilder->ToReferenceFrame(mEffectsFrame);
nsRect dirtyRect =
@ -2489,7 +2453,7 @@ PRBool nsDisplaySVGEffects::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRect r;
r.IntersectRect(dirtyRect, mList.GetBounds(aBuilder));
PRBool notUsed;
mList.ComputeVisibilityForSublist(aBuilder, &childrenVisible, r, nsRect(), notUsed);
mList.ComputeVisibilityForSublist(aBuilder, &childrenVisible, r, notUsed);
return PR_TRUE;
}

Просмотреть файл

@ -705,17 +705,13 @@ public:
* this item to the intersection of *aVisibleRegion and this item's bounds.
* We rely on that, so this should only be called by
* nsDisplayList::ComputeVisibility or nsDisplayItem::RecomputeVisibility.
* aAllowVisibleRegionExpansion is a rect where we are allowed to
* expand the visible region and is only used for making sure the
* background behind a plugin is visible.
*
*
* @return PR_TRUE if the item is visible, PR_FALSE if no part of the item
* is visible. aContainsRootContentDocBG is set to true if this item contains
* the background for the root content document.
*/
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{ return !mVisibleRect.IsEmpty(); }
@ -997,7 +993,6 @@ public:
PRBool ComputeVisibilityForSublist(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aListVisibleBounds,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
/**
@ -1404,7 +1399,6 @@ public:
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
NS_DISPLAY_DECL_NAME("Border", TYPE_BORDER)
@ -1463,7 +1457,6 @@ public:
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
PRBool IsRootContentDocBackground() {
@ -1494,7 +1487,6 @@ public:
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
virtual nsRegion GetOpaqueRegion(nsDisplayListBuilder* aBuilder,
PRBool* aForceTransparentSurface = nsnull);
@ -1534,7 +1526,6 @@ public:
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
NS_DISPLAY_DECL_NAME("BoxShadowOuter", TYPE_BOX_SHADOW_OUTER)
@ -1560,7 +1551,6 @@ public:
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
NS_DISPLAY_DECL_NAME("BoxShadowInner", TYPE_BOX_SHADOW_INNER)
@ -1587,7 +1577,6 @@ public:
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
NS_DISPLAY_DECL_NAME("Outline", TYPE_OUTLINE)
};
@ -1650,7 +1639,6 @@ public:
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem) {
NS_WARNING("This list should already have been flattened!!!");
@ -1736,7 +1724,6 @@ public:
LayerManager* aManager);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem);
NS_DISPLAY_DECL_NAME("Opacity", TYPE_OPACITY)
@ -1804,7 +1791,6 @@ public:
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
private:
@ -1836,7 +1822,6 @@ public:
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem);
NS_DISPLAY_DECL_NAME("Clip", TYPE_CLIP)
@ -1879,7 +1864,6 @@ public:
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem);
NS_DISPLAY_DECL_NAME("ClipRoundedRect", TYPE_CLIP_ROUNDED_RECT)
@ -1921,7 +1905,6 @@ public:
HitTestState* aState, nsTArray<nsIFrame*> *aOutFrames);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
NS_DISPLAY_DECL_NAME("Zoom", TYPE_ZOOM)
@ -1957,7 +1940,6 @@ public:
virtual void Paint(nsDisplayListBuilder* aBuilder, nsIRenderingContext* aCtx);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
virtual PRBool TryMerge(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem);
NS_DISPLAY_DECL_NAME("SVGEffects", TYPE_SVG_EFFECTS)
@ -2022,7 +2004,6 @@ public:
LayerManager* aManager);
virtual PRBool ComputeVisibility(nsDisplayListBuilder *aBuilder,
nsRegion *aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
virtual PRBool TryMerge(nsDisplayListBuilder *aBuilder, nsDisplayItem *aItem);

Просмотреть файл

@ -173,12 +173,10 @@ public:
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
PRBool retval = NS_GET_A(mExtraBackgroundColor) > 0 ||
nsDisplayBackground::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG);
if (retval && mFrame->PresContext()->IsRootContentDocument()) {
aContainsRootContentDocBG = PR_TRUE;

Просмотреть файл

@ -163,7 +163,6 @@ enum { XKeyPress = KeyPress };
#include "gfxImageSurface.h"
#include "gfxUtils.h"
#include "Layers.h"
#include "ReadbackLayer.h"
// accessibility support
#ifdef ACCESSIBILITY
@ -238,10 +237,6 @@ static PRLogModuleInfo *nsObjectFrameLM = PR_NewLogModule("nsObjectFrame");
#define MAC_CARBON_PLUGINS
#endif
using namespace mozilla;
#ifdef MOZ_IPC
using namespace mozilla::plugins;
#endif
using namespace mozilla::layers;
// special class for handeling DOM context menu events because for
@ -469,13 +464,6 @@ public:
// Return true if we set image with valid surface
PRBool SetCurrentImage(ImageContainer* aContainer);
// Methods to update the background image we send to async plugins.
// The eventual target of these operations is PluginInstanceParent,
// but it takes several hops to get there.
void SetBackgroundUnknown();
already_AddRefed<gfxContext> BeginUpdateBackground(const nsIntRect& aRect);
void EndUpdateBackground(gfxContext* aContext, const nsIntRect& aRect);
PRBool UseLayers()
{
PRBool useAsyncRendering;
@ -486,7 +474,6 @@ public:
mPluginWindow->type == NPWindowTypeDrawable));
}
private:
// return FALSE if LayerSurface dirty (newly created and don't have valid plugin content yet)
PRBool IsUpToDate()
@ -497,13 +484,6 @@ private:
mPluginWindow->height);
}
already_AddRefed<nsIPluginInstance_MOZILLA_2_0_BRANCH>
GetInstance()
{
nsCOMPtr<nsIPluginInstance_MOZILLA_2_0_BRANCH> inst = do_QueryInterface(mInstance);
return inst.forget();
}
void FixUpURLS(const nsString &name, nsAString &value);
nsPluginNativeWindow *mPluginWindow;
@ -626,53 +606,6 @@ private:
PRPackedBool mWaitingForPaint;
};
class PluginBackgroundSink : public ReadbackSink {
public:
PluginBackgroundSink(nsObjectFrame* aFrame, PRUint64 aStartSequenceNumber)
: mLastSequenceNumber(aStartSequenceNumber), mFrame(aFrame) {}
~PluginBackgroundSink()
{
if (mFrame) {
mFrame->mBackgroundSink = nsnull;
}
}
virtual void SetUnknown(PRUint64 aSequenceNumber)
{
if (!AcceptUpdate(aSequenceNumber))
return;
mFrame->mInstanceOwner->SetBackgroundUnknown();
}
virtual already_AddRefed<gfxContext>
BeginUpdate(const nsIntRect& aRect, PRUint64 aSequenceNumber)
{
if (!AcceptUpdate(aSequenceNumber))
return nsnull;
return mFrame->mInstanceOwner->BeginUpdateBackground(aRect);
}
virtual void EndUpdate(gfxContext* aContext, const nsIntRect& aRect)
{
return mFrame->mInstanceOwner->EndUpdateBackground(aContext, aRect);
}
void Destroy() { mFrame = nsnull; }
protected:
PRBool AcceptUpdate(PRUint64 aSequenceNumber) {
if (aSequenceNumber > mLastSequenceNumber && mFrame &&
mFrame->mInstanceOwner) {
mLastSequenceNumber = aSequenceNumber;
return PR_TRUE;
}
return PR_FALSE;
}
PRUint64 mLastSequenceNumber;
nsObjectFrame* mFrame;
};
// Mac specific code to fix up port position and clip
#ifdef XP_MACOSX
@ -718,6 +651,7 @@ NS_IMETHODIMP nsObjectFrame::GetPluginPort(HWND *aPort)
#endif
#endif
static NS_DEFINE_CID(kWidgetCID, NS_CHILD_CID);
NS_IMETHODIMP
@ -755,10 +689,6 @@ nsObjectFrame::DestroyFrom(nsIFrame* aDestructRoot)
mWidget->Destroy();
}
if (mBackgroundSink) {
mBackgroundSink->Destroy();
}
nsObjectFrameSuper::DestroyFrom(aDestructRoot);
}
@ -1323,48 +1253,19 @@ nsObjectFrame::PaintPrintPlugin(nsIFrame* aFrame, nsIRenderingContext* aCtx,
static_cast<nsObjectFrame*>(aFrame)->PrintPlugin(*aCtx, aDirtyRect);
}
class nsDisplayPluginReadback : public nsDisplayItem {
public:
nsDisplayPluginReadback(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame)
: nsDisplayItem(aBuilder, aFrame)
{
MOZ_COUNT_CTOR(nsDisplayPluginReadback);
}
#ifdef NS_BUILD_REFCNT_LOGGING
virtual ~nsDisplayPluginReadback() {
MOZ_COUNT_DTOR(nsDisplayPluginReadback);
}
#endif
virtual nsRect GetBounds(nsDisplayListBuilder* aBuilder);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
NS_DISPLAY_DECL_NAME("PluginReadback", TYPE_PLUGIN_READBACK)
virtual already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager)
{
return static_cast<nsObjectFrame*>(mFrame)->BuildLayer(aBuilder, aManager, this);
}
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
LayerManager* aManager)
{
return LAYER_ACTIVE;
}
};
static nsRect
GetDisplayItemBounds(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem, nsIFrame* aFrame)
nsRect
nsDisplayPlugin::GetBounds(nsDisplayListBuilder* aBuilder)
{
nsRect r = aFrame->GetContentRect() - aFrame->GetPosition() +
aItem->ToReferenceFrame();
nsRect r = mFrame->GetContentRect() - mFrame->GetPosition() +
ToReferenceFrame();
if (aBuilder->IsForPluginGeometry()) {
// Return the geometry we want, not the geometry we have (which is based
// on the surface the plugin last gave us)
return r;
}
nsObjectFrame* f = static_cast<nsObjectFrame*>(aFrame);
if (LAYER_ACTIVE == f->GetLayerState(aBuilder)) {
nsObjectFrame* f = static_cast<nsObjectFrame*>(mFrame);
if (mozilla::LAYER_ACTIVE == f->GetLayerState(aBuilder, nsnull)) {
ImageContainer* c = f->GetImageContainer();
if (c) {
gfxIntSize size = c->GetCurrentSize();
@ -1378,38 +1279,6 @@ GetDisplayItemBounds(nsDisplayListBuilder* aBuilder, nsDisplayItem* aItem, nsIFr
return r;
}
nsRect
nsDisplayPluginReadback::GetBounds(nsDisplayListBuilder* aBuilder)
{
return GetDisplayItemBounds(aBuilder, this, mFrame);
}
PRBool
nsDisplayPluginReadback::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
if (!nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG))
return PR_FALSE;
nsRect expand;
expand.IntersectRect(aAllowVisibleRegionExpansion, GetBounds(aBuilder));
// *Add* our bounds to the visible region so that stuff underneath us is
// likely to be made visible, so we can use it for a background! This is
// a bit crazy since we normally only subtract from the visible region.
aVisibleRegion->Or(*aVisibleRegion, expand);
return PR_TRUE;
}
nsRect
nsDisplayPlugin::GetBounds(nsDisplayListBuilder* aBuilder)
{
return GetDisplayItemBounds(aBuilder, this, mFrame);
}
void
nsDisplayPlugin::Paint(nsDisplayListBuilder* aBuilder,
nsIRenderingContext* aCtx)
@ -1421,12 +1290,10 @@ nsDisplayPlugin::Paint(nsDisplayListBuilder* aBuilder,
PRBool
nsDisplayPlugin::ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG)
{
mVisibleRegion.And(*aVisibleRegion, GetBounds(aBuilder));
return nsDisplayItem::ComputeVisibility(aBuilder, aVisibleRegion,
aAllowVisibleRegionExpansion,
aContainsRootContentDocBG);
}
@ -1589,12 +1456,10 @@ nsObjectFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists)
{
AddStateBits(NS_OBJECT_NEEDS_SET_IMAGE);
// XXX why are we painting collapsed object frames?
if (!IsVisibleOrCollapsedForPainting(aBuilder))
return NS_OK;
nsresult rv = DisplayBorderBackgroundOutline(aBuilder, aLists);
NS_ENSURE_SUCCESS(rv, rv);
@ -1639,12 +1504,6 @@ nsObjectFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsDisplayGeneric(aBuilder, this, PaintPrintPlugin, "PrintPlugin",
nsDisplayItem::TYPE_PRINT_PLUGIN));
} else {
if (aBuilder->IsPaintingToWindow() && GetLayerState(aBuilder) == LAYER_ACTIVE) {
rv = replacedContent.AppendNewToTop(new (aBuilder)
nsDisplayPluginReadback(aBuilder, this));
NS_ENSURE_SUCCESS(rv, rv);
}
rv = replacedContent.AppendNewToTop(new (aBuilder)
nsDisplayPlugin(aBuilder, this));
}
@ -1948,44 +1807,14 @@ nsPluginInstanceOwner::SetCurrentImage(ImageContainer* aContainer)
return PR_TRUE;
}
void
nsPluginInstanceOwner::SetBackgroundUnknown()
mozilla::LayerState
nsObjectFrame::GetLayerState(nsDisplayListBuilder* aBuilder,
LayerManager* aManager)
{
nsCOMPtr<nsIPluginInstance_MOZILLA_2_0_BRANCH> inst = GetInstance();
if (inst) {
inst->SetBackgroundUnknown();
}
}
if (!mInstanceOwner || !mInstanceOwner->UseLayers())
return mozilla::LAYER_NONE;
already_AddRefed<gfxContext>
nsPluginInstanceOwner::BeginUpdateBackground(const nsIntRect& aRect)
{
nsIntRect rect = aRect;
nsCOMPtr<nsIPluginInstance_MOZILLA_2_0_BRANCH> inst = GetInstance();
nsRefPtr<gfxContext> ctx;
if (inst &&
NS_SUCCEEDED(inst->BeginUpdateBackground(&rect, getter_AddRefs(ctx)))) {
return ctx.forget();
}
return nsnull;
}
void
nsPluginInstanceOwner::EndUpdateBackground(gfxContext* aContext,
const nsIntRect& aRect)
{
nsIntRect rect = aRect;
nsCOMPtr<nsIPluginInstance_MOZILLA_2_0_BRANCH> inst = GetInstance();
if (inst) {
inst->EndUpdateBackground(aContext, &rect);
}
}
LayerState
nsObjectFrame::GetLayerState(nsDisplayListBuilder* aBuilder)
{
return mInstanceOwner && mInstanceOwner->UseLayers() ?
LAYER_ACTIVE : LAYER_NONE;
return mozilla::LAYER_ACTIVE;
}
already_AddRefed<Layer>
@ -2004,18 +1833,6 @@ nsObjectFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
if (window->width <= 0 || window->height <= 0)
return nsnull;
// Create image
nsRefPtr<ImageContainer> container = GetImageContainer(aManager);
if (!container)
return nsnull;
if (GetStateBits() & NS_OBJECT_NEEDS_SET_IMAGE) {
RemoveStateBits(NS_OBJECT_NEEDS_SET_IMAGE);
if (!mInstanceOwner->SetCurrentImage(container)) {
return nsnull;
}
}
gfxIntSize size = container->GetCurrentSize();
nsRect area = GetContentRect() + aBuilder->ToReferenceFrame(GetParent());
gfxRect r = nsLayoutUtils::RectToGfxRect(area, PresContext()->AppUnitsPerDevPixel());
// to provide crisper and faster drawing.
@ -2023,55 +1840,41 @@ nsObjectFrame::BuildLayer(nsDisplayListBuilder* aBuilder,
nsRefPtr<Layer> layer =
(aBuilder->LayerBuilder()->GetLeafLayerFor(aBuilder, aManager, aItem));
if (aItem->GetType() == nsDisplayItem::TYPE_PLUGIN) {
if (!layer) {
mInstanceOwner->NotifyPaintWaiter(aBuilder);
// Initialize ImageLayer
layer = aManager->CreateImageLayer();
if (!layer)
return nsnull;
}
NS_ASSERTION(layer->GetType() == Layer::TYPE_IMAGE, "Bad layer type");
ImageLayer* imglayer = static_cast<ImageLayer*>(layer.get());
imglayer->SetContainer(container);
imglayer->SetFilter(nsLayoutUtils::GetGraphicsFilterForFrame(this));
layer->SetContentFlags(IsOpaque() ? Layer::CONTENT_OPAQUE : 0);
} else {
NS_ASSERTION(aItem->GetType() == nsDisplayItem::TYPE_PLUGIN_READBACK,
"Unknown item type");
if (!layer) {
layer = aManager->CreateReadbackLayer();
if (!layer)
return nsnull;
}
NS_ASSERTION(layer->GetType() == Layer::TYPE_READBACK, "Bad layer type");
ReadbackLayer* readback = static_cast<ReadbackLayer*>(layer.get());
if (readback->GetSize() != nsIntSize(size.width, size.height)) {
// This will destroy any old background sink and notify us that the
// background is now unknown
readback->SetSink(nsnull);
NS_ASSERTION(!mBackgroundSink, "Should have been cleared");
readback->SetSize(nsIntSize(size.width, size.height));
mBackgroundSink =
new PluginBackgroundSink(this,
readback->AllocateSequenceNumber());
readback->SetSink(mBackgroundSink);
// The layer has taken ownership of our sink. When either the sink dies
// or the frame dies, the connection from the surviving object is nulled out.
}
if (!layer) {
mInstanceOwner->NotifyPaintWaiter(aBuilder);
// Initialize ImageLayer
layer = aManager->CreateImageLayer();
}
if (!layer)
return nsnull;
NS_ASSERTION(layer->GetType() == Layer::TYPE_IMAGE, "ObjectFrame works only with ImageLayer");
// Create image
nsRefPtr<ImageContainer> container = GetImageContainer(aManager);
if (!container)
return nsnull;
if (!mInstanceOwner->SetCurrentImage(container)) {
return nsnull;
}
ImageLayer* imglayer = static_cast<ImageLayer*>(layer.get());
imglayer->SetContainer(container);
imglayer->SetFilter(nsLayoutUtils::GetGraphicsFilterForFrame(this));
layer->SetContentFlags(IsOpaque() ? Layer::CONTENT_OPAQUE : 0);
// Set a transform on the layer to draw the plugin in the right place
gfxMatrix transform;
// Center plugin if layer size != frame rect
r.pos.x += (r.Width() - container->GetCurrentSize().width) / 2;
r.pos.y += (r.Height() - container->GetCurrentSize().height) / 2;
transform.Translate(r.pos);
layer->SetTransform(gfx3DMatrix::From2D(transform));
return layer.forget();
nsRefPtr<Layer> result = layer.forget();
return result.forget();
}
void
@ -2236,7 +2039,7 @@ nsObjectFrame::PaintPlugin(nsDisplayListBuilder* aBuilder,
// double pass render. If this plugin isn't oop, the register window message
// will be ignored.
NPEvent pluginEvent;
pluginEvent.event = DoublePassRenderingEvent();
pluginEvent.event = mozilla::plugins::DoublePassRenderingEvent();
pluginEvent.wParam = 0;
pluginEvent.lParam = 0;
if (pluginEvent.event)

Просмотреть файл

@ -62,12 +62,9 @@ class nsIPluginInstance;
class nsPresContext;
class nsDisplayPlugin;
class nsIDOMElement;
class PluginBackgroundSink;
#define nsObjectFrameSuper nsFrame
#define NS_OBJECT_NEEDS_SET_IMAGE NS_FRAME_STATE_BIT(31)
class nsObjectFrame : public nsObjectFrameSuper,
public nsIObjectFrame,
public nsIReflowCallback {
@ -179,15 +176,12 @@ public:
virtual PRBool ReflowFinished();
virtual void ReflowCallbackCanceled();
/**
* Builds either an ImageLayer or a ReadbackLayer, depending on the type
* of aItem (TYPE_PLUGIN or TYPE_PLUGIN_READBACK respectively).
*/
already_AddRefed<Layer> BuildLayer(nsDisplayListBuilder* aBuilder,
LayerManager* aManager,
nsDisplayItem* aItem);
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder);
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
LayerManager* aManager);
ImageContainer* GetImageContainer(LayerManager* aManager = nsnull);
@ -278,7 +272,6 @@ protected:
friend class nsPluginInstanceOwner;
friend class nsDisplayPlugin;
friend class PluginBackgroundSink;
private:
@ -296,11 +289,6 @@ private:
nsIView* mInnerView;
nsCOMPtr<nsIWidget> mWidget;
nsIntRect mWindowlessRect;
/**
* This is owned by the ReadbackLayer for this nsObjectFrame. It is
* automatically cleared if the PluginBackgroundSink is destroyed.
*/
PluginBackgroundSink* mBackgroundSink;
// For assertions that make it easier to determine if a crash is due
// to the underlying problem described in bug 136927, and to prevent
@ -334,7 +322,6 @@ public:
nsIRenderingContext* aCtx);
virtual PRBool ComputeVisibility(nsDisplayListBuilder* aBuilder,
nsRegion* aVisibleRegion,
const nsRect& aAllowVisibleRegionExpansion,
PRBool& aContainsRootContentDocBG);
NS_DISPLAY_DECL_NAME("Plugin", TYPE_PLUGIN)
@ -358,7 +345,7 @@ public:
virtual LayerState GetLayerState(nsDisplayListBuilder* aBuilder,
LayerManager* aManager)
{
return static_cast<nsObjectFrame*>(mFrame)->GetLayerState(aBuilder);
return static_cast<nsObjectFrame*>(mFrame)->GetLayerState(aBuilder, aManager);
}
private:

Просмотреть файл

@ -48,8 +48,6 @@ interface nsIOutputStream;
struct JSContext;
struct JSObject;
class gfxASurface;
class gfxContext;
struct nsIntRect;
#define NPRUNTIME_JSCLASS_NAME "NPObject JS wrapper class"
%}
@ -57,8 +55,6 @@ struct nsIntRect;
[ptr] native JSContextPtr(JSContext);
[ptr] native JSObjectPtr(JSObject);
[ptr] native gfxASurfacePtr(gfxASurface);
[ptr] native gfxContextPtr(gfxContext);
[ptr] native nsIntRectPtr(nsIntRect);
[uuid(84994340-E120-4051-824F-D4EE8AEF1A3E)]
interface nsIPluginInstance : nsISupports
@ -251,18 +247,3 @@ interface nsIPluginInstance : nsISupports
*/
PRBool useAsyncPainting();
};
// XXX kill me after branching
[noscript, uuid(324f3c02-4fbd-430b-8afa-db083d3867fc)]
interface nsIPluginInstance_MOZILLA_2_0_BRANCH : nsIPluginInstance
{
/**
* This is the second leg in the trip to PluginInstanceParent. It
* approximately follows the ReadbackSink API.
*/
void setBackgroundUnknown();
void beginUpdateBackground(in nsIntRectPtr rect, out gfxContextPtr ctx);
void endUpdateBackground(in gfxContextPtr ctx, in nsIntRectPtr rect);
};

Просмотреть файл

@ -255,32 +255,4 @@ PluginPRLibrary::GetSurface(NPP instance, gfxASurface** aSurface)
return NS_OK;
}
nsresult
PluginPRLibrary::SetBackgroundUnknown(NPP instance)
{
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
NS_ERROR("Unexpected use of async APIs for in-process plugin.");
return NS_ERROR_NOT_IMPLEMENTED;
}
nsresult
PluginPRLibrary::BeginUpdateBackground(NPP instance,
const nsIntRect&, gfxContext** aCtx)
{
nsNPAPIPluginInstance* inst = (nsNPAPIPluginInstance*)instance->ndata;
NS_ENSURE_TRUE(inst, NS_ERROR_NULL_POINTER);
NS_ERROR("Unexpected use of async APIs for in-process plugin.");
*aCtx = nsnull;
return NS_OK;
}
nsresult
PluginPRLibrary::EndUpdateBackground(NPP instance,
gfxContext*, const nsIntRect&)
{
NS_RUNTIMEABORT("This should never be called");
return NS_ERROR_NOT_AVAILABLE;
}
} // namespace mozilla

Просмотреть файл

@ -142,14 +142,6 @@ public:
virtual nsresult AsyncSetWindow(NPP instance, NPWindow* window);
virtual nsresult GetSurface(NPP instance, gfxASurface** aSurface);
NS_OVERRIDE virtual bool UseAsyncPainting() { return false; }
NS_OVERRIDE
virtual nsresult SetBackgroundUnknown(NPP instance);
NS_OVERRIDE
virtual nsresult BeginUpdateBackground(NPP instance,
const nsIntRect&, gfxContext** aCtx);
NS_OVERRIDE
virtual nsresult EndUpdateBackground(NPP instance,
gfxContext* aCtx, const nsIntRect&);
private:
NP_InitializeFunc mNP_Initialize;

Просмотреть файл

@ -59,13 +59,13 @@
#include "nsJSNPRuntime.h"
#include "nsPluginStreamListenerPeer.h"
using namespace mozilla;
using namespace mozilla::plugins::parent;
using mozilla::TimeStamp;
static NS_DEFINE_IID(kIOutputStreamIID, NS_IOUTPUTSTREAM_IID);
static NS_DEFINE_IID(kIPluginStreamListenerIID, NS_IPLUGINSTREAMLISTENER_IID);
NS_IMPL_ISUPPORTS2(nsNPAPIPluginInstance, nsIPluginInstance, nsIPluginInstance_MOZILLA_2_0_BRANCH)
NS_IMPL_ISUPPORTS1(nsNPAPIPluginInstance, nsIPluginInstance)
nsNPAPIPluginInstance::nsNPAPIPluginInstance(nsNPAPIPlugin* plugin)
:
@ -809,32 +809,18 @@ nsNPAPIPluginInstance::IsWindowless(PRBool* isWindowless)
return NS_OK;
}
class NS_STACK_CLASS AutoPluginLibraryCall
{
public:
AutoPluginLibraryCall(nsNPAPIPluginInstance* aThis)
: mThis(aThis), mGuard(aThis), mLibrary(nsnull)
{
nsNPAPIPlugin* plugin = mThis->GetPlugin();
if (plugin)
mLibrary = plugin->GetLibrary();
}
operator bool() { return !!mLibrary; }
PluginLibrary* operator->() { return mLibrary; }
private:
nsNPAPIPluginInstance* mThis;
PluginDestructionGuard mGuard;
PluginLibrary* mLibrary;
};
NS_IMETHODIMP
nsNPAPIPluginInstance::AsyncSetWindow(NPWindow* window)
{
if (RUNNING != mRunning)
return NS_OK;
AutoPluginLibraryCall library(this);
PluginDestructionGuard guard(this);
if (!mPlugin)
return NS_ERROR_FAILURE;
PluginLibrary* library = mPlugin->GetLibrary();
if (!library)
return NS_ERROR_FAILURE;
@ -847,7 +833,12 @@ nsNPAPIPluginInstance::GetSurface(gfxASurface** aSurface)
if (RUNNING != mRunning)
return NS_OK;
AutoPluginLibraryCall library(this);
PluginDestructionGuard guard(this);
if (!mPlugin)
return NS_ERROR_FAILURE;
PluginLibrary* library = mPlugin->GetLibrary();
if (!library)
return NS_ERROR_FAILURE;
@ -870,7 +861,12 @@ nsNPAPIPluginInstance::UseAsyncPainting(PRBool* aIsAsync)
return NS_OK;
}
AutoPluginLibraryCall library(this);
PluginDestructionGuard guard(this);
if (!mPlugin)
return NS_ERROR_FAILURE;
PluginLibrary* library = mPlugin->GetLibrary();
if (!library)
return NS_ERROR_FAILURE;
@ -878,47 +874,6 @@ nsNPAPIPluginInstance::UseAsyncPainting(PRBool* aIsAsync)
return NS_OK;
}
NS_IMETHODIMP
nsNPAPIPluginInstance::SetBackgroundUnknown()
{
if (RUNNING != mRunning)
return NS_OK;
AutoPluginLibraryCall library(this);
if (!library)
return NS_ERROR_FAILURE;
return library->SetBackgroundUnknown(&mNPP);
}
NS_IMETHODIMP
nsNPAPIPluginInstance::BeginUpdateBackground(nsIntRect* aRect,
gfxContext** aContext)
{
if (RUNNING != mRunning)
return NS_OK;
AutoPluginLibraryCall library(this);
if (!library)
return NS_ERROR_FAILURE;
return library->BeginUpdateBackground(&mNPP, *aRect, aContext);
}
NS_IMETHODIMP
nsNPAPIPluginInstance::EndUpdateBackground(gfxContext* aContext,
nsIntRect* aRect)
{
if (RUNNING != mRunning)
return NS_OK;
AutoPluginLibraryCall library(this);
if (!library)
return NS_ERROR_FAILURE;
return library->EndUpdateBackground(&mNPP, aContext, *aRect);
}
NS_IMETHODIMP
nsNPAPIPluginInstance::IsTransparent(PRBool* isTransparent)
{

Просмотреть файл

@ -67,7 +67,7 @@ public:
void (*callback)(NPP npp, uint32_t timerID);
};
class nsNPAPIPluginInstance : public nsIPluginInstance_MOZILLA_2_0_BRANCH
class nsNPAPIPluginInstance : public nsIPluginInstance
{
private:
typedef mozilla::PluginLibrary PluginLibrary;
@ -75,7 +75,6 @@ private:
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIPLUGININSTANCE
NS_DECL_NSIPLUGININSTANCE_MOZILLA_2_0_BRANCH
nsNPAPIPlugin* GetPlugin();

Просмотреть файл

@ -1,109 +0,0 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<style type="text/css">
#one {
position:absolute;
left:0px; top:0px;
z-index:4;
}
#two {
position:absolute;
top:100px; left:100px;
background-color:rgb(0,0,0,0);
z-index:3;
}
#three {
position:absolute;
left:100px; top:100px;
width:200px; height:200px;
background-color: rgb(255,0,0);
opacity:0.6;
z-index:2;
}
#four {
position:absolute;
top:100px; left:100px;
z-index:1;
}
</style>
<script type="text/javascript">
var plugin, div, canvas;
function start() {
plugin = document.getElementById("four");
div = document.getElementById("three");
canvas = document.getElementById("two");
paintCanvas();
mozRequestAnimationFrame(moveSomething);
}
function paintCanvas() {
var ctx = canvas.getContext("2d");
ctx.fillStyle = "rgba(255,0,0, 0.6)";
ctx.fillRect(0,0, 200,200);
}
var i = 0, numLoops = 20;
var pluginIn = true, divIn = true, canvasIn = true;
function moveSomething() {
var didSomething = (0 === (i % 2)) ? moveSomethingOut() : moveSomethingIn();
if (!didSomething && ++i >= numLoops) {
return finish();
}
mozRequestAnimationFrame(moveSomething);
}
function finish() {
document.documentElement.removeAttribute("class");
}
function moveSomethingOut() {
if (pluginIn) {
plugin.style.left = "400px";
pluginIn = false;
} else if (divIn) {
div.style.left = "400px";
divIn = false;
} else if (canvasIn) {
canvas.style.left = "400px";
canvasIn = false;
} else {
return false;
}
return true;
}
function moveSomethingIn() {
if (!pluginIn) {
plugin.style.left = "100px";
pluginIn = true;
} else if (!divIn) {
div.style.left = "100px";
divIn = true;
} else if (!canvasIn) {
canvas.style.left = "100px";
canvasIn = true;
} else {
return false;
}
return true;
}
function reset() {
}
</script>
</style>
</head>
<body onload="start();">
<embed id="four" type="application/x-test" width="200" height="200"
drawmode="solid" color="FFFF0000"></embed>
<div id="three"></div>
<canvas id="two" width="200" height="200"></canvas>
<embed id="one" type="application/x-test" width="400" height="400"
drawmode="solid" color="9900FF00"></embed>
</body>
</html>

Просмотреть файл

@ -9,4 +9,3 @@ load 570884.html
# Plugin arch is going to change anyway with OOP content so skipping
# this test for now is OK.
skip-if(browserIsRemote||!haveTestPlugin||http.platform!="X11"||!testPluginIsOOP()) load 598862.html
load 626602-1.html

Просмотреть файл

@ -1,22 +0,0 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<link rel="stylesheet" type="text/css" href="plugin-background.css"></link>
<script type="text/javascript">
var NUM_STEPS = 1;
</script>
<script type="text/javascript" src="plugin-background.js"></script>
</head>
<body>
<div id="bad">Test some plugin stuff.</div>
<div id="good"></div>
<embed id="plugin" type="application/x-test" width="199" height="199"
drawmode="solid" color="330000FF"></embed>
<div id="topbar"></div>
<div id="leftbar"></div>
<div id="rightbar"></div>
<div id="bottombar"></div>
</body>
</html>

Просмотреть файл

@ -1,22 +0,0 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<link rel="stylesheet" type="text/css" href="plugin-background.css"></link>
<script type="text/javascript">
var NUM_STEPS = 10;
</script>
<script type="text/javascript" src="plugin-background.js"></script>
</head>
<body>
<div id="bad">Test some plugin stuff.</div>
<div id="good"></div>
<embed id="plugin" type="application/x-test" width="199" height="199"
drawmode="solid" color="330000FF"></embed>
<div id="topbar"></div>
<div id="leftbar"></div>
<div id="rightbar"></div>
<div id="bottombar"></div>
</body>
</html>

Просмотреть файл

@ -1,22 +0,0 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<link rel="stylesheet" type="text/css" href="plugin-background.css"></link>
<script type="text/javascript">
var NUM_STEPS = 2;
</script>
<script type="text/javascript" src="plugin-background.js"></script>
</head>
<body>
<div id="bad">Test some plugin stuff.</div>
<div id="good"></div>
<embed id="plugin" type="application/x-test" width="199" height="199"
drawmode="solid" color="330000FF"></embed>
<div id="topbar"></div>
<div id="leftbar"></div>
<div id="rightbar"></div>
<div id="bottombar"></div>
</body>
</html>

Просмотреть файл

@ -1,22 +0,0 @@
<!DOCTYPE html>
<html class="reftest-wait">
<head>
<link rel="stylesheet" type="text/css" href="plugin-background.css"></link>
<script type="text/javascript">
var NUM_STEPS = 5;
</script>
<script type="text/javascript" src="plugin-background.js"></script>
</head>
<body>
<div id="bad">Test some plugin stuff.</div>
<div id="good"></div>
<embed id="plugin" type="application/x-test" width="199" height="199"
drawmode="solid" color="330000FF"></embed>
<div id="topbar"></div>
<div id="leftbar"></div>
<div id="rightbar"></div>
<div id="bottombar"></div>
</body>
</html>

Просмотреть файл

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="plugin-background.css"></link>
</head>
<body>
<div id="bad">Test some plugin stuff.</div>
<div id="good"></div>
<div id="plugin"></div>
<div id="topbar"></div>
<div id="leftbar"></div>
<div id="rightbar"></div>
<div id="bottombar"></div>
</body>
</html>

Просмотреть файл

@ -1,58 +0,0 @@
div {
position: absolute;
}
#bad {
left:220px; top:0px;
z-index: 0;
}
#good {
left:0px; top:0px;
width:220px; height:220px;
background-color: rgba(0,255,0, 0.6);
z-index: 0;
}
#topbar {
left:0px; top:0px;
width:220px; height:20px;
background-color: rgb(0,0,0);
z-index: 2;
}
#topbar {
left:0px; top:0px;
width:220px; height:20px;
background-color: rgb(0,0,0);
z-index: 2;
}
#leftbar {
left:0px; top:0px;
width:20px; height:220px;
background-color: rgb(0,0,0);
z-index: 2;
}
#rightbar {
left:200px; top:0px;
width:20px; height:220px;
background-color: rgb(0,0,0);
z-index: 2;
}
#bottombar {
left:0px; top:200px;
width:220px; height:20px;
background-color: rgb(0,0,0);
z-index: 2;
}
div#plugin {
position: absolute;
left:1px; top:1px;
width:199px; height:199px;
background-color: rgba(0,0,255, 0.2);
z-index: 1;
}
embed#plugin {
position: absolute;
left:1px; top:1px;
z-index: 1;
}

Просмотреть файл

@ -1,18 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="plugin-background.css"></link>
</head>
<body>
<div id="bad">Test some plugin stuff.</div>
<div id="good"></div>
<embed id="plugin" type="application/x-test" width="199" height="199"
drawmode="solid" color="330000FF"></embed>
<div id="topbar"></div>
<div id="leftbar"></div>
<div id="rightbar"></div>
<div id="bottombar"></div>
</body>
</html>

Просмотреть файл

@ -1,75 +0,0 @@
// The including script sets this for us
//var NUM_STEPS;
var plugin;
var left = 1, top = 1, width = 199, height = 199;
function movePluginTo(x, y, w, h) {
left = x; top = y; width = w; height = h;
plugin.width = w;
plugin.height = h;
plugin.style.left = left + "px";
plugin.style.top = top + "px";
}
function deltaInBounds(dx,dy, dw,dh) {
var l = dx + left;
var r = l + width + dw;
var t = dy + top;
var b = t + height + dh;
return (0 <= l && l <= 20 &&
0 <= t && t <= 20 &&
200 <= r && r <= 220 &&
200 <= b && b <= 220);
}
var initialFrame;
function start() {
window.removeEventListener("MozReftestInvalidate", start, false);
window.addEventListener("MozAfterPaint", step, false);
window.addEventListener("MozPaintWaitFinished", step, false);
initialFrame = window.mozPaintCount;
plugin = document.getElementById("plugin");
movePluginTo(0,0, 200,200);
}
var steps = 0;
var which = "move"; // or "grow"
var dx = 1, dy = 1, dw = 1, dh = 1;
function step() {
if (++steps >= NUM_STEPS) {
window.removeEventListener("MozAfterPaint", step, false);
window.removeEventListener("MozPaintWaitFinished", step, false);
return finish();
}
var didSomething = false;
if (which == "grow") {
if (deltaInBounds(0,0, dw,dh)) {
movePluginTo(left,top, width+dw, height+dh);
didSomething = true;
} else {
dw = -dw; dh = -dh;
}
} else {
// "move"
if (deltaInBounds(dx,dy, 0,0)) {
movePluginTo(left+dx,top+dy, width, height);
didSomething = true;
} else {
dx = -dx; dy = -dy;
}
}
which = (which == "grow") ? "move" : "grow";
if (!didSomething) {
step();
}
}
function finish() {
document.documentElement.removeAttribute("class");
}
window.addEventListener("MozReftestInvalidate", start, false);

Просмотреть файл

@ -1,49 +0,0 @@
<!doctype html>
<html>
<head>
<style type="text/css">
#one {
position:absolute;
left:0px; top:0px;
z-index:4;
}
#two {
position:absolute;
top:100px; left:100px;
background-color:rgb(0,0,0,0);
z-index:3;
}
#three {
position:absolute;
left:100px; top:100px;
width:200px; height:200px;
background-color: rgb(255,0,0);
opacity:0.6;
z-index:2;
}
#four {
position:absolute;
top:100px; left:100px;
z-index:1;
}
</style>
<script type="text/javascript">
function paintCanvas() {
var canvas = document.getElementById("two");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "rgba(255,0,0, 0.6)";
ctx.fillRect(0,0, 200,200);
}
</script>
</style>
</head>
<body onload="paintCanvas();">
<embed id="four" type="application/x-test" width="200" height="200"
drawmode="solid" color="FFFF0000"></embed>
<div id="three"></div>
<canvas id="two" width="200" height="200"></canvas>
<embed id="one" type="application/x-test" width="400" height="400"
drawmode="solid" color="9900FF00"></embed>
</body>
</html>

Просмотреть файл

@ -1,34 +0,0 @@
<!doctype html>
<html>
<head>
<style type="text/css">
#one {
position:absolute;
left:0px; top:0px;
z-index:1;
}
#two {
position:absolute;
top:100px; left:100px;
// Set these using the canvas API
// width:200px; height:200px;
// background-color: rgb(255,0,0);
z-index:0;
}
</style>
<script type="text/javascript">
function paintCanvas() {
var canvas = document.getElementById("two");
var ctx = canvas.getContext("2d");
ctx.fillStyle = "rgb(255,0,0)";
ctx.fillRect(0,0, 200,200);
}
</script>
</style>
</head>
<body onload="paintCanvas();">
<canvas width="200" height="200" id="two"></canvas>
<embed id="one" type="application/x-test" width="400" height="400" drawmode="solid" color="9900FF00"></embed>
</body>
</html>

Просмотреть файл

@ -1,26 +0,0 @@
<!doctype html>
<html>
<head>
<style type="text/css">
#one {
position:absolute;
left:0px; top:0px;
z-index:1;
}
#two {
position:absolute;
top:0px; left:0px;
width:200px; height:200px;
z-index:0;
background-color: rgb(255,0,0);
-moz-transform-origin: 0 0;
-moz-transform: translate(100px,100px);
}
</style>
</head>
<body>
<div id="two"></div>
<embed id="one" type="application/x-test" width="400" height="400" drawmode="solid" color="9900FF00"></embed>
</body>
</html>

Просмотреть файл

@ -9,11 +9,3 @@ random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) =
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == border-padding-3.html border-padding-3-ref.html # bug 629430
random-if(cocoaWidget||d2d) fails-if(!haveTestPlugin) skip-if(!testPluginIsOOP()) == pluginproblemui-direction-1.html pluginproblemui-direction-1-ref.html
fails-if(!haveTestPlugin) skip-if(!testPluginIsOOP()) == pluginproblemui-direction-2.html pluginproblemui-direction-2-ref.html
fails-if(!haveTestPlugin) == plugin-canvas-alpha-zindex.html div-alpha-zindex.html
fails-if(!haveTestPlugin) == plugin-transform-alpha-zindex.html div-alpha-zindex.html
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == plugin-busy-alpha-zindex.html div-alpha-zindex.html
fails-if(!haveTestPlugin) == plugin-background.html plugin-background-ref.html
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == plugin-background-1-step.html plugin-background-ref.html
random-if(/^Windows\x20NT\x206\.1/.test(http.oscpu)) fails-if(!haveTestPlugin) == plugin-background-2-step.html plugin-background-ref.html
fails-if(!haveTestPlugin) == plugin-background-5-step.html plugin-background-ref.html
fails-if(!haveTestPlugin) == plugin-background-10-step.html plugin-background-ref.html

Просмотреть файл

@ -381,17 +381,13 @@ pluginHandleEvent(InstanceData* instanceData, void* event)
if (expose.x < clip.left || expose.y < clip.top ||
expose.x + expose.width > clip.right ||
expose.y + expose.height > clip.bottom) {
g_warning("expose rectangle (x=%d,y=%d,w=%d,h=%d) not in clip rectangle (l=%d,t=%d,r=%d,b=%d)",
expose.x, expose.y, expose.width, expose.height,
clip.left, clip.top, clip.right, clip.bottom);
g_warning("expose rectangle not in clip rectangle");
return 0;
}
if (expose.x < window.x || expose.y < window.y ||
expose.x + expose.width > window.x + int32_t(window.width) ||
expose.y + expose.height > window.y + int32_t(window.height)) {
g_warning("expose rectangle (x=%d,y=%d,w=%d,h=%d) not in plugin rectangle (x=%d,y=%d,w=%d,h=%d)",
expose.x, expose.y, expose.width, expose.height,
window.x, window.y, window.width, window.height);
g_warning("expose rectangle not in plugin rectangle");
return 0;
}