michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "BasicCanvasLayer.h" michael@0: #include "basic/BasicLayers.h" // for BasicLayerManager michael@0: #include "basic/BasicLayersImpl.h" // for GetEffectiveOperator michael@0: #include "mozilla/mozalloc.h" // for operator new michael@0: #include "nsAutoPtr.h" // for nsRefPtr michael@0: #include "nsCOMPtr.h" // for already_AddRefed michael@0: #include "nsISupportsImpl.h" // for Layer::AddRef, etc michael@0: #include "gfx2DGlue.h" michael@0: michael@0: class gfxContext; michael@0: michael@0: using namespace mozilla::gfx; michael@0: using namespace mozilla::gl; michael@0: michael@0: namespace mozilla { michael@0: namespace layers { michael@0: michael@0: void michael@0: BasicCanvasLayer::Paint(DrawTarget* aDT, michael@0: const Point& aDeviceOffset, michael@0: Layer* aMaskLayer) michael@0: { michael@0: if (IsHidden()) michael@0: return; michael@0: michael@0: FirePreTransactionCallback(); michael@0: UpdateTarget(); michael@0: FireDidTransactionCallback(); michael@0: michael@0: if (!mSurface) { michael@0: return; michael@0: } michael@0: michael@0: Matrix m; michael@0: if (mNeedsYFlip) { michael@0: m = aDT->GetTransform(); michael@0: Matrix newTransform = m; michael@0: newTransform.Translate(0.0f, mBounds.height); michael@0: newTransform.Scale(1.0f, -1.0f); michael@0: aDT->SetTransform(newTransform); michael@0: } michael@0: michael@0: FillRectWithMask(aDT, aDeviceOffset, michael@0: Rect(0, 0, mBounds.width, mBounds.height), michael@0: mSurface, ToFilter(mFilter), michael@0: DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)), michael@0: aMaskLayer); michael@0: michael@0: if (mNeedsYFlip) { michael@0: aDT->SetTransform(m); michael@0: } michael@0: } michael@0: michael@0: already_AddRefed michael@0: BasicLayerManager::CreateCanvasLayer() michael@0: { michael@0: NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); michael@0: nsRefPtr layer = new BasicCanvasLayer(this); michael@0: return layer.forget(); michael@0: } michael@0: michael@0: } michael@0: }