Bumping manifests a=b2g-bump
[gecko.git] / gfx / layers / CopyableCanvasLayer.h
blob4f61d43dbf111177915971638a78ca0c52d64491
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/. */
6 #ifndef GFX_COPYABLECANVASLAYER_H
7 #define GFX_COPYABLECANVASLAYER_H
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
23 namespace mozilla {
24 namespace gl{
25 class SurfaceStream;
28 namespace layers {
30 class CanvasClientWebGL;
32 /**
33 * A shared CanvasLayer implementation that supports copying
34 * its contents into a gfxASurface using UpdateSurface.
36 class CopyableCanvasLayer : public CanvasLayer
38 public:
39 CopyableCanvasLayer(LayerManager* aLayerManager, void *aImplData);
41 protected:
42 virtual ~CopyableCanvasLayer();
44 public:
45 virtual void Initialize(const Data& aData);
47 virtual bool IsDataValid(const Data& aData);
49 bool IsGLLayer() { return !!mGLContext; }
51 protected:
52 void UpdateTarget(gfx::DrawTarget* aDestTarget = nullptr);
54 RefPtr<gfx::SourceSurface> mSurface;
55 nsRefPtr<gl::GLContext> mGLContext;
56 mozilla::RefPtr<mozilla::gfx::DrawTarget> mDrawTarget;
58 RefPtr<gl::SurfaceStream> mStream;
60 uint32_t mCanvasFramebuffer;
62 bool mIsAlphaPremultiplied;
63 bool mNeedsYFlip;
65 RefPtr<gfx::DataSourceSurface> mCachedTempSurface;
67 gfx::DataSourceSurface* GetTempSurface(const gfx::IntSize& aSize,
68 const gfx::SurfaceFormat aFormat);
70 void DiscardTempSurface();
76 #endif