Skip to content

Commit

Permalink
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow…
Browse files Browse the repository at this point in the history
…,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE

Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.

Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
  • Loading branch information
Bas-moz committed Apr 10, 2013
1 parent c83dcfe commit 4c76031
Show file tree
Hide file tree
Showing 213 changed files with 18,546 additions and 9,693 deletions.
2 changes: 1 addition & 1 deletion configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -8078,7 +8078,7 @@ dnl ========================================================
dnl Graphics checks.
dnl ========================================================

if test "${OS_TARGET}" = "WINNT" -o "${OS_ARCH}" = "Darwin" -o "${MOZ_WIDGET_TOOLKIT}" = "android" -o "${MOZ_WIDGET_TOOLKIT}" = "gtk2"; then
if test "${OS_TARGET}" = "WINNT" -o "${MOZ_WIDGET_TOOLKIT}" = "android" -o "${MOZ_WIDGET_TOOLKIT}" = "gtk2"; then
MOZ_ENABLE_SKIA=1
else
MOZ_ENABLE_SKIA=
Expand Down
19 changes: 19 additions & 0 deletions dom/base/nsDOMWindowUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2207,6 +2207,25 @@ nsDOMWindowUtils::GetLayerManagerType(nsAString& aType)
return NS_OK;
}

NS_IMETHODIMP
nsDOMWindowUtils::GetLayerManagerRemote(bool* retval)
{
if (!nsContentUtils::IsCallerChrome()) {
return NS_ERROR_DOM_SECURITY_ERR;
}

nsCOMPtr<nsIWidget> widget = GetWidget();
if (!widget)
return NS_ERROR_FAILURE;

LayerManager *mgr = widget->GetLayerManager();
if (!mgr)
return NS_ERROR_FAILURE;

*retval = !!mgr->AsShadowForwarder();
return NS_OK;
}

