/src/mozilla-central/gfx/layers/CopyableCanvasRenderer.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_COPYABLECANVASRENDERER_H |
8 | | #define GFX_COPYABLECANVASRENDERER_H |
9 | | |
10 | | #include <stdint.h> // for uint32_t |
11 | | #include "CanvasRenderer.h" |
12 | | #include "GLContextTypes.h" // for GLContext |
13 | | #include "gfxContext.h" // for gfxContext, etc |
14 | | #include "gfxTypes.h" |
15 | | #include "gfxPlatform.h" // for gfxImageFormat |
16 | | #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc |
17 | | #include "mozilla/Preferences.h" // for Preferences |
18 | | #include "mozilla/RefPtr.h" // for RefPtr |
19 | | #include "mozilla/gfx/2D.h" // for DrawTarget |
20 | | #include "mozilla/mozalloc.h" // for operator delete, etc |
21 | | #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc |
22 | | |
23 | | namespace mozilla { |
24 | | |
25 | | namespace gl { |
26 | | class SharedSurface; |
27 | | } // namespace gl |
28 | | |
29 | | namespace layers { |
30 | | |
31 | | /** |
32 | | * A shared CanvasRenderer implementation that supports copying |
33 | | * its contents into a gfxASurface using RebackSurface. |
34 | | */ |
35 | | class CopyableCanvasRenderer : public CanvasRenderer |
36 | | { |
37 | | public: |
38 | | CopyableCanvasRenderer(); |
39 | | virtual ~CopyableCanvasRenderer(); |
40 | | |
41 | | public: |
42 | | void Initialize(const CanvasInitializeData& aData) override; |
43 | | bool IsDataValid(const CanvasInitializeData& aData) override; |
44 | | |
45 | | void ClearCachedResources() override; |
46 | | void Destroy() override; |
47 | | |
48 | 0 | CopyableCanvasRenderer* AsCopyableCanvasRenderer() override { return this; } |
49 | | |
50 | 0 | bool NeedsYFlip() const { return mOriginPos == gl::OriginPos::BottomLeft; } |
51 | 0 | bool HasGLContext() const { return !!mGLContext; } |
52 | 0 | bool IsOpaque() const { return mOpaque; } |
53 | | |
54 | 0 | PersistentBufferProvider* GetBufferProvider() { return mBufferProvider; } |
55 | | |
56 | | already_AddRefed<gfx::SourceSurface> ReadbackSurface(); |
57 | | |
58 | | protected: |
59 | | RefPtr<gl::GLContext> mGLContext; |
60 | | RefPtr<PersistentBufferProvider> mBufferProvider; |
61 | | UniquePtr<gl::SharedSurface> mGLFrontbuffer; |
62 | | RefPtr<AsyncCanvasRenderer> mAsyncRenderer; |
63 | | |
64 | | bool mIsAlphaPremultiplied; |
65 | | gl::OriginPos mOriginPos; |
66 | | |
67 | | bool mOpaque; |
68 | | |
69 | | RefPtr<gfx::DataSourceSurface> mCachedTempSurface; |
70 | | |
71 | | gfx::DataSourceSurface* GetTempSurface(const gfx::IntSize& aSize, |
72 | | const gfx::SurfaceFormat aFormat); |
73 | | }; |
74 | | |
75 | | } // namespace layers |
76 | | } // namespace mozilla |
77 | | |
78 | | #endif |