OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_DEFINITION_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_DEFINITION_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "gpu/command_buffer/service/gl_utils.h" |
| 14 |
| 15 namespace gfx { |
| 16 class GLFence; |
| 17 } |
| 18 |
| 19 namespace gpu { |
| 20 namespace gles2 { |
| 21 |
| 22 class Texture; |
| 23 |
| 24 class SharedGLFence : public base::RefCountedThreadSafe<SharedGLFence> { |
| 25 public: |
| 26 SharedGLFence(); |
| 27 void GpuWaitSync() const; |
| 28 |
| 29 private: |
| 30 friend class base::RefCountedThreadSafe<SharedGLFence>; |
| 31 virtual ~SharedGLFence(); |
| 32 |
| 33 scoped_ptr<gfx::GLFence> fence_; |
| 34 |
| 35 DISALLOW_COPY_AND_ASSIGN(SharedGLFence); |
| 36 }; |
| 37 |
| 38 class NativeImageBuffer : public base::RefCountedThreadSafe<NativeImageBuffer> { |
| 39 public: |
| 40 static NativeImageBuffer* Create(GLuint texture_id); |
| 41 virtual void BindToTexture(GLenum target) = 0; |
| 42 |
| 43 protected: |
| 44 friend class base::RefCountedThreadSafe<NativeImageBuffer>; |
| 45 NativeImageBuffer() {} |
| 46 virtual ~NativeImageBuffer() {} |
| 47 |
| 48 DISALLOW_COPY_AND_ASSIGN(NativeImageBuffer); |
| 49 }; |
| 50 |
| 51 // An immutable description that can be used to create a texture that shares |
| 52 // the underlying image buffer(s). |
| 53 class TextureDefinition { |
| 54 public: |
| 55 TextureDefinition(GLenum target, |
| 56 Texture* texture, |
| 57 NativeImageBuffer* image, |
| 58 const scoped_refptr<SharedGLFence>& fence); |
| 59 virtual ~TextureDefinition(); |
| 60 |
| 61 Texture* CreateTexture() const; |
| 62 void UpdateTexture(Texture* texture) const; |
| 63 |
| 64 scoped_refptr<NativeImageBuffer> image() { return image_; } |
| 65 |
| 66 private: |
| 67 struct LevelInfo { |
| 68 LevelInfo(GLenum target, |
| 69 GLenum internal_format, |
| 70 GLsizei width, |
| 71 GLsizei height, |
| 72 GLsizei depth, |
| 73 GLint border, |
| 74 GLenum format, |
| 75 GLenum type, |
| 76 bool cleared); |
| 77 ~LevelInfo(); |
| 78 |
| 79 GLenum target; |
| 80 GLenum internal_format; |
| 81 GLsizei width; |
| 82 GLsizei height; |
| 83 GLsizei depth; |
| 84 GLint border; |
| 85 GLenum format; |
| 86 GLenum type; |
| 87 bool cleared; |
| 88 }; |
| 89 |
| 90 typedef std::vector<std::vector<LevelInfo> > LevelInfos; |
| 91 |
| 92 GLenum target_; |
| 93 scoped_refptr<NativeImageBuffer> image_; |
| 94 scoped_refptr<SharedGLFence> fence_; |
| 95 GLenum min_filter_; |
| 96 GLenum mag_filter_; |
| 97 GLenum wrap_s_; |
| 98 GLenum wrap_t_; |
| 99 GLenum usage_; |
| 100 bool immutable_; |
| 101 LevelInfos level_infos_; |
| 102 }; |
| 103 |
| 104 } // namespage gles2 |
| 105 } // namespace gpu |
| 106 |
| 107 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_DEFINITION_H_ |
OLD | NEW |