|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
|
2 * This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 #include "BasicCanvasLayer.h" |
|
7 #include "basic/BasicLayers.h" // for BasicLayerManager |
|
8 #include "basic/BasicLayersImpl.h" // for GetEffectiveOperator |
|
9 #include "mozilla/mozalloc.h" // for operator new |
|
10 #include "nsAutoPtr.h" // for nsRefPtr |
|
11 #include "nsCOMPtr.h" // for already_AddRefed |
|
12 #include "nsISupportsImpl.h" // for Layer::AddRef, etc |
|
13 #include "gfx2DGlue.h" |
|
14 |
|
15 class gfxContext; |
|
16 |
|
17 using namespace mozilla::gfx; |
|
18 using namespace mozilla::gl; |
|
19 |
|
20 namespace mozilla { |
|
21 namespace layers { |
|
22 |
|
23 void |
|
24 BasicCanvasLayer::Paint(DrawTarget* aDT, |
|
25 const Point& aDeviceOffset, |
|
26 Layer* aMaskLayer) |
|
27 { |
|
28 if (IsHidden()) |
|
29 return; |
|
30 |
|
31 FirePreTransactionCallback(); |
|
32 UpdateTarget(); |
|
33 FireDidTransactionCallback(); |
|
34 |
|
35 if (!mSurface) { |
|
36 return; |
|
37 } |
|
38 |
|
39 Matrix m; |
|
40 if (mNeedsYFlip) { |
|
41 m = aDT->GetTransform(); |
|
42 Matrix newTransform = m; |
|
43 newTransform.Translate(0.0f, mBounds.height); |
|
44 newTransform.Scale(1.0f, -1.0f); |
|
45 aDT->SetTransform(newTransform); |
|
46 } |
|
47 |
|
48 FillRectWithMask(aDT, aDeviceOffset, |
|
49 Rect(0, 0, mBounds.width, mBounds.height), |
|
50 mSurface, ToFilter(mFilter), |
|
51 DrawOptions(GetEffectiveOpacity(), GetEffectiveOperator(this)), |
|
52 aMaskLayer); |
|
53 |
|
54 if (mNeedsYFlip) { |
|
55 aDT->SetTransform(m); |
|
56 } |
|
57 } |
|
58 |
|
59 already_AddRefed<CanvasLayer> |
|
60 BasicLayerManager::CreateCanvasLayer() |
|
61 { |
|
62 NS_ASSERTION(InConstruction(), "Only allowed in construction phase"); |
|
63 nsRefPtr<CanvasLayer> layer = new BasicCanvasLayer(this); |
|
64 return layer.forget(); |
|
65 } |
|
66 |
|
67 } |
|
68 } |