Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/layers/ImageLayers.h
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
#ifndef GFX_IMAGELAYER_H
8
#define GFX_IMAGELAYER_H
9
10
#include "Layers.h"                     // for Layer, etc
11
#include "mozilla/gfx/BaseSize.h"       // for BaseSize
12
#include "mozilla/gfx/Point.h"          // for IntSize
13
#include "mozilla/layers/LayersTypes.h"
14
#include "nsAutoPtr.h"                  // for nsRefPtr
15
#include "nscore.h"                     // for nsACString
16
17
namespace mozilla {
18
namespace layers {
19
20
class ImageContainer;
21
22
namespace layerscope {
23
class LayersPacket;
24
} // namespace layerscope
25
26
/**
27
 * A Layer which renders an Image.
28
 */
29
class ImageLayer : public Layer {
30
public:
31
  /**
32
   * CONSTRUCTION PHASE ONLY
33
   * Set the ImageContainer. aContainer must have the same layer manager
34
   * as this layer.
35
   */
36
  virtual void SetContainer(ImageContainer* aContainer);
37
38
  /**
39
   * CONSTRUCTION PHASE ONLY
40
   * Set the filter used to resample this image if necessary.
41
   */
42
  void SetSamplingFilter(gfx::SamplingFilter aSamplingFilter)
43
0
  {
44
0
    if (mSamplingFilter != aSamplingFilter) {
45
0
      MOZ_LAYERS_LOG_IF_SHADOWABLE(this, ("Layer::Mutated(%p) Filter", this));
46
0
      mSamplingFilter = aSamplingFilter;
47
0
      Mutated();
48
0
    }
49
0
  }
50
51
  /**
52
   * CONSTRUCTION PHASE ONLY
53
   * Set the size to scale the image to and the mode at which to scale.
54
   */
55
  void SetScaleToSize(const gfx::IntSize &aSize, ScaleMode aMode)
56
0
  {
57
0
    if (mScaleToSize != aSize || mScaleMode != aMode) {
58
0
      mScaleToSize = aSize;
59
0
      mScaleMode = aMode;
60
0
      Mutated();
61
0
    }
62
0
  }
63
64
65
0
  ImageContainer* GetContainer() { return mContainer; }
66
0
  gfx::SamplingFilter GetSamplingFilter() { return mSamplingFilter; }
67
0
  const gfx::IntSize& GetScaleToSize() { return mScaleToSize; }
68
0
  ScaleMode GetScaleMode() { return mScaleMode; }
69
70
  MOZ_LAYER_DECL_NAME("ImageLayer", TYPE_IMAGE)
71
72
  virtual void ComputeEffectiveTransforms(const gfx::Matrix4x4& aTransformToSurface) override;
73
74
  virtual const gfx::Matrix4x4& GetEffectiveTransformForBuffer() const override
75
0
  {
76
0
    return mEffectiveTransformForBuffer;
77
0
  }
78
79
0
  virtual ImageLayer* AsImageLayer() override { return this; }
80
81
protected:
82
  ImageLayer(LayerManager* aManager, void* aImplData);
83
  ~ImageLayer();
84
  virtual void PrintInfo(std::stringstream& aStream, const char* aPrefix) override;
85
  virtual void DumpPacket(layerscope::LayersPacket* aPacket, const void* aParent) override;
86
87
  RefPtr<ImageContainer> mContainer;
88
  gfx::SamplingFilter mSamplingFilter;
89
  gfx::IntSize mScaleToSize;
90
  ScaleMode mScaleMode;
91
  gfx::Matrix4x4 mEffectiveTransformForBuffer;
92
};
93
94
} // namespace layers
95
} // namespace mozilla
96
97
#endif /* GFX_IMAGELAYER_H */