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 :
|
|
|
|
*/
|
|
|
|
/* ***** 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 <vector>
|
|
|
|
|
|
|
|
#include "ShadowLayersParent.h"
|
|
|
|
#include "ShadowLayerParent.h"
|
|
|
|
#include "ShadowLayers.h"
|
|
|
|
|
|
|
|
#include "mozilla/unused.h"
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
#include "mozilla/layout/RenderFrameParent.h"
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
#include "gfxSharedImageSurface.h"
|
|
|
|
|
|
|
|
#include "ImageLayers.h"
|
|
|
|
|
|
|
|
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
|
|
|
|
ShadowLayersParent::ShadowLayersParent(ShadowLayerManager* aManager)
|
2011-01-12 20:13:41 +00:00
|
|
|
: mDestroyed(false)
|
2010-07-21 21:17:33 +00:00
|
|
|
{
|
|
|
|
MOZ_COUNT_CTOR(ShadowLayersParent);
|
|
|
|
mLayerManager = aManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
bool
|
2010-11-09 02:49:00 +00:00
|
|
|
ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
|
|
|
|
InfallibleTArray<EditReply>* reply)
|
2010-07-21 21:17:33 +00:00
|
|
|
{
|
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();
|
2010-10-13 22:55:45 +00:00
|
|
|
layer->SetAllocator(this);
|
2010-09-24 22:41:31 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
case Edit::TOpCreateThebesBuffer: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] CreateThebesBuffer"));
|
|
|
|
|
|
|
|
const OpCreateThebesBuffer& otb = edit.get_OpCreateThebesBuffer();
|
|
|
|
ShadowThebesLayer* thebes = static_cast<ShadowThebesLayer*>(
|
|
|
|
AsShadowLayer(otb)->AsLayer());
|
|
|
|
|
2010-09-28 22:05:30 +00:00
|
|
|
thebes->SetFrontBuffer(otb.initialFront(), otb.frontValidRegion(),
|
|
|
|
otb.xResolution(), otb.yResolution());
|
2010-07-21 21:17:33 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Edit::TOpCreateCanvasBuffer: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] CreateCanvasBuffer"));
|
|
|
|
|
|
|
|
const OpCreateCanvasBuffer& ocb = edit.get_OpCreateCanvasBuffer();
|
|
|
|
ShadowCanvasLayer* canvas = static_cast<ShadowCanvasLayer*>(
|
|
|
|
AsShadowLayer(ocb)->AsLayer());
|
|
|
|
|
2011-06-10 01:17:02 +00:00
|
|
|
canvas->Init(ocb.initialFront(), ocb.size(), ocb.needYFlip());
|
2010-07-21 21:17:33 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Edit::TOpCreateImageBuffer: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] CreateImageBuffer"));
|
|
|
|
|
|
|
|
const OpCreateImageBuffer ocb = edit.get_OpCreateImageBuffer();
|
|
|
|
ShadowImageLayer* image = static_cast<ShadowImageLayer*>(
|
|
|
|
AsShadowLayer(ocb)->AsLayer());
|
|
|
|
|
2011-04-20 21:45:57 +00:00
|
|
|
image->Init(ocb.initialFront(), ocb.size());
|
2010-07-21 21:17:33 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
2010-09-03 03:05:01 +00:00
|
|
|
case Edit::TOpDestroyThebesFrontBuffer: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] DestroyThebesFrontBuffer"));
|
|
|
|
|
|
|
|
const OpDestroyThebesFrontBuffer& odfb =
|
|
|
|
edit.get_OpDestroyThebesFrontBuffer();
|
|
|
|
ShadowThebesLayer* thebes = static_cast<ShadowThebesLayer*>(
|
|
|
|
AsShadowLayer(odfb)->AsLayer());
|
|
|
|
|
|
|
|
thebes->DestroyFrontBuffer();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Edit::TOpDestroyCanvasFrontBuffer: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] DestroyCanvasFrontBuffer"));
|
|
|
|
|
|
|
|
const OpDestroyCanvasFrontBuffer& odfb =
|
|
|
|
edit.get_OpDestroyCanvasFrontBuffer();
|
|
|
|
ShadowCanvasLayer* canvas = static_cast<ShadowCanvasLayer*>(
|
|
|
|
AsShadowLayer(odfb)->AsLayer());
|
|
|
|
|
|
|
|
canvas->DestroyFrontBuffer();
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case Edit::TOpDestroyImageFrontBuffer: {
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] DestroyImageFrontBuffer"));
|
|
|
|
|
|
|
|
const OpDestroyImageFrontBuffer& odfb =
|
|
|
|
edit.get_OpDestroyImageFrontBuffer();
|
|
|
|
ShadowImageLayer* image = static_cast<ShadowImageLayer*>(
|
|
|
|
AsShadowLayer(odfb)->AsLayer());
|
|
|
|
|
|
|
|
image->DestroyFrontBuffer();
|
|
|
|
|
|
|
|
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());
|
2010-07-21 21:17:33 +00:00
|
|
|
layer->SetOpacity(common.opacity());
|
|
|
|
layer->SetClipRect(common.useClipRect() ? &common.clipRect() : NULL);
|
|
|
|
layer->SetTransform(common.transform());
|
2011-01-26 06:26:37 +00:00
|
|
|
layer->SetTileSourceRect(common.useTileSourceRect() ? &common.tileSourceRect() : NULL);
|
2011-05-12 16:49:33 +00:00
|
|
|
static bool fixedPositionLayersEnabled = getenv("MOZ_ENABLE_FIXED_POSITION_LAYERS") != 0;
|
|
|
|
if (fixedPositionLayersEnabled) {
|
|
|
|
layer->SetIsFixedPosition(common.isFixedPosition());
|
|
|
|
}
|
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());
|
|
|
|
thebesLayer->SetResolution(attrs.xResolution(), attrs.yResolution());
|
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(
|
|
|
|
specific.get_ColorLayerAttributes().color());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Specific::TCanvasLayerAttributes:
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] canvas layer"));
|
|
|
|
|
|
|
|
static_cast<CanvasLayer*>(layer)->SetFilter(
|
|
|
|
specific.get_CanvasLayerAttributes().filter());
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Specific::TImageLayerAttributes:
|
|
|
|
MOZ_LAYERS_LOG(("[ParentSide] image layer"));
|
|
|
|
|
|
|
|
static_cast<ImageLayer*>(layer)->SetFilter(
|
|
|
|
specific.get_ImageLayerAttributes().filter());
|
|
|
|
break;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
2010-09-14 05:23:08 +00:00
|
|
|
ThebesBuffer newBack;
|
|
|
|
nsIntRegion newValidRegion;
|
|
|
|
float newXResolution, newYResolution;
|
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(),
|
2010-11-05 07:17:07 +00:00
|
|
|
&newBack, &newValidRegion, &newXResolution, &newYResolution,
|
|
|
|
&readonlyFront, &frontUpdatedRegion);
|
2010-09-14 05:23:08 +00:00
|
|
|
replyv.push_back(
|
|
|
|
OpThebesBufferSwap(
|
|
|
|
shadow, NULL,
|
2010-11-05 07:17:07 +00:00
|
|
|
newBack, newValidRegion, newXResolution, newYResolution,
|
|
|
|
readonlyFront, frontUpdatedRegion));
|
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());
|
|
|
|
|
2011-04-20 21:45:57 +00:00
|
|
|
SurfaceDescriptor newFront = op.newFrontBuffer();
|
|
|
|
SurfaceDescriptor newBack;
|
|
|
|
canvas->Swap(op.newFrontBuffer(), &newBack);
|
2011-01-11 21:34:31 +00:00
|
|
|
if (newFront == newBack) {
|
2011-04-20 21:45:57 +00:00
|
|
|
newFront = SurfaceDescriptor();
|
2011-01-11 21:34:31 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
|
|
|
|
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());
|
|
|
|
|
2011-05-25 08:09:55 +00:00
|
|
|
SharedImage newFront = op.newFrontBuffer();
|
2011-04-20 23:21:56 +00:00
|
|
|
SharedImage newBack;
|
2011-04-20 21:45:57 +00:00
|
|
|
image->Swap(op.newFrontBuffer(), &newBack);
|
2011-05-25 08:09:55 +00:00
|
|
|
if (newFront == newBack) {
|
|
|
|
newFront = SharedImage();
|
2011-01-11 21:34:31 +00:00
|
|
|
}
|
2010-07-21 21:17:33 +00:00
|
|
|
|
2011-04-21 04:38:39 +00:00
|
|
|
replyv.push_back(OpImageSwap(shadow, NULL,
|
|
|
|
newBack));
|
2010-07-21 21:17:33 +00:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
NS_RUNTIMEABORT("not reached");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
layer_manager()->EndTransaction(NULL, NULL);
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
Frame()->ShadowLayersUpdated();
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-12-31 07:40:19 +00:00
|
|
|
bool
|
|
|
|
ShadowLayersParent::RecvGetParentType(LayersBackend* aBackend)
|
|
|
|
{
|
|
|
|
*aBackend = layer_manager()->GetBackendType();
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
PLayerParent*
|
|
|
|
ShadowLayersParent::AllocPLayer()
|
|
|
|
{
|
|
|
|
return new ShadowLayerParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ShadowLayersParent::DeallocPLayer(PLayerParent* actor)
|
|
|
|
{
|
|
|
|
delete actor;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-08-20 23:24:41 +00:00
|
|
|
RenderFrameParent*
|
|
|
|
ShadowLayersParent::Frame()
|
|
|
|
{
|
|
|
|
return static_cast<RenderFrameParent*>(Manager());
|
|
|
|
}
|
|
|
|
|
2010-07-21 21:17:33 +00:00
|
|
|
} // namespace layers
|
|
|
|
} // namespace mozilla
|