| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_DEFINITION_H_ | 5 #ifndef GPU_COMMAND_BUFFER_SERVICE_TEXTURE_DEFINITION_H_ |
| 6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_DEFINITION_H_ | 6 #define GPU_COMMAND_BUFFER_SERVICE_TEXTURE_DEFINITION_H_ |
| 7 | 7 |
| 8 #include <set> |
| 8 #include <vector> | 9 #include <vector> |
| 9 | 10 |
| 10 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/observer_list.h" |
| 11 #include "gpu/command_buffer/service/gl_utils.h" | 14 #include "gpu/command_buffer/service/gl_utils.h" |
| 12 #include "gpu/gpu_export.h" | 15 #include "gpu/gpu_export.h" |
| 13 | 16 |
| 14 namespace gpu { | 17 namespace gpu { |
| 15 namespace gles2 { | 18 namespace gles2 { |
| 16 | 19 |
| 17 // A saved definition of a texture that still exists in the underlying | 20 // A saved definition of a texture that still exists in the underlying |
| 18 // GLShareGroup and can be used to redefine a client visible texture in any | 21 // GLShareGroup and can be used to redefine a client visible texture in any |
| 19 // context using the same GLShareGroup with the corresponding service ID. | 22 // context using the same GLShareGroup with the corresponding service ID. |
| 20 class GPU_EXPORT TextureDefinition { | 23 class GPU_EXPORT TextureDefinition { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 37 GLsizei height; | 40 GLsizei height; |
| 38 GLsizei depth; | 41 GLsizei depth; |
| 39 GLint border; | 42 GLint border; |
| 40 GLenum format; | 43 GLenum format; |
| 41 GLenum type; | 44 GLenum type; |
| 42 bool cleared; | 45 bool cleared; |
| 43 }; | 46 }; |
| 44 | 47 |
| 45 typedef std::vector<std::vector<LevelInfo> > LevelInfos; | 48 typedef std::vector<std::vector<LevelInfo> > LevelInfos; |
| 46 | 49 |
| 47 typedef base::Callback<void(TextureDefinition*)> DestroyCallback; | 50 class Client { |
| 51 protected: |
| 52 virtual void StartUsingSharedTexture(TextureDefinition* definition) const; |
| 53 virtual bool StopUsingSharedTexture(TextureDefinition* definition, |
| 54 bool delete_texture) const; |
| 55 void StartSharedTextureTransfer(TextureDefinition* definition) const; |
| 56 size_t GetSharedTextureRefCount(TextureDefinition* definition) const { |
| 57 return definition->active_clients_.size(); |
| 58 } |
| 59 }; |
| 60 |
| 61 class Observer { |
| 62 public: |
| 63 virtual void OnDestroySharedTexture(const TextureDefinition* definition) {} |
| 64 |
| 65 protected: |
| 66 ~Observer() {} |
| 67 }; |
| 48 | 68 |
| 49 TextureDefinition(GLenum target, | 69 TextureDefinition(GLenum target, |
| 50 GLuint service_id, | 70 GLuint service_id, |
| 51 GLenum min_filter, | 71 GLenum min_filter, |
| 52 GLenum mag_filter, | 72 GLenum mag_filter, |
| 53 GLenum wrap_s, | 73 GLenum wrap_s, |
| 54 GLenum wrap_t, | 74 GLenum wrap_t, |
| 55 GLenum usage, | 75 GLenum usage, |
| 56 bool immutable, | 76 bool immutable, |
| 57 const LevelInfos& level_infos); | 77 const LevelInfos& level_infos); |
| 58 ~TextureDefinition(); | 78 |
| 79 void AddObserver(Observer* observer); |
| 80 void RemoveObserver(Observer* observer); |
| 59 | 81 |
| 60 GLenum target() const { | 82 GLenum target() const { |
| 61 return target_; | 83 return target_; |
| 62 } | 84 } |
| 63 | 85 |
| 64 GLuint ReleaseServiceId(); | |
| 65 GLuint service_id() const { return service_id_; } | 86 GLuint service_id() const { return service_id_; } |
| 66 GLenum min_filter() const { return min_filter_; } | 87 GLenum min_filter() const { return min_filter_; } |
| 67 GLenum mag_filter() const { return mag_filter_; } | 88 GLenum mag_filter() const { return mag_filter_; } |
| 68 GLenum wrap_s() const { return wrap_s_; } | 89 GLenum wrap_s() const { return wrap_s_; } |
| 69 GLenum wrap_t() const { return wrap_t_; } | 90 GLenum wrap_t() const { return wrap_t_; } |
| 70 GLenum usage() const { return usage_; } | 91 GLenum usage() const { return usage_; } |
| 71 | 92 |
| 72 bool immutable() const { return immutable_; } | 93 bool immutable() const { return immutable_; } |
| 73 | 94 |
| 74 const LevelInfos& level_infos() const { | 95 LevelInfos& level_infos() { |
| 75 return level_infos_; | 96 return level_infos_; |
| 76 } | 97 } |
| 77 | 98 |
| 99 // A static definition for a 2D texture of size 0x0. |
| 100 static TextureDefinition kEmptyTexture2D; |
| 101 |
| 78 private: | 102 private: |
| 103 ~TextureDefinition(); |
| 104 GLuint ReleaseServiceId(bool delete_texture); |
| 105 |
| 79 GLenum target_; | 106 GLenum target_; |
| 80 GLuint service_id_; | 107 GLuint service_id_; |
| 81 GLenum min_filter_; | 108 GLenum min_filter_; |
| 82 GLenum mag_filter_; | 109 GLenum mag_filter_; |
| 83 GLenum wrap_s_; | 110 GLenum wrap_s_; |
| 84 GLenum wrap_t_; | 111 GLenum wrap_t_; |
| 85 GLenum usage_; | 112 GLenum usage_; |
| 86 bool immutable_; | 113 bool immutable_; |
| 87 std::vector<std::vector<LevelInfo> > level_infos_; | 114 std::vector<std::vector<LevelInfo> > level_infos_; |
| 115 ObserverList<Observer> observers_; |
| 116 |
| 117 typedef std::set<const Client*> ClientList; |
| 118 mutable ClientList active_clients_; |
| 119 const Client* client_transferred_from_; |
| 120 |
| 121 static std::set<GLuint> shared_texture_ids_; |
| 88 | 122 |
| 89 DISALLOW_COPY_AND_ASSIGN(TextureDefinition); | 123 DISALLOW_COPY_AND_ASSIGN(TextureDefinition); |
| 90 }; | 124 }; |
| 91 | 125 |
| 92 } // namespage gles2 | 126 } // namespage gles2 |
| 93 } // namespace gpu | 127 } // namespace gpu |
| 94 | 128 |
| 95 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_DEFINITION_H_ | 129 #endif // GPU_COMMAND_BUFFER_SERVICE_TEXTURE_DEFINITION_H_ |
| OLD | NEW |