|
1 // |
|
2 // Copyright (c) 2002-2012 The ANGLE Project Authors. All rights reserved. |
|
3 // Use of this source code is governed by a BSD-style license that can be |
|
4 // found in the LICENSE file. |
|
5 // |
|
6 |
|
7 // TextureStorage.h: Defines the abstract rx::TextureStorageInterface class and its concrete derived |
|
8 // classes TextureStorageInterface2D and TextureStorageInterfaceCube, which act as the interface to the |
|
9 // GPU-side texture. |
|
10 |
|
11 #ifndef LIBGLESV2_RENDERER_TEXTURESTORAGE_H_ |
|
12 #define LIBGLESV2_RENDERER_TEXTURESTORAGE_H_ |
|
13 |
|
14 #include "common/debug.h" |
|
15 |
|
16 namespace rx |
|
17 { |
|
18 class Renderer; |
|
19 class SwapChain; |
|
20 class RenderTarget; |
|
21 class Blit; |
|
22 |
|
23 class TextureStorage |
|
24 { |
|
25 public: |
|
26 TextureStorage() {}; |
|
27 virtual ~TextureStorage() {}; |
|
28 |
|
29 virtual int getLodOffset() const = 0; |
|
30 virtual bool isRenderTarget() const = 0; |
|
31 virtual bool isManaged() const = 0; |
|
32 virtual int levelCount() = 0; |
|
33 |
|
34 virtual RenderTarget *getRenderTarget() = 0; |
|
35 virtual RenderTarget *getRenderTarget(GLenum faceTarget) = 0; |
|
36 virtual void generateMipmap(int level) = 0; |
|
37 virtual void generateMipmap(int face, int level) = 0; |
|
38 |
|
39 private: |
|
40 DISALLOW_COPY_AND_ASSIGN(TextureStorage); |
|
41 |
|
42 }; |
|
43 |
|
44 class TextureStorageInterface |
|
45 { |
|
46 public: |
|
47 TextureStorageInterface(); |
|
48 virtual ~TextureStorageInterface(); |
|
49 |
|
50 TextureStorage *getStorageInstance() { return mInstance; } |
|
51 |
|
52 unsigned int getTextureSerial() const; |
|
53 virtual unsigned int getRenderTargetSerial(GLenum target) const = 0; |
|
54 |
|
55 virtual int getLodOffset() const; |
|
56 virtual bool isRenderTarget() const; |
|
57 virtual bool isManaged() const; |
|
58 virtual int levelCount(); |
|
59 |
|
60 protected: |
|
61 TextureStorage *mInstance; |
|
62 |
|
63 private: |
|
64 DISALLOW_COPY_AND_ASSIGN(TextureStorageInterface); |
|
65 |
|
66 const unsigned int mTextureSerial; |
|
67 static unsigned int issueTextureSerial(); |
|
68 |
|
69 static unsigned int mCurrentTextureSerial; |
|
70 }; |
|
71 |
|
72 class TextureStorageInterface2D : public TextureStorageInterface |
|
73 { |
|
74 public: |
|
75 TextureStorageInterface2D(Renderer *renderer, SwapChain *swapchain); |
|
76 TextureStorageInterface2D(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height); |
|
77 virtual ~TextureStorageInterface2D(); |
|
78 |
|
79 void generateMipmap(int level); |
|
80 RenderTarget *getRenderTarget() const; |
|
81 |
|
82 virtual unsigned int getRenderTargetSerial(GLenum target) const; |
|
83 |
|
84 private: |
|
85 DISALLOW_COPY_AND_ASSIGN(TextureStorageInterface2D); |
|
86 |
|
87 const unsigned int mRenderTargetSerial; |
|
88 }; |
|
89 |
|
90 class TextureStorageInterfaceCube : public TextureStorageInterface |
|
91 { |
|
92 public: |
|
93 TextureStorageInterfaceCube(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size); |
|
94 virtual ~TextureStorageInterfaceCube(); |
|
95 |
|
96 void generateMipmap(int face, int level); |
|
97 RenderTarget *getRenderTarget(GLenum faceTarget) const; |
|
98 |
|
99 virtual unsigned int getRenderTargetSerial(GLenum target) const; |
|
100 |
|
101 private: |
|
102 DISALLOW_COPY_AND_ASSIGN(TextureStorageInterfaceCube); |
|
103 |
|
104 const unsigned int mFirstRenderTargetSerial; |
|
105 }; |
|
106 |
|
107 } |
|
108 |
|
109 #endif // LIBGLESV2_RENDERER_TEXTURESTORAGE_H_ |
|
110 |