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/. */
7 #ifndef mozilla_gfx_2d_SourceSurfaceCapture_h
8 #define mozilla_gfx_2d_SourceSurfaceCapture_h
11 #include "CaptureCommandList.h"
12 #include "mozilla/Mutex.h"
17 class DrawTargetCaptureImpl
;
19 class SourceSurfaceCapture
: public SourceSurface
21 friend class DrawTargetCaptureImpl
;
23 MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(SourceSurfaceCapture
, override
)
25 explicit SourceSurfaceCapture(DrawTargetCaptureImpl
* aOwner
);
26 explicit SourceSurfaceCapture(DrawTargetCaptureImpl
* aOwner
,
27 LuminanceType aLuminanceType
,
29 ~SourceSurfaceCapture();
31 SurfaceType
GetType() const override
{ return SurfaceType::CAPTURE
; }
32 IntSize
GetSize() const override
{ return mSize
; }
33 SurfaceFormat
GetFormat() const override
{ return mFormat
; }
35 bool IsValid() const override
;
36 already_AddRefed
<DataSourceSurface
> GetDataSurface() override
;
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
);
43 RefPtr
<SourceSurface
> ResolveImpl(BackendType aBackendType
);
44 void DrawTargetWillDestroy();
45 void DrawTargetWillChange();
49 SurfaceFormat mFormat
;
51 int32_t mSurfaceAllocationSize
;
52 RefPtr
<DrawTarget
> mRefDT
;
53 DrawTargetCaptureImpl
* mOwner
;
54 CaptureCommandList mCommands
;
57 bool mShouldResolveToLuminance
;
58 LuminanceType mLuminanceType
;
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.
65 RefPtr
<SourceSurface
> mResolved
;
69 } // namespace mozilla
71 #endif // mozilla_gfx_2d_SourceSurfaceCapture_h