2010-07-21 21:17:33 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* vim: sw=2 ts=8 et :
|
|
|
|
*/
|
2012-05-21 11:12:37 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2010-07-21 21:17:33 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
2012-07-12 12:51:58 +00:00
|
|
|
#include "AutoOpenSurface.h"
|
2011-12-19 18:17:29 +00:00
|
|
|
#include "CompositorParent.h"
|
2010-07-21 21:17:33 +00:00
|
|
|
#include "gfxSharedImageSurface.h"
|
|
|
|
#include "ImageLayers.h"
|
2012-07-12 12:51:58 +00:00
|
|
|
#include "mozilla/layout/RenderFrameParent.h"
|
|
|
|
#include "mozilla/unused.h"
|
|
|
|
#include "RenderTrace.h"
|
|
|
|
#include "ShadowLayerParent.h"
|
|
|
|
#include "ShadowLayersParent.h"
|
|
|
|
#include "ShadowLayers.h"
|
|
|
|
#include "ShadowLayerUtils.h"
|
|
|
|
#include "TiledLayerBuffer.h"
|
2010-07-21 21:17:33 +00:00
|
|
|
|
|
|
|
typedef std::vector<mozilla::layers::EditReply> EditReplyVector;
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
using mozilla::layout::RenderFrameParent;
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
namespace mozilla {
|
|
|
|
namespace layers {
|
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
// Convenience accessors
|
|
|
|
static ShadowLayerParent*
|
|
|
|
cast(const PLayerParent* in)
|
|
|
|
{
|
|
|
|
return const_cast<ShadowLayerParent*>(
|
|
|
|
static_cast<const ShadowLayerParent*>(in));
|
|
|
|
}
|
|
|
|
|
|
|
|
template<class OpCreateT>
|
|
|
|
static ShadowLayerParent*
|
|
|
|
AsShadowLayer(const OpCreateT& op)
|
|
|
|
{
|
|
|
|
return cast(op.layerParent());
|
|
|
|
}
|
|
|
|
|
|
|
|
static ShadowLayerParent*
|
|
|
|
AsShadowLayer(const OpSetRoot& op)
|
|
|
|
{
|
|
|
|
return cast(op.rootParent());
|
|
|
|
}
|
|
|
|
|
|
|
|
static ShadowLayerParent*
|
|
|
|
ShadowContainer(const OpInsertAfter& op)
|
|
|
|
{
|
|
|
|
return cast(op.containerParent());
|
|
|
|
}
|
|
|
|
static ShadowLayerParent*
|
|
|
|
ShadowChild(const OpInsertAfter& op)
|
|
|
|
{
|
|
|
|
return cast(op.childLayerParent());
|
|
|
|
}
|
|
|
|
static ShadowLayerParent*
|
|
|
|
ShadowAfter(const OpInsertAfter& op)
|
|
|
|
{
|
|
|
|
return cast(op.afterParent());
|
|
|
|
}
|
|
|
|
|
|
|
|
static ShadowLayerParent*
|
|
|
|
ShadowContainer(const OpAppendChild& op)
|
|
|
|
{
|
|
|
|
return cast(op.containerParent());
|
|
|
|
}
|
|
|
|
static ShadowLayerParent*
|
|
|
|
ShadowChild(const OpAppendChild& op)
|
|
|
|
{
|
|
|
|
return cast(op.childLayerParent());
|
|
|
|
}
|
|
|
|
|
|
|
|
static ShadowLayerParent*
|
|
|
|
ShadowContainer(const OpRemoveChild& op)
|
|
|
|
{
|
|
|
|
return cast(op.containerParent());
|
|
|
|
}
|
|
|
|
static ShadowLayerParent*
|
|
|
|
ShadowChild(const OpRemoveChild& op)
|
|
|
|
{
|
|
|
|
return cast(op.childLayerParent());
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------
|
|
|
|
// ShadowLayersParent
|
2012-01-06 22:52:32 +00:00
|
|
|
ShadowLayersParent::ShadowLayersParent(ShadowLayerManager* aManager,
|
2012-07-17 23:59:45 +00:00
|
|
|
ShadowLayersManager* aLayersManager,
|
|
|
|
uint64_t aId)
|
|
|
|
: mLayerManager(aManager)
|
|
|
|
, mShadowLayersManager(aLayersManager)
|
|
|
|
, mId(aId)
|
|
|
|
, mDestroyed(false)
|
2010-07-21 21:17:33 +00:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ShadowLayersParent);
|
|
|
|
}
|
|
|
|
|
|
|
|
ShadowLayersParent::~ShadowLayersParent()
|
|
|
|
{
|
|
|
|
MOZ_COUNT_DTOR(ShadowLayersParent);
|
|
|
|
}
|
|
|
|
|
2011-01-06 04:54:47 +00:00
|
|
|
void
|
|
|
|
ShadowLayersParent::Destroy()
|
|
|
|
{
|
2011-01-12 20:13:41 +00:00
|
|
|
mDestroyed = true;
|
2011-01-06 04:54:47 +00:00
|
|
|
for (size_t i = 0; i < ManagedPLayerParent().Length(); ++i) {
|
|
|
|
ShadowLayerParent* slp =
|
|
|
|
static_cast<ShadowLayerParent*>(ManagedPLayerParent()[i]);
|
|
|
|
slp->Destroy();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-05-01 19:23:39 +00:00
|
|
|
/* virtual */
|
|
|
|
bool
|
|
|
|
ShadowLayersParent::RecvUpdateNoSwap(const InfallibleTArray<Edit>& cset,
|
2012-07-24 19:01:09 +00:00
|
|
|
const TargetConfig& targetConfig,
|
|
|
|
const bool& isFirstPaint)
|
2012-05-01 19:23:39 +00:00
|
|
|
{
|
|
|
|
InfallibleTArray<EditReply> noReplies;
|
2012-07-24 19:01:09 +00:00
|
|
|
bool success = RecvUpdate(cset, targetConfig, isFirstPaint, &noReplies);
|
2012-05-01 19:23:39 +00:00
|
|
|
NS_ABORT_IF_FALSE(noReplies.Length() == 0, "RecvUpdateNoSwap requires a sync Update to carry Edits");
|
|
|
|
return success;
|
|
|
|
}
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
bool
|
2010-11-09 02:49:00 +00:00
|
|
|
ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
2012-07-24 19:01:09 +00:00
|
|
|
const TargetConfig& targetConfig,
|
2012-03-12 15:50:07 +00:00
|
|
|
const bool& isFirstPaint,
|
2010-11-09 02:49:00 +00:00
|
|
|
InfallibleTArray<EditReply>* reply)
|
2010-07-21 21:17:33 +00:00
|
|
|
{
|
2012-02-10 23:06:17 +00:00
|
|
|
#ifdef COMPOSITOR_PERFORMANCE_WARNING
|
|
|
|
TimeStamp updateStart = TimeStamp::Now();
|
|
|
|
#endif
|
|
|
|
|
2011-05-31 16:14:54 +00:00
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] received txn with %d edits", cset.Length()));
|
2010-07-21 21:17:33 +00:00
|
|
|
|
2011-01-12 20:13:41 +00:00
|
|
|
if (mDestroyed || layer_manager()->IsDestroyed()) {
|
2010-12-27 14:48:00 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
EditReplyVector replyv;
|
|
|
|
|
|
|
|
layer_manager()->BeginTransactionWithTarget(NULL);
|
|
|
|
|
|
|
|
for (EditArray::index_type i = 0; i < cset.Length(); ++i) {
|
|
|
|
const Edit& edit = cset[i];
|
|
|
|
|
|
|
|
switch (edit.type()) {
|
|
|
|
// Create* ops
|
|
|
|
case Edit::TOpCreateThebesLayer: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] CreateThebesLayer"));
|
|
|
|
|
2010-09-24 22:41:31 +00:00
|
|
|
nsRefPtr<ShadowThebesLayer> layer =
|
|
|
|
layer_manager()->CreateShadowThebesLayer();
|
2010-10-13 22:55:45 +00:00
|
|
|
layer->SetAllocator(this);
|
2010-07-21 21:17:33 +00:00
|
|
|
AsShadowLayer(edit.get_OpCreateThebesLayer())->Bind(layer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Edit::TOpCreateContainerLayer: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] CreateContainerLayer"));
|
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
nsRefPtr<ContainerLayer> layer = layer_manager()->CreateShadowContainerLayer();
|
2010-07-21 21:17:33 +00:00
|
|
|
AsShadowLayer(edit.get_OpCreateContainerLayer())->Bind(layer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Edit::TOpCreateImageLayer: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] CreateImageLayer"));
|
|
|
|
|
2010-09-24 22:41:31 +00:00
|
|
|
nsRefPtr<ShadowImageLayer> layer =
|
|
|
|
layer_manager()->CreateShadowImageLayer();
|
|
|
|
AsShadowLayer(edit.get_OpCreateImageLayer())->Bind(layer);
|
2010-07-21 21:17:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Edit::TOpCreateColorLayer: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] CreateColorLayer"));
|
|
|
|
|
2010-10-13 22:55:45 +00:00
|
|
|
nsRefPtr<ShadowColorLayer> layer = layer_manager()->CreateShadowColorLayer();
|
2010-07-21 21:17:33 +00:00
|
|
|
AsShadowLayer(edit.get_OpCreateColorLayer())->Bind(layer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Edit::TOpCreateCanvasLayer: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] CreateCanvasLayer"));
|
|
|
|
|
2010-09-24 22:41:31 +00:00
|
|
|
nsRefPtr<ShadowCanvasLayer> layer =
|
|
|
|
layer_manager()->CreateShadowCanvasLayer();
|
2010-10-13 22:55:45 +00:00
|
|
|
layer->SetAllocator(this);
|
2010-07-21 21:17:33 +00:00
|
|
|
AsShadowLayer(edit.get_OpCreateCanvasLayer())->Bind(layer);
|
|
|
|
break;
|
|
|
|
}
|
2012-07-17 23:59:45 +00:00
|
|
|
case Edit::TOpCreateRefLayer: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] CreateRefLayer"));
|
|
|
|
|
|
|
|
nsRefPtr<ShadowRefLayer> layer =
|
|
|
|
layer_manager()->CreateShadowRefLayer();
|
|
|
|
layer->SetAllocator(this);
|
|
|
|
AsShadowLayer(edit.get_OpCreateRefLayer())->Bind(layer);
|
|
|
|
break;
|
|
|
|
}
|
2010-07-21 21:17:33 +00:00
|
|
|
|
|
|
|
// Attributes
|
|
|
|
case Edit::TOpSetLayerAttributes: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] SetLayerAttributes"));
|
|
|
|
|
|
|
|
const OpSetLayerAttributes& osla = edit.get_OpSetLayerAttributes();
|
|
|
|
Layer* layer = AsShadowLayer(osla)->AsLayer();
|
|
|
|
const LayerAttributes& attrs = osla.attrs();
|
|
|
|
|
|
|
|
const CommonLayerAttributes& common = attrs.common();
|
|
|
|
layer->SetVisibleRegion(common.visibleRegion());
|
2010-09-02 09:18:40 +00:00
|
|
|
layer->SetContentFlags(common.contentFlags());
|
2012-07-25 08:48:09 +00:00
|
|
|
layer->SetOpacity(common.opacity().value());
|
2010-07-21 21:17:33 +00:00
|
|
|
layer->SetClipRect(common.useClipRect() ? &common.clipRect() : NULL);
|
2012-07-25 08:48:09 +00:00
|
|
|
layer->SetTransform(common.transform().value());
|
|
|
|
layer->SetScale(common.xScale(), common.yScale());
|
2011-05-12 16:49:33 +00:00
|
|
|
static bool fixedPositionLayersEnabled = getenv("MOZ_ENABLE_FIXED_POSITION_LAYERS") != 0;
|
|
|
|
if (fixedPositionLayersEnabled) {
|
|
|
|
layer->SetIsFixedPosition(common.isFixedPosition());
|
2012-06-27 15:43:57 +00:00
|
|
|
layer->SetFixedPositionAnchor(common.fixedPositionAnchor());
|
2011-05-12 16:49:33 +00:00
|
|
|
}
|
2012-03-18 23:02:38 +00:00
|
|
|
if (PLayerParent* maskLayer = common.maskLayerParent()) {
|
|
|
|
layer->SetMaskLayer(cast(maskLayer)->AsLayer());
|
|
|
|
} else {
|
|
|
|
layer->SetMaskLayer(NULL);
|
|
|
|
}
|
2012-07-25 08:48:09 +00:00
|
|
|
layer->SetAnimations(common.animations());
|
2010-07-21 21:17:33 +00:00
|
|
|
|
|
|
|
typedef SpecificLayerAttributes Specific;
|
|
|
|
const SpecificLayerAttributes& specific = attrs.specific();
|
|
|
|
switch (specific.type()) {
|
|
|
|
case Specific::Tnull_t:
|
|
|
|
break;
|
|
|
|
|
2010-09-03 20:10:46 +00:00
|
|
|
case Specific::TThebesLayerAttributes: {
|
2010-07-21 21:17:33 +00:00
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] thebes layer"));
|
|
|
|
|
2010-09-03 20:10:46 +00:00
|
|
|
ShadowThebesLayer* thebesLayer =
|
|
|
|
static_cast<ShadowThebesLayer*>(layer);
|
|
|
|
const ThebesLayerAttributes& attrs =
|
|
|
|
specific.get_ThebesLayerAttributes();
|
|
|
|
|
|
|
|
thebesLayer->SetValidRegion(attrs.validRegion());
|
2010-07-21 21:17:33 +00:00
|
|
|
|
2010-09-03 20:10:46 +00:00
|
|
|
break;
|
|
|
|
}
|
2010-09-03 20:10:45 +00:00
|
|
|
case Specific::TContainerLayerAttributes:
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] container layer"));
|
|
|
|
|
|
|
|
static_cast<ContainerLayer*>(layer)->SetFrameMetrics(
|
|
|
|
specific.get_ContainerLayerAttributes().metrics());
|
|
|
|
break;
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
case Specific::TColorLayerAttributes:
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] color layer"));
|
|
|
|
|
|
|
|
static_cast<ColorLayer*>(layer)->SetColor(
|
2012-07-25 08:48:09 +00:00
|
|
|
specific.get_ColorLayerAttributes().color().value());
|
2010-07-21 21:17:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case Specific::TCanvasLayerAttributes:
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] canvas layer"));
|
|
|
|
|
|
|
|
static_cast<CanvasLayer*>(layer)->SetFilter(
|
|
|
|
specific.get_CanvasLayerAttributes().filter());
|
|
|
|
break;
|
|
|
|
|
2012-07-17 23:59:45 +00:00
|
|
|
case Specific::TRefLayerAttributes:
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] ref layer"));
|
|
|
|
|
|
|
|
static_cast<RefLayer*>(layer)->SetReferentId(
|
|
|
|
specific.get_RefLayerAttributes().id());
|
|
|
|
break;
|
|
|
|
|
2012-05-22 23:14:03 +00:00
|
|
|
case Specific::TImageLayerAttributes: {
|
2010-07-21 21:17:33 +00:00
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] image layer"));
|
|
|
|
|
2012-05-22 23:14:03 +00:00
|
|
|
ImageLayer* imageLayer = static_cast<ImageLayer*>(layer);
|
|
|
|
const ImageLayerAttributes& attrs = specific.get_ImageLayerAttributes();
|
|
|
|
imageLayer->SetFilter(attrs.filter());
|
|
|
|
imageLayer->SetForceSingleTile(attrs.forceSingleTile());
|
2010-07-21 21:17:33 +00:00
|
|
|
break;
|
2012-05-22 23:14:03 +00:00
|
|
|
}
|
2010-07-21 21:17:33 +00:00
|
|
|
default:
|
|
|
|
NS_RUNTIMEABORT("not reached");
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Tree ops
|
|
|
|
case Edit::TOpSetRoot: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] SetRoot"));
|
|
|
|
|
2010-09-03 20:10:45 +00:00
|
|
|
mRoot = AsShadowLayer(edit.get_OpSetRoot())->AsContainer();
|
2010-07-21 21:17:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Edit::TOpInsertAfter: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] InsertAfter"));
|
|
|
|
|
|
|
|
const OpInsertAfter& oia = edit.get_OpInsertAfter();
|
|
|
|
ShadowContainer(oia)->AsContainer()->InsertAfter(
|
|
|
|
ShadowChild(oia)->AsLayer(), ShadowAfter(oia)->AsLayer());
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Edit::TOpAppendChild: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] AppendChild"));
|
|
|
|
|
|
|
|
const OpAppendChild& oac = edit.get_OpAppendChild();
|
|
|
|
ShadowContainer(oac)->AsContainer()->InsertAfter(
|
|
|
|
ShadowChild(oac)->AsLayer(), NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Edit::TOpRemoveChild: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] RemoveChild"));
|
|
|
|
|
|
|
|
const OpRemoveChild& orc = edit.get_OpRemoveChild();
|
|
|
|
Layer* childLayer = ShadowChild(orc)->AsLayer();
|
|
|
|
ShadowContainer(orc)->AsContainer()->RemoveChild(childLayer);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-04-13 15:17:39 +00:00
|
|
|
case Edit::TOpPaintTiledLayerBuffer: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] Paint TiledLayerBuffer"));
|
|
|
|
const OpPaintTiledLayerBuffer& op = edit.get_OpPaintTiledLayerBuffer();
|
|
|
|
ShadowLayerParent* shadow = AsShadowLayer(op);
|
|
|
|
|
|
|
|
ShadowThebesLayer* shadowLayer = static_cast<ShadowThebesLayer*>(shadow->AsLayer());
|
|
|
|
TiledLayerComposer* tileComposer = shadowLayer->AsTiledLayerComposer();
|
|
|
|
|
|
|
|
NS_ASSERTION(tileComposer, "shadowLayer is not a tile composer");
|
|
|
|
|
|
|
|
BasicTiledLayerBuffer* p = (BasicTiledLayerBuffer*)op.tiledLayerBuffer();
|
|
|
|
tileComposer->PaintedTiledLayerBuffer(p);
|
|
|
|
break;
|
|
|
|
}
|
2010-07-21 21:17:33 +00:00
|
|
|
case Edit::TOpPaintThebesBuffer: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] Paint ThebesLayer"));
|
|
|
|
|
|
|
|
const OpPaintThebesBuffer& op = edit.get_OpPaintThebesBuffer();
|
|
|
|
ShadowLayerParent* shadow = AsShadowLayer(op);
|
|
|
|
ShadowThebesLayer* thebes =
|
|
|
|
static_cast<ShadowThebesLayer*>(shadow->AsLayer());
|
|
|
|
const ThebesBuffer& newFront = op.newFrontBuffer();
|
|
|
|
|
2012-02-24 16:35:04 +00:00
|
|
|
RenderTraceInvalidateStart(thebes, "FF00FF", op.updatedRegion().GetBounds());
|
2012-02-17 22:05:03 +00:00
|
|
|
|
2011-10-10 16:47:27 +00:00
|
|
|
OptionalThebesBuffer newBack;
|
2010-09-14 05:23:08 +00:00
|
|
|
nsIntRegion newValidRegion;
|
2010-11-05 07:17:07 +00:00
|
|
|
OptionalThebesBuffer readonlyFront;
|
|
|
|
nsIntRegion frontUpdatedRegion;
|
2010-09-14 05:23:08 +00:00
|
|
|
thebes->Swap(newFront, op.updatedRegion(),
|
2011-06-22 12:11:28 +00:00
|
|
|
&newBack, &newValidRegion,
|
2010-11-05 07:17:07 +00:00
|
|
|
&readonlyFront, &frontUpdatedRegion);
|
2010-09-14 05:23:08 +00:00
|
|
|
replyv.push_back(
|
|
|
|
OpThebesBufferSwap(
|
|
|
|
shadow, NULL,
|
2011-06-22 12:11:28 +00:00
|
|
|
newBack, newValidRegion,
|
2010-11-05 07:17:07 +00:00
|
|
|
readonlyFront, frontUpdatedRegion));
|
2012-02-17 22:05:03 +00:00
|
|
|
|
2012-02-24 16:35:04 +00:00
|
|
|
RenderTraceInvalidateEnd(thebes, "FF00FF");
|
2010-07-21 21:17:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Edit::TOpPaintCanvas: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] Paint CanvasLayer"));
|
|
|
|
|
|
|
|
const OpPaintCanvas& op = edit.get_OpPaintCanvas();
|
|
|
|
ShadowLayerParent* shadow = AsShadowLayer(op);
|
|
|
|
ShadowCanvasLayer* canvas =
|
|
|
|
static_cast<ShadowCanvasLayer*>(shadow->AsLayer());
|
|
|
|
|
2012-02-24 16:35:04 +00:00
|
|
|
RenderTraceInvalidateStart(canvas, "FF00FF", canvas->GetVisibleRegion().GetBounds());
|
2012-02-17 22:05:03 +00:00
|
|
|
|
2011-09-27 22:19:28 +00:00
|
|
|
canvas->SetAllocator(this);
|
|
|
|
CanvasSurface newBack;
|
|
|
|
canvas->Swap(op.newFrontBuffer(), op.needYFlip(), &newBack);
|
2011-03-27 23:59:46 +00:00
|
|
|
canvas->Updated();
|
2010-07-21 21:17:33 +00:00
|
|
|
replyv.push_back(OpBufferSwap(shadow, NULL,
|
2011-04-20 21:45:57 +00:00
|
|
|
newBack));
|
2010-07-21 21:17:33 +00:00
|
|
|
|
2012-02-24 16:35:04 +00:00
|
|
|
RenderTraceInvalidateEnd(canvas, "FF00FF");
|
2010-07-21 21:17:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Edit::TOpPaintImage: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] Paint ImageLayer"));
|
|
|
|
|
|
|
|
const OpPaintImage& op = edit.get_OpPaintImage();
|
|
|
|
ShadowLayerParent* shadow = AsShadowLayer(op);
|
|
|
|
ShadowImageLayer* image =
|
|
|
|
static_cast<ShadowImageLayer*>(shadow->AsLayer());
|
|
|
|
|
2012-02-24 16:35:04 +00:00
|
|
|
RenderTraceInvalidateStart(image, "FF00FF", image->GetVisibleRegion().GetBounds());
|
|
|
|
|
2011-09-27 22:19:26 +00:00
|
|
|
image->SetAllocator(this);
|
2011-04-20 23:21:56 +00:00
|
|
|
SharedImage newBack;
|
2011-04-20 21:45:57 +00:00
|
|
|
image->Swap(op.newFrontBuffer(), &newBack);
|
2011-04-21 04:38:39 +00:00
|
|
|
replyv.push_back(OpImageSwap(shadow, NULL,
|
|
|
|
newBack));
|
2010-07-21 21:17:33 +00:00
|
|
|
|
2012-02-24 16:35:04 +00:00
|
|
|
RenderTraceInvalidateEnd(image, "FF00FF");
|
2010-07-21 21:17:33 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
NS_RUNTIMEABORT("not reached");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-26 13:20:42 +00:00
|
|
|
layer_manager()->EndTransaction(NULL, NULL, LayerManager::END_NO_IMMEDIATE_REDRAW);
|
2010-07-21 21:17:33 +00:00
|
|
|
|
|
|
|
reply->SetCapacity(replyv.size());
|
2010-07-21 23:13:24 +00:00
|
|
|
if (replyv.size() > 0) {
|
|
|
|
reply->AppendElements(&replyv.front(), replyv.size());
|
|
|
|
}
|
2010-07-21 21:17:33 +00:00
|
|
|
|
2010-09-14 05:23:08 +00:00
|
|
|
// Ensure that any pending operations involving back and front
|
|
|
|
// buffers have completed, so that neither process stomps on the
|
|
|
|
// other's buffer contents.
|
|
|
|
ShadowLayerManager::PlatformSyncBeforeReplyUpdate();
|
|
|
|
|
2012-07-24 19:01:09 +00:00
|
|
|
mShadowLayersManager->ShadowLayersUpdated(this, targetConfig, isFirstPaint);
|
2010-08-20 23:24:41 +00:00
|
|
|
|
2012-02-10 23:06:17 +00:00
|
|
|
#ifdef COMPOSITOR_PERFORMANCE_WARNING
|
2012-03-19 11:55:37 +00:00
|
|
|
int compositeTime = (int)(mozilla::TimeStamp::Now() - updateStart).ToMilliseconds();
|
|
|
|
if (compositeTime > 15) {
|
|
|
|
printf_stderr("Compositor: Layers update took %i ms (blocking gecko).\n", compositeTime);
|
|
|
|
}
|
2012-02-10 23:06:17 +00:00
|
|
|
#endif
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-06-01 12:42:34 +00:00
|
|
|
bool
|
|
|
|
ShadowLayersParent::RecvDrawToSurface(const SurfaceDescriptor& surfaceIn,
|
|
|
|
SurfaceDescriptor* surfaceOut)
|
|
|
|
{
|
|
|
|
*surfaceOut = surfaceIn;
|
2012-06-01 12:42:36 +00:00
|
|
|
if (mDestroyed || layer_manager()->IsDestroyed()) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-12 12:51:58 +00:00
|
|
|
AutoOpenSurface sharedSurface(OPEN_READ_WRITE, surfaceIn);
|
2012-06-01 12:42:36 +00:00
|
|
|
|
|
|
|
nsRefPtr<gfxASurface> localSurface =
|
2012-07-12 12:51:58 +00:00
|
|
|
gfxPlatform::GetPlatform()->CreateOffscreenSurface(sharedSurface.Size(),
|
|
|
|
sharedSurface.ContentType());
|
2012-06-01 12:42:36 +00:00
|
|
|
nsRefPtr<gfxContext> context = new gfxContext(localSurface);
|
|
|
|
|
|
|
|
layer_manager()->BeginTransactionWithTarget(context);
|
|
|
|
layer_manager()->EndTransaction(NULL, NULL);
|
2012-07-12 12:51:58 +00:00
|
|
|
nsRefPtr<gfxContext> contextForCopy = new gfxContext(sharedSurface.Get());
|
2012-06-01 12:42:36 +00:00
|
|
|
contextForCopy->SetOperator(gfxContext::OPERATOR_SOURCE);
|
|
|
|
contextForCopy->DrawSurface(localSurface, localSurface->GetSize());
|
2012-06-01 12:42:34 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-07-12 12:51:58 +00:00
|
|
|
PGrallocBufferParent*
|
|
|
|
ShadowLayersParent::AllocPGrallocBuffer(const gfxIntSize& aSize,
|
|
|
|
const gfxContentType& aContent,
|
|
|
|
MaybeMagicGrallocBufferHandle* aOutHandle)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
|
|
|
return GrallocBufferActor::Create(aSize, aContent, aOutHandle);
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("No gralloc buffers for you");
|
|
|
|
return nsnull;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ShadowLayersParent::DeallocPGrallocBuffer(PGrallocBufferParent* actor)
|
|
|
|
{
|
|
|
|
#ifdef MOZ_HAVE_SURFACEDESCRIPTORGRALLOC
|
|
|
|
delete actor;
|
|
|
|
return true;
|
|
|
|
#else
|
|
|
|
NS_RUNTIMEABORT("Um, how did we get here?");
|
|
|
|
return false;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
PLayerParent*
|
|
|
|
ShadowLayersParent::AllocPLayer()
|
|
|
|
{
|
|
|
|
return new ShadowLayerParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ShadowLayersParent::DeallocPLayer(PLayerParent* actor)
|
|
|
|
{
|
|
|
|
delete actor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-27 22:19:26 +00:00
|
|
|
void
|
|
|
|
ShadowLayersParent::DestroySharedSurface(gfxSharedImageSurface* aSurface)
|
|
|
|
{
|
|
|
|
layer_manager()->DestroySharedSurface(aSurface, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowLayersParent::DestroySharedSurface(SurfaceDescriptor* aSurface)
|
|
|
|
{
|
|
|
|
layer_manager()->DestroySharedSurface(aSurface, this);
|
|
|
|
}
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|