2012-06-29 10:01:34 +04: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 13:20:52 +04:00
|
|
|
#include "BasicCanvasLayer.h"
|
2013-08-12 03:17:23 +04:00
|
|
|
#include "basic/BasicLayers.h" // for BasicLayerManager
|
2014-02-27 20:56:48 +04:00
|
|
|
#include "basic/BasicLayersImpl.h" // for GetEffectiveOperator
|
2013-08-12 03:17:23 +04: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 19:07:46 +04:00
|
|
|
#include "gfx2DGlue.h"
|
|
|
|
|
2013-08-12 03:17:23 +04:00
|
|
|
class gfxContext;
|
2012-06-29 10:01:34 +04:00
|
|
|
|
|
|
|
using namespace mozilla::gfx;
|
2012-10-26 00:12:59 +04:00
|
|
|
using namespace mozilla::gl;
|
2012-06-29 10:01:34 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
2012-07-10 19:06:42 +04:00
|
|
|
namespace layers {
|
|
|
|
|
2014-02-12 19:07:46 +04:00
|
|
|
void
|
2014-05-12 04:31:27 +04:00
|
|
|
BasicCanvasLayer::Paint(DrawTarget* aDT,
|
|
|
|
const Point& aDeviceOffset,
|
|
|
|
Layer* aMaskLayer)
|
2012-06-29 10:01:34 +04:00
|
|
|
{
|
|
|
|
if (IsHidden())
|
|
|
|
return;
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2014-10-09 02:18:28 +04:00
|
|
|
if (IsDirty()) {
|
|
|
|
Painted();
|
|
|
|
|
|
|
|
FirePreTransactionCallback();
|
|
|
|
UpdateTarget();
|
|
|
|
FireDidTransactionCallback();
|
|
|
|
}
|
2013-02-14 03:26:24 +04:00
|
|
|
|
2014-04-07 12:57:27 +04:00
|
|
|
if (!mSurface) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-11-18 04:02:19 +03:00
|
|
|
const bool needsYFlip = (mOriginPos == gl::OriginPos::BottomLeft);
|
|
|
|
|
2014-09-10 21:29:35 +04:00
|
|
|
Matrix oldTM;
|
2014-11-18 04:02:19 +03:00
|
|
|
if (needsYFlip) {
|
2014-09-10 21:29:35 +04:00
|
|
|
oldTM = aDT->GetTransform();
|
|
|
|
aDT->SetTransform(Matrix(oldTM).
|
|
|
|
PreTranslate(0.0f, mBounds.height).
|
|
|
|
PreScale(1.0f, -1.0f));
|
2014-04-01 08:02:09 +04:00
|
|
|
}
|
|
|
|
|
2014-05-12 04:31:27 +04:00
|
|
|
FillRectWithMask(aDT, aDeviceOffset,
|
2014-04-01 08:02:09 +04:00
|
|
|
Rect(0, 0, mBounds.width, mBounds.height),
|
|
|
|
mSurface, ToFilter(mFilter),
|
|
|
|
DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)),
|
|
|
|
aMaskLayer);
|
|
|
|
|
2014-11-18 04:02:19 +03:00
|
|
|
if (needsYFlip) {
|
2014-09-10 21:29:35 +04:00
|
|
|
aDT->SetTransform(oldTM);
|
2014-04-01 08:02:09 +04:00
|
|
|
}
|
2012-06-29 10:01:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<CanvasLayer>
|
|
|
|
BasicLayerManager::CreateCanvasLayer()
|
|
|
|
{
|
|
|
|
NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
|
|
|
|
nsRefPtr<CanvasLayer> layer = new BasicCanvasLayer(this);
|
|
|
|
return layer.forget();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|