Line data Source code
1 : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * This Source Code Form is subject to the terms of the Mozilla Public
3 : * License, v. 2.0. If a copy of the MPL was not distributed with this
4 : * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
5 :
6 : #ifndef GFX_COPYABLECANVASLAYER_H
7 : #define GFX_COPYABLECANVASLAYER_H
8 :
9 : #include <stdint.h> // for uint32_t
10 : #include "GLContextTypes.h" // for GLContext
11 : #include "Layers.h" // for CanvasLayer, etc
12 : #include "gfxContext.h" // for gfxContext, etc
13 : #include "gfxTypes.h"
14 : #include "gfxPlatform.h" // for gfxImageFormat
15 : #include "mozilla/Assertions.h" // for MOZ_ASSERT, etc
16 : #include "mozilla/Preferences.h" // for Preferences
17 : #include "mozilla/RefPtr.h" // for RefPtr
18 : #include "mozilla/gfx/2D.h" // for DrawTarget
19 : #include "mozilla/mozalloc.h" // for operator delete, etc
20 : #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
21 :
22 : namespace mozilla {
23 :
24 : namespace gl {
25 : class SharedSurface;
26 : } // namespace gl
27 :
28 : namespace layers {
29 :
30 : /**
31 : * A shared CanvasLayer implementation that supports copying
32 : * its contents into a gfxASurface using UpdateSurface.
33 : */
34 : class CopyableCanvasLayer : public CanvasLayer
35 : {
36 : public:
37 : CopyableCanvasLayer(LayerManager* aLayerManager, void *aImplData);
38 :
39 : protected:
40 : virtual ~CopyableCanvasLayer();
41 :
42 : public:
43 : virtual void Initialize(const Data& aData) override;
44 :
45 : virtual bool IsDataValid(const Data& aData) override;
46 :
47 0 : bool IsGLLayer() { return !!mGLContext; }
48 :
49 : protected:
50 : RefPtr<gl::GLContext> mGLContext;
51 : RefPtr<PersistentBufferProvider> mBufferProvider;
52 : UniquePtr<gl::SharedSurface> mGLFrontbuffer;
53 :
54 : bool mIsAlphaPremultiplied;
55 : gl::OriginPos mOriginPos;
56 : bool mIsMirror;
57 :
58 : RefPtr<gfx::DataSourceSurface> mCachedTempSurface;
59 :
60 : gfx::DataSourceSurface* GetTempSurface(const gfx::IntSize& aSize,
61 : const gfx::SurfaceFormat aFormat);
62 : };
63 :
64 : } // namespace layers
65 : } // namespace mozilla
66 :
67 : #endif
|