Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(550)

Side by Side Diff: gpu/command_buffer/service/texture_manager.cc

Issue 15798014: Replace context parenting by sharing through mailboxes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #include "gpu/command_buffer/service/texture_manager.h" 5 #include "gpu/command_buffer/service/texture_manager.h"
6 #include "base/bits.h" 6 #include "base/bits.h"
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h"
9 #include "gpu/command_buffer/service/error_state.h" 9 #include "gpu/command_buffer/service/error_state.h"
10 #include "gpu/command_buffer/service/feature_info.h" 10 #include "gpu/command_buffer/service/feature_info.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 wrap_s_(GL_REPEAT), 107 wrap_s_(GL_REPEAT),
108 wrap_t_(GL_REPEAT), 108 wrap_t_(GL_REPEAT),
109 usage_(GL_NONE), 109 usage_(GL_NONE),
110 pool_(GL_TEXTURE_POOL_UNMANAGED_CHROMIUM), 110 pool_(GL_TEXTURE_POOL_UNMANAGED_CHROMIUM),
111 max_level_set_(-1), 111 max_level_set_(-1),
112 texture_complete_(false), 112 texture_complete_(false),
113 cube_complete_(false), 113 cube_complete_(false),
114 npot_(false), 114 npot_(false),
115 has_been_bound_(false), 115 has_been_bound_(false),
116 framebuffer_attachment_count_(0), 116 framebuffer_attachment_count_(0),
117 owned_(true),
118 stream_texture_(false), 117 stream_texture_(false),
119 immutable_(false), 118 immutable_(false),
120 estimated_size_(0), 119 estimated_size_(0),
121 can_render_condition_(CAN_RENDER_ALWAYS) { 120 can_render_condition_(CAN_RENDER_ALWAYS) {
122 } 121 }
123 122
124 Texture::~Texture() { 123 Texture::~Texture() {
125 if (mailbox_manager_) 124 if (mailbox_manager_)
126 mailbox_manager_->TextureDeleted(this); 125 mailbox_manager_->TextureDeleted(this);
127 } 126 }
128 127
129 void Texture::AddTextureRef(TextureRef* ref) { 128 void Texture::AddTextureRef(TextureRef* ref) {
130 DCHECK(refs_.find(ref) == refs_.end()); 129 DCHECK(refs_.find(ref) == refs_.end());
131 refs_.insert(ref); 130 refs_.insert(ref);
132 if (!memory_tracking_ref_) { 131 if (!memory_tracking_ref_) {
133 memory_tracking_ref_ = ref; 132 memory_tracking_ref_ = ref;
134 GetMemTracker()->TrackMemAlloc(estimated_size()); 133 GetMemTracker()->TrackMemAlloc(estimated_size());
135 } 134 }
136 } 135 }
137 136
138 void Texture::RemoveTextureRef(TextureRef* ref, bool have_context) { 137 void Texture::RemoveTextureRef(TextureRef* ref, bool have_context) {
139 if (memory_tracking_ref_ == ref) { 138 if (memory_tracking_ref_ == ref) {
140 GetMemTracker()->TrackMemFree(estimated_size()); 139 GetMemTracker()->TrackMemFree(estimated_size());
141 memory_tracking_ref_ = NULL; 140 memory_tracking_ref_ = NULL;
142 } 141 }
143 size_t result = refs_.erase(ref); 142 size_t result = refs_.erase(ref);
144 DCHECK_EQ(result, 1u); 143 DCHECK_EQ(result, 1u);
145 if (refs_.empty()) { 144 if (refs_.empty()) {
146 if (owned_ && have_context) { 145 if (have_context) {
147 GLuint id = service_id(); 146 GLuint id = service_id();
148 glDeleteTextures(1, &id); 147 glDeleteTextures(1, &id);
149 } 148 }
150 delete this; 149 delete this;
151 } else if (memory_tracking_ref_ == NULL) { 150 } else if (memory_tracking_ref_ == NULL) {
152 // TODO(piman): tune ownership semantics for cross-context group shared 151 // TODO(piman): tune ownership semantics for cross-context group shared
153 // textures. 152 // textures.
154 memory_tracking_ref_ = *refs_.begin(); 153 memory_tracking_ref_ = *refs_.begin();
155 GetMemTracker()->TrackMemAlloc(estimated_size()); 154 GetMemTracker()->TrackMemAlloc(estimated_size());
156 } 155 }
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 depth, 1034 depth,
1036 border, 1035 border,
1037 format, 1036 format,
1038 type, 1037 type,
1039 cleared); 1038 cleared);
1040 texture->GetMemTracker()->TrackMemAlloc(texture->estimated_size()); 1039 texture->GetMemTracker()->TrackMemAlloc(texture->estimated_size());
1041 } 1040 }
1042 1041
1043 Texture* TextureManager::Produce(TextureRef* ref) { 1042 Texture* TextureManager::Produce(TextureRef* ref) {
1044 DCHECK(ref); 1043 DCHECK(ref);
1045 Texture* texture = ref->texture(); 1044 return ref->texture();
1046 if (!texture->owned_)
1047 return NULL;
1048 return texture;
1049 } 1045 }
1050 1046
1051 TextureRef* TextureManager::Consume( 1047 TextureRef* TextureManager::Consume(
1052 GLuint client_id, 1048 GLuint client_id,
1053 Texture* texture) { 1049 Texture* texture) {
1054 DCHECK(client_id); 1050 DCHECK(client_id);
1055 scoped_refptr<TextureRef> ref(new TextureRef(this, client_id, texture)); 1051 scoped_refptr<TextureRef> ref(new TextureRef(this, client_id, texture));
1056 bool result = textures_.insert(std::make_pair(client_id, ref)).second; 1052 bool result = textures_.insert(std::make_pair(client_id, ref)).second;
1057 DCHECK(result); 1053 DCHECK(result);
1058 return ref.get(); 1054 return ref.get();
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1219 } 1215 }
1220 1216
1221 void TextureManager::IncFramebufferStateChangeCount() { 1217 void TextureManager::IncFramebufferStateChangeCount() {
1222 if (framebuffer_manager_) 1218 if (framebuffer_manager_)
1223 framebuffer_manager_->IncFramebufferStateChangeCount(); 1219 framebuffer_manager_->IncFramebufferStateChangeCount();
1224 1220
1225 } 1221 }
1226 1222
1227 } // namespace gles2 1223 } // namespace gles2
1228 } // namespace gpu 1224 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/texture_manager.h ('k') | gpu/command_buffer/service/texture_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698