/src/mozilla-central/gfx/layers/ImageLayers.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* vim: set ts=8 sts=2 et sw=2 tw=80: */ |
3 | | /* This Source Code Form is subject to the terms of the Mozilla Public |
4 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
5 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
6 | | |
7 | | #include "ImageLayers.h" |
8 | | #include "ImageContainer.h" // for ImageContainer |
9 | | #include "gfxRect.h" // for gfxRect |
10 | | #include "nsDebug.h" // for NS_ASSERTION |
11 | | #include "nsISupportsImpl.h" // for ImageContainer::Release, etc |
12 | | #include "gfx2DGlue.h" |
13 | | |
14 | | namespace mozilla { |
15 | | namespace layers { |
16 | | |
17 | | ImageLayer::ImageLayer(LayerManager* aManager, void* aImplData) |
18 | | : Layer(aManager, aImplData), mSamplingFilter(gfx::SamplingFilter::GOOD) |
19 | | , mScaleMode(ScaleMode::SCALE_NONE) |
20 | 0 | {} |
21 | | |
22 | | ImageLayer::~ImageLayer() |
23 | 0 | {} |
24 | | |
25 | | void ImageLayer::SetContainer(ImageContainer* aContainer) |
26 | 0 | { |
27 | 0 | mContainer = aContainer; |
28 | 0 | } |
29 | | |
30 | | void ImageLayer::ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) |
31 | 0 | { |
32 | 0 | gfx::Matrix4x4 local = GetLocalTransform(); |
33 | 0 |
|
34 | 0 | // Snap image edges to pixel boundaries |
35 | 0 | gfxRect sourceRect(0, 0, 0, 0); |
36 | 0 | if (mContainer) { |
37 | 0 | sourceRect.SizeTo(gfx::SizeDouble(mContainer->GetCurrentSize())); |
38 | 0 | } |
39 | 0 | // Snap our local transform first, and snap the inherited transform as well. |
40 | 0 | // This makes our snapping equivalent to what would happen if our content |
41 | 0 | // was drawn into a PaintedLayer (gfxContext would snap using the local |
42 | 0 | // transform, then we'd snap again when compositing the PaintedLayer). |
43 | 0 | mEffectiveTransform = |
44 | 0 | SnapTransform(local, sourceRect, nullptr) * |
45 | 0 | SnapTransformTranslation(aTransformToSurface, nullptr); |
46 | 0 |
|
47 | 0 | if (mScaleMode != ScaleMode::SCALE_NONE && !sourceRect.IsZeroArea()) { |
48 | 0 | NS_ASSERTION(mScaleMode == ScaleMode::STRETCH, |
49 | 0 | "No other scalemodes than stretch and none supported yet."); |
50 | 0 | local.PreScale(mScaleToSize.width / sourceRect.Width(), |
51 | 0 | mScaleToSize.height / sourceRect.Height(), 1.0); |
52 | 0 |
|
53 | 0 | mEffectiveTransformForBuffer = |
54 | 0 | SnapTransform(local, sourceRect, nullptr) * |
55 | 0 | SnapTransformTranslation(aTransformToSurface, nullptr); |
56 | 0 | } else { |
57 | 0 | mEffectiveTransformForBuffer = mEffectiveTransform; |
58 | 0 | } |
59 | 0 |
|
60 | 0 | ComputeEffectiveTransformForMaskLayers(aTransformToSurface); |
61 | 0 | } |
62 | | |
63 | | } // namespace layers |
64 | | } // namespace mozilla |