2012-06-28 23:01:34 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
Bug 825928: Land layers refactoring. r=jrmuizel,bas,nical,mattwoodrow,roc,nrc,benwa,bjacob,jgilbert,kchen CLOSED TREE
Please contact Bas Schouten <bschouten@mozilla.com>, Nicolas Silva <nsilva@mozilla.com> or Nicholas Cameron <ncameron@mozilla.com> with general questions. Below is a rough list of authors to contact with specific questions.
Authors:
gfx/layers/Compositor.* gfx/layers/Effects.h - Compositor Interface - bas,nrc,nical
gfx/layers/d3d* - D3D9/D3D10 - bas
gfx/layers/ThebesLayer* - ThebesLayers - nrc,bas
gfx/layers/composite/* - CompositeLayers - nrc,nical
gfx/layers/client/* - Client - nrc,nical,bas
gfx/layers/*Image* - nical
gfx/layers/ipc ipc - IPC - nical
gfx/layers/opengl - CompositorOGL - nrc,nical
gfx/2d - bas,nrc
gfx/gl - GLContext - bjacob
dom/* layout/* - DOM - mattwoodrow
2013-04-10 02:20:52 -07:00
|
|
|
#include "BasicCanvasLayer.h"
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "basic/BasicLayers.h" // for BasicLayerManager
|
2014-02-27 08:56:48 -08:00
|
|
|
#include "basic/BasicLayersImpl.h" // for GetEffectiveOperator
|
2013-08-11 16:17:23 -07:00
|
|
|
#include "mozilla/mozalloc.h" // for operator new
|
|
|
|
#include "nsAutoPtr.h" // for nsRefPtr
|
|
|
|
#include "nsCOMPtr.h" // for already_AddRefed
|
|
|
|
#include "nsISupportsImpl.h" // for Layer::AddRef, etc
|
2014-02-12 07:07:46 -08:00
|
|
|
#include "gfx2DGlue.h"
|
|
|
|
|
2013-08-11 16:17:23 -07:00
|
|
|
class gfxContext;
|
2012-06-28 23:01:34 -07:00
|
|
|
|
|
|
|
using namespace mozilla::gfx;
|
2012-10-25 13:12:59 -07:00
|
|
|
using namespace mozilla::gl;
|
2012-06-28 23:01:34 -07:00
|
|
|
|
|
|
|
namespace mozilla {
|
2012-07-10 08:06:42 -07:00
|
|
|
namespace layers {
|
|
|
|
|
2014-02-12 07:07:46 -08:00
|
|
|
void
|
2014-03-31 21:02:10 -07:00
|
|
|
BasicCanvasLayer::Paint(DrawTarget* aDT, Layer* aMaskLayer)
|
2012-06-28 23:01:34 -07:00
|
|
|
{
|
|
|
|
if (IsHidden())
|
|
|
|
return;
|
2013-02-13 15:26:24 -08:00
|
|
|
|
|
|
|
FirePreTransactionCallback();
|
2014-03-31 21:02:09 -07:00
|
|
|
UpdateTarget();
|
2012-06-28 23:01:34 -07:00
|
|
|
FireDidTransactionCallback();
|
2013-02-13 15:26:24 -08:00
|
|
|
|
2014-04-07 01:57:27 -07:00
|
|
|
if (!mSurface) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-03-31 21:02:10 -07:00
|
|
|
Matrix m;
|
2014-03-31 21:02:09 -07:00
|
|
|
if (mNeedsYFlip) {
|
2014-03-31 21:02:10 -07:00
|
|
|
m = aDT->GetTransform();
|
|
|
|
Matrix newTransform = m;
|
|
|
|
newTransform.Translate(0.0f, mBounds.height);
|
|
|
|
newTransform.Scale(1.0f, -1.0f);
|
|
|
|
aDT->SetTransform(newTransform);
|
2014-03-31 21:02:09 -07:00
|
|
|
}
|
|
|
|
|
2014-03-31 21:02:10 -07:00
|
|
|
FillRectWithMask(aDT,
|
2014-03-31 21:02:09 -07:00
|
|
|
Rect(0, 0, mBounds.width, mBounds.height),
|
|
|
|
mSurface, ToFilter(mFilter),
|
|
|
|
DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)),
|
|
|
|
aMaskLayer);
|
|
|
|
|
|
|
|
if (mNeedsYFlip) {
|
2014-03-31 21:02:10 -07:00
|
|
|
aDT->SetTransform(m);
|
2014-03-31 21:02:09 -07:00
|
|
|
}
|
2012-06-28 23:01:34 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<CanvasLayer>
|
|
|
|
BasicLayerManager::CreateCanvasLayer()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
|
|
|
|
nsRefPtr<CanvasLayer> layer = new BasicCanvasLayer(this);
|
|
|
|
return layer.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|