gfx/layers/CopyableCanvasLayer.h

branch
TOR_BUG_9701
changeset 8
97036ab72558
equal deleted inserted replaced
-1:000000000000 0:36e0cb67d36b
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 "nsAutoPtr.h" // for nsRefPtr
21 #include "nsISupportsImpl.h" // for MOZ_COUNT_CTOR, etc
22
23 namespace mozilla {
24
25 namespace gfx {
26 class SurfaceStream;
27 class SharedSurface;
28 class SurfaceFactory;
29 }
30
31 namespace layers {
32
33 class CanvasClientWebGL;
34
35 /**
36 * A shared CanvasLayer implementation that supports copying
37 * its contents into a gfxASurface using UpdateSurface.
38 */
39 class CopyableCanvasLayer : public CanvasLayer
40 {
41 public:
42 CopyableCanvasLayer(LayerManager* aLayerManager, void *aImplData);
43 virtual ~CopyableCanvasLayer();
44
45 virtual void Initialize(const Data& aData);
46
47 virtual bool IsDataValid(const Data& aData);
48
49 protected:
50 void UpdateTarget(gfx::DrawTarget* aDestTarget = nullptr);
51
52 RefPtr<gfx::SourceSurface> mSurface;
53 nsRefPtr<mozilla::gl::GLContext> mGLContext;
54 mozilla::RefPtr<mozilla::gfx::DrawTarget> mDrawTarget;
55
56 RefPtr<gfx::SurfaceStream> mStream;
57
58 uint32_t mCanvasFramebuffer;
59
60 bool mIsGLAlphaPremult;
61 bool mNeedsYFlip;
62
63 RefPtr<gfx::DataSourceSurface> mCachedTempSurface;
64 gfx::IntSize mCachedSize;
65 gfx::SurfaceFormat mCachedFormat;
66
67 gfx::DataSourceSurface* GetTempSurface(const gfx::IntSize& aSize,
68 const gfx::SurfaceFormat aFormat);
69
70 void DiscardTempSurface();
71 };
72
73 }
74 }
75
76 #endif

mercurial