NS_IMETHODIMP
nsDOMWindowUtils::StartFrameTimeRecording(uint32_t *startIndex)
{
Expand Down
9 changes: 8 additions & 1 deletion dom/interfaces/base/nsIDOMWindowUtils.idl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ interface nsIDOMClientRect;
interface nsIURI;
interface nsIDOMEventTarget;

[scriptable, uuid(ab9e9c45-1910-458c-a043-79cbbfc89f4d)]
[scriptable, uuid(04429978-3417-411b-882b-81cd5cec5ecd)]
interface nsIDOMWindowUtils : nsISupports {

/**
Expand Down Expand Up @@ -1063,6 +1063,13 @@ interface nsIDOMWindowUtils : nsISupports {
* error if there is no widget associated with this window.
*/
readonly attribute AString layerManagerType;

/**
* True if the layer manager for the widget associated with this window is
* forwarding layers to a remote compositor, false otherwise. Throws an
* error if there is no widget associated with this window.
*/
readonly attribute boolean layerManagerRemote;

/**
* Record (and return) frame-intervals and paint-times for frames which were presented
Expand Down
6 changes: 3 additions & 3 deletions dom/ipc/PBrowser.ipdl
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ include "mozilla/dom/TabMessageUtils.h";
include "mozilla/dom/ScreenOrientation.h";
include "mozilla/dom/PermissionMessageUtils.h";
include "mozilla/layout/RenderFrameUtils.h";
include "mozilla/layers/CompositorTypes.h";

using IPC::Principal;
using gfxMatrix;
using gfxRect;
using gfxSize;
using mozilla::layers::LayersBackend;
using mozilla::layers::FrameMetrics;
using mozilla::layout::ScrollingBehavior;
using mozilla::void_t;
Expand All @@ -50,7 +50,7 @@ using nsTextEvent;
using nsTouchEvent;
using RemoteDOMEvent;
using mozilla::dom::ScreenOrientation;

using mozilla::layers::TextureFactoryIdentifier;
namespace mozilla {
namespace dom {

Expand Down Expand Up @@ -209,7 +209,7 @@ parent:
*/
sync PRenderFrame()
returns (ScrollingBehavior scrolling,
LayersBackend backend, int32_t maxTextureSize, uint64_t layersId);
TextureFactoryIdentifier textureFactoryIdentifier, uint64_t layersId);

/**
* Starts an offline application cache update.
Expand Down
21 changes: 9 additions & 12 deletions dom/ipc/TabChild.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2029,8 +2029,7 @@ TabChild::RecvSetAppType(const nsString& aAppType)

PRenderFrameChild*
TabChild::AllocPRenderFrame(ScrollingBehavior* aScrolling,
LayersBackend* aBackend,
int32_t* aMaxTextureSize,
TextureFactoryIdentifier* aTextureFactoryIdentifier,
uint64_t* aLayersId)
{
return new RenderFrameChild();
Expand Down Expand Up @@ -2089,12 +2088,11 @@ TabChild::InitRenderingState()
{
static_cast<PuppetWidget*>(mWidget.get())->InitIMEState();

LayersBackend be;
uint64_t id;
int32_t maxTextureSize;
TextureFactoryIdentifier textureFactoryIdentifier;
RenderFrameChild* remoteFrame =
static_cast<RenderFrameChild*>(SendPRenderFrameConstructor(
&mScrolling, &be, &maxTextureSize, &id));
&mScrolling, &textureFactoryIdentifier, &id));
if (!remoteFrame) {
NS_WARNING("failed to construct RenderFrame");
return false;
Expand All @@ -2104,15 +2102,14 @@ TabChild::InitRenderingState()
if (id != 0) {
// Pushing layers transactions directly to a separate
// compositor context.
PCompositorChild* compositorChild = CompositorChild::Get();
PCompositorChild* compositorChild = CompositorChild::Get();
if (!compositorChild) {
NS_WARNING("failed to get CompositorChild instance");
return false;
}
shadowManager =
compositorChild->SendPLayersConstructor(be, id,
&be,
&maxTextureSize);
compositorChild->SendPLayersConstructor(textureFactoryIdentifier.mParentBackend,
id, &textureFactoryIdentifier);
} else {
// Pushing transactions to the parent content.
shadowManager = remoteFrame->SendPLayersConstructor();
Expand All @@ -2126,11 +2123,11 @@ TabChild::InitRenderingState()
}

ShadowLayerForwarder* lf =
mWidget->GetLayerManager(shadowManager, be)->AsShadowForwarder();
mWidget->GetLayerManager(shadowManager, textureFactoryIdentifier.mParentBackend)
->AsShadowForwarder();
NS_ABORT_IF_FALSE(lf && lf->HasShadowManager(),
"PuppetWidget should have shadow manager");
lf->SetParentBackendType(be);
lf->SetMaxTextureSize(maxTextureSize);
lf->IdentifyTextureHost(textureFactoryIdentifier);

mRemoteFrame = remoteFrame;

Expand Down
7 changes: 5 additions & 2 deletions dom/ipc/TabChild.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ namespace layout {
class RenderFrameChild;
}

namespace layers {
struct TextureFactoryIdentifier;
}

namespace dom {

class TabChild;
Expand Down Expand Up @@ -332,8 +336,7 @@ class TabChild : public PBrowserChild,

protected:
virtual PRenderFrameChild* AllocPRenderFrame(ScrollingBehavior* aScrolling,
LayersBackend* aBackend,
int32_t* aMaxTextureSize,
TextureFactoryIdentifier* aTextureFactoryIdentifier,
uint64_t* aLayersId) MOZ_OVERRIDE;
virtual bool DeallocPRenderFrame(PRenderFrameChild* aFrame) MOZ_OVERRIDE;
virtual bool RecvDestroy() MOZ_OVERRIDE;
Expand Down
8 changes: 3 additions & 5 deletions dom/ipc/TabParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1253,8 +1253,7 @@ TabParent::HandleDelayedDialogs()

PRenderFrameParent*
TabParent::AllocPRenderFrame(ScrollingBehavior* aScrolling,
LayersBackend* aBackend,
int32_t* aMaxTextureSize,
TextureFactoryIdentifier* aTextureFactoryIdentifier,
uint64_t* aLayersId)
{
MOZ_ASSERT(ManagedPRenderFrameParent().IsEmpty());
Expand All @@ -1268,7 +1267,7 @@ TabParent::AllocPRenderFrame(ScrollingBehavior* aScrolling,
*aScrolling = UseAsyncPanZoom() ? ASYNC_PAN_ZOOM : DEFAULT_SCROLLING;
return new RenderFrameParent(frameLoader,
*aScrolling,
aBackend, aMaxTextureSize, aLayersId);
aTextureFactoryIdentifier, aLayersId);
}

bool
Expand Down Expand Up @@ -1410,8 +1409,7 @@ TabParent::RecvBrowserFrameOpenWindow(PBrowserParent* aOpener,
bool
TabParent::RecvPRenderFrameConstructor(PRenderFrameParent* actor,
ScrollingBehavior* scrolling,
LayersBackend* backend,
int32_t* maxTextureSize,
TextureFactoryIdentifier* factoryIdentifier,
uint64_t* layersId)
{
RenderFrameParent* rfp = GetRenderFrame();
Expand Down
9 changes: 4 additions & 5 deletions dom/ipc/TabParent.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace mozilla {

namespace layers {
struct FrameMetrics;
struct TextureFactoryIdentifier;
}

namespace layout {
Expand Down Expand Up @@ -96,8 +97,7 @@ class TabParent : public PBrowserParent
virtual bool RecvEvent(const RemoteDOMEvent& aEvent);
virtual bool RecvPRenderFrameConstructor(PRenderFrameParent* actor,
ScrollingBehavior* scrolling,
LayersBackend* backend,
int32_t* maxTextureSize,
TextureFactoryIdentifier* identifier,
uint64_t* layersId);
virtual bool RecvBrowserFrameOpenWindow(PBrowserParent* aOpener,
const nsString& aURL,
Expand Down Expand Up @@ -191,7 +191,7 @@ class TabParent : public PBrowserParent
virtual POfflineCacheUpdateParent* AllocPOfflineCacheUpdate(
const URIParams& aManifestURI,
const URIParams& aDocumentURI,
const bool& stickDocument);
const bool& stickDocument) MOZ_OVERRIDE;
virtual bool DeallocPOfflineCacheUpdate(POfflineCacheUpdateParent* actor);

JSBool GetGlobalJSObject(JSContext* cx, JSObject** globalp);
Expand Down Expand Up @@ -255,8 +255,7 @@ class TabParent : public PBrowserParent
bool AllowContentIME();

virtual PRenderFrameParent* AllocPRenderFrame(ScrollingBehavior* aScrolling,
LayersBackend* aBackend,
int32_t* aMaxTextureSize,
TextureFactoryIdentifier* aTextureFactoryIdentifier,
uint64_t* aLayersId) MOZ_OVERRIDE;
virtual bool DeallocPRenderFrame(PRenderFrameParent* aFrame) MOZ_OVERRIDE;

Expand Down
4 changes: 2 additions & 2 deletions dom/plugins/ipc/PluginInstanceParent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ PluginInstanceParent::DestroyBackground()
unused << SendPPluginBackgroundDestroyerConstructor(pbd);
}

SurfaceDescriptor
mozilla::plugins::SurfaceDescriptor
PluginInstanceParent::BackgroundDescriptor()
{
NS_ABORT_IF_FALSE(mBackground, "Need a background here");
Expand All @@ -941,7 +941,7 @@ PluginInstanceParent::BackgroundDescriptor()

// If this is ever used, which it shouldn't be, it will trigger a
// hard assertion in IPDL-generated code.
return SurfaceDescriptor();
return mozilla::plugins::SurfaceDescriptor();
}

ImageContainer*
Expand Down
2 changes: 0 additions & 2 deletions gfx/2d/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,11 @@ CPPSRCS += \
endif

ifeq (cocoa,$(MOZ_WIDGET_TOOLKIT))
ifdef MOZ_ENABLE_SKIA
CPPSRCS += \
ScaledFontMac.cpp \
$(NULL)

endif
endif

ifeq ($(MOZ_WIDGET_TOOLKIT),$(findstring $(MOZ_WIDGET_TOOLKIT),android gtk2 gonk qt))
CPPSRCS += \
Expand Down
54 changes: 54 additions & 0 deletions gfx/2d/Matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,60 @@ class Matrix
}
};

class Matrix4x4
{
public:
Matrix4x4()
: _11(1.0f), _12(0.0f), _13(0.0f), _14(0.0f)
, _21(0.0f), _22(1.0f), _23(0.0f), _24(0.0f)
, _31(0.0f), _32(0.0f), _33(1.0f), _34(0.0f)
, _41(0.0f), _42(0.0f), _43(0.0f), _44(1.0f)
{}

Float _11, _12, _13, _14;
Float _21, _22, _23, _24;
Float _31, _32, _33, _34;
Float _41, _42, _43, _44;

/**
* Returns true if the matrix is isomorphic to a 2D affine transformation.
*/
bool Is2D() const
{
if (_13 != 0.0f || _14 != 0.0f ||
_23 != 0.0f || _24 != 0.0f ||
_31 != 0.0f || _32 != 0.0f || _33 != 1.0f || _34 != 0.0f ||
_43 != 0.0f || _44 != 1.0f) {
return false;
}
return true;
}

Matrix As2D() const
{
MOZ_ASSERT(Is2D(), "Matrix is not a 2D affine transform");

return Matrix(_11, _12, _21, _22, _41, _42);
}

// Apply a scale to this matrix. This scale will be applied -before- the
// existing transformation of the matrix.
Matrix4x4 &Scale(Float aX, Float aY, Float aZ)
{
_11 *= aX;
_12 *= aX;
_13 *= aX;
_21 *= aY;
_22 *= aY;
_23 *= aY;
_31 *= aZ;
_32 *= aZ;
_33 *= aZ;

return *this;
}
};

}
}

