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

Side by Side Diff: examples/ganesh_app/texture_uploader.cc

Issue 807733002: Split surface id and simplify connecting to surfaces service (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "examples/ganesh_app/texture_uploader.h" 5 #include "examples/ganesh_app/texture_uploader.h"
6 6
7 #ifndef GL_GLEXT_PROTOTYPES 7 #ifndef GL_GLEXT_PROTOTYPES
8 #define GL_GLEXT_PROTOTYPES 8 #define GL_GLEXT_PROTOTYPES
9 #endif 9 #endif
10 10
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 } 125 }
126 126
127 void TextureUploader::EnsureSurfaceForSize(const mojo::Size& size) { 127 void TextureUploader::EnsureSurfaceForSize(const mojo::Size& size) {
128 if (surface_id_ && size == surface_size_) 128 if (surface_id_ && size == surface_size_)
129 return; 129 return;
130 130
131 if (surface_id_) { 131 if (surface_id_) {
132 surface_->DestroySurface(surface_id_.Clone()); 132 surface_->DestroySurface(surface_id_.Clone());
133 } else { 133 } else {
134 surface_id_ = mojo::SurfaceId::New(); 134 surface_id_ = mojo::SurfaceId::New();
135 surface_id_->id = static_cast<uint64_t>(id_namespace_) << 32; 135 surface_id_->id_namespace = id_namespace_;
136 } 136 }
137 137
138 surface_id_->id++; 138 surface_id_->local++;
139 surface_->CreateSurface(surface_id_.Clone(), size.Clone()); 139 surface_->CreateSurface(surface_id_.Clone());
140 client_->OnSurfaceIdAvailable(surface_id_.Clone()); 140 client_->OnSurfaceIdAvailable(surface_id_.Clone());
141 surface_size_ = size; 141 surface_size_ = size;
142 } 142 }
143 143
144 void TextureUploader::OnContextLost() { 144 void TextureUploader::OnContextLost() {
145 LOG(FATAL) << "Context lost."; 145 LOG(FATAL) << "Context lost.";
146 } 146 }
147 147
148 void TextureUploader::SetIdNamespace(uint32_t id_namespace) {
149 }
150
148 void TextureUploader::ReturnResources( 151 void TextureUploader::ReturnResources(
149 mojo::Array<mojo::ReturnedResourcePtr> resources) { 152 mojo::Array<mojo::ReturnedResourcePtr> resources) {
150 if (!resources.size()) 153 if (!resources.size())
151 return; 154 return;
152 context_->MakeCurrent(); 155 context_->MakeCurrent();
153 for (size_t i = 0u; i < resources.size(); ++i) { 156 for (size_t i = 0u; i < resources.size(); ++i) {
154 mojo::ReturnedResourcePtr resource = resources[i].Pass(); 157 mojo::ReturnedResourcePtr resource = resources[i].Pass();
155 DCHECK_EQ(1, resource->count); 158 DCHECK_EQ(1, resource->count);
156 glWaitSyncPointCHROMIUM(resource->sync_point); 159 glWaitSyncPointCHROMIUM(resource->sync_point);
157 mojo::GLTexture* texture = resource_to_texture_map_[resource->id]; 160 mojo::GLTexture* texture = resource_to_texture_map_[resource->id];
158 DCHECK_NE(0u, texture->texture_id()); 161 DCHECK_NE(0u, texture->texture_id());
159 resource_to_texture_map_.erase(resource->id); 162 resource_to_texture_map_.erase(resource->id);
160 delete texture; 163 delete texture;
161 } 164 }
162 } 165 }
163 166
164 void TextureUploader::OnSurfaceConnectionCreated(mojo::SurfacePtr surface, 167 void TextureUploader::OnSurfaceConnectionCreated(mojo::SurfacePtr surface,
165 uint32_t id_namespace) { 168 uint32_t id_namespace) {
166 surface_ = surface.Pass(); 169 surface_ = surface.Pass();
167 surface_.set_client(this); 170 surface_.set_client(this);
168 id_namespace_ = id_namespace; 171 id_namespace_ = id_namespace;
169 172
170 if (pending_upload_) 173 if (pending_upload_)
171 Upload(pending_upload_.Pass()); 174 Upload(pending_upload_.Pass());
172 } 175 }
173 176
174 } // namespace examples 177 } // namespace examples
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698