gfx/layers/d3d9/CanvasLayerD3D9.h

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:761e2efb6e13
1 /* -*- Mode: C++; tab-width: 20; 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_CANVASLAYERD3D9_H
7 #define GFX_CANVASLAYERD3D9_H
8
9 #include "LayerManagerD3D9.h"
10 #include "GLContextTypes.h"
11
12 namespace mozilla {
13 namespace layers {
14
15
16 class CanvasLayerD3D9 :
17 public CanvasLayer,
18 public LayerD3D9
19 {
20 public:
21 CanvasLayerD3D9(LayerManagerD3D9 *aManager);
22 ~CanvasLayerD3D9();
23
24 // CanvasLayer implementation
25 virtual void Initialize(const Data& aData);
26
27 // LayerD3D9 implementation
28 virtual Layer* GetLayer();
29 virtual void RenderLayer();
30 virtual void CleanResources();
31 virtual void LayerManagerDestroyed();
32
33 void CreateTexture();
34
35 protected:
36 typedef mozilla::gl::GLContext GLContext;
37
38 void UpdateSurface();
39
40 nsRefPtr<GLContext> mGLContext;
41 nsRefPtr<IDirect3DTexture9> mTexture;
42 RefPtr<gfx::DrawTarget> mDrawTarget;
43
44 bool mDataIsPremultiplied;
45 bool mNeedsYFlip;
46 bool mHasAlpha;
47
48 nsAutoArrayPtr<uint8_t> mCachedTempBlob;
49 uint32_t mCachedTempBlob_Size;
50
51 uint8_t* GetTempBlob(const uint32_t aSize)
52 {
53 if (!mCachedTempBlob || aSize != mCachedTempBlob_Size) {
54 mCachedTempBlob = new uint8_t[aSize];
55 mCachedTempBlob_Size = aSize;
56 }
57
58 return mCachedTempBlob;
59 }
60
61 void DiscardTempBlob()
62 {
63 mCachedTempBlob = nullptr;
64 }
65 };
66
67 } /* layers */
68 } /* mozilla */
69 #endif /* GFX_CANVASLAYERD3D9_H */

mercurial