Coverage Report

Created: 2018-09-25 14:53

/src/mozilla-central/gfx/2d/SourceSurfaceCapture.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 mozilla_gfx_2d_SourceSurfaceCapture_h
8
#define mozilla_gfx_2d_SourceSurfaceCapture_h
9
10
#include "2D.h"
11
#include "CaptureCommandList.h"
12
#include "mozilla/Mutex.h"
13
14
namespace mozilla {
15
namespace gfx {
16
17
class DrawTargetCaptureImpl;
18
19
class SourceSurfaceCapture : public SourceSurface
20
{
21
  friend class DrawTargetCaptureImpl;
22
public:
23
  MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceCapture, override)
24
25
  explicit SourceSurfaceCapture(DrawTargetCaptureImpl* aOwner);
26
  explicit SourceSurfaceCapture(DrawTargetCaptureImpl* aOwner,
27
                                LuminanceType aLuminanceType,
28
                                float aOpacity);
29
  ~SourceSurfaceCapture();
30
31
0
  SurfaceType GetType() const override { return SurfaceType::CAPTURE; }
32
0
  IntSize GetSize() const override { return mSize; }
33
0
  SurfaceFormat GetFormat() const override { return mFormat; }
34
35
  bool IsValid() const override;
36
  already_AddRefed<DataSourceSurface> GetDataSurface() override;
37
38
  // The backend hint is not guaranteed to be honored, so callers must check
39
  // the resulting type if needed.
40
  RefPtr<SourceSurface> Resolve(BackendType aBackendType = BackendType::NONE);
41
42
protected:
43
  RefPtr<SourceSurface> ResolveImpl(BackendType aBackendType);
44
  void DrawTargetWillDestroy();
45
  void DrawTargetWillChange();
46
47
private:
48
  IntSize mSize;
49
  SurfaceFormat mFormat;
50
  int32_t mStride;
51
  int32_t mSurfaceAllocationSize;
52
  RefPtr<DrawTarget> mRefDT;
53
  DrawTargetCaptureImpl* mOwner;
54
  CaptureCommandList mCommands;
55
  bool mHasCommandList;
56
57
  bool mShouldResolveToLuminance;
58
  LuminanceType mLuminanceType;
59
  float mOpacity;
60
61
  // Note that we have to keep a reference around. Internal methods like
62
  // GetSkImageForSurface expect their callers to hold a reference, which
63
  // isn't easily possible for nested surfaces.
64
  mutable Mutex mLock;
65
  RefPtr<SourceSurface> mResolved;
66
};
67
68
} // namespace gfx
69
} // namespace mozilla
70
71
#endif // mozilla_gfx_2d_SourceSurfaceCapture_h