Expand Down
2 changes: 1 addition & 1 deletion gfx/2d/Rect.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct Rect :

GFX2D_API void NudgeToIntegers();

bool ToIntRect(IntRect *aOut)
bool ToIntRect(IntRect *aOut) const
{
*aOut = IntRect(int32_t(X()), int32_t(Y()),
int32_t(Width()), int32_t(Height()));
Expand Down
6 changes: 5 additions & 1 deletion gfx/2d/Types.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,12 @@ enum SurfaceFormat
{
FORMAT_B8G8R8A8,
FORMAT_B8G8R8X8,
FORMAT_R8G8B8A8,
FORMAT_R8G8B8X8,
FORMAT_R5G6B5,
FORMAT_A8
FORMAT_A8,
FORMAT_YUV,
FORMAT_UNKNOWN
};

enum BackendType
Expand Down
30 changes: 1 addition & 29 deletions gfx/gl/GLContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -810,35 +810,7 @@ GLContext::CreateTextureImage(const nsIntSize& aSize,
GLenum aWrapMode,
TextureImage::Flags aFlags)
{
bool useNearestFilter = aFlags & TextureImage::UseNearestFilter;
MakeCurrent();

GLuint texture;
fGenTextures(1, &texture);

fActiveTexture(LOCAL_GL_TEXTURE0);
fBindTexture(LOCAL_GL_TEXTURE_2D, texture);

GLint texfilter = useNearestFilter ? LOCAL_GL_NEAREST : LOCAL_GL_LINEAR;
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MIN_FILTER, texfilter);
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_MAG_FILTER, texfilter);
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_S, aWrapMode);
fTexParameteri(LOCAL_GL_TEXTURE_2D, LOCAL_GL_TEXTURE_WRAP_T, aWrapMode);

return CreateBasicTextureImage(texture, aSize, aWrapMode, aContentType, this, aFlags);
}

already_AddRefed<TextureImage>
GLContext::CreateBasicTextureImage(GLuint aTexture,
const nsIntSize& aSize,
GLenum aWrapMode,
TextureImage::ContentType aContentType,
GLContext* aContext,
TextureImage::Flags aFlags)
{
nsRefPtr<BasicTextureImage> teximage(
new BasicTextureImage(aTexture, aSize, aWrapMode, aContentType, aContext, aFlags));
return teximage.forget();
return CreateBasicTextureImage(this, aSize, aContentType, aWrapMode, aFlags);
}

void GLContext::ApplyFilterToBoundTexture(gfxPattern::GraphicsFilter aFilter)
Expand Down
Loading

0 comments on commit 4c76031

Please sign in to comment.