OLD | NEW |
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/bitmap_uploader/bitmap_uploader.h" | 5 #include "examples/bitmap_uploader/bitmap_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 // GL_GLEXT_PROTOTYPES | 9 #endif // GL_GLEXT_PROTOTYPES |
10 | 10 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 view_->SetSurfaceId(SurfaceId::New()); | 96 view_->SetSurfaceId(SurfaceId::New()); |
97 return; | 97 return; |
98 } | 98 } |
99 if (!surface_) // Can't upload yet, store for later. | 99 if (!surface_) // Can't upload yet, store for later. |
100 return; | 100 return; |
101 if (!surface_id_ || size != surface_size_) { | 101 if (!surface_id_ || size != surface_size_) { |
102 if (surface_id_) { | 102 if (surface_id_) { |
103 surface_->DestroySurface(surface_id_.Clone()); | 103 surface_->DestroySurface(surface_id_.Clone()); |
104 } else { | 104 } else { |
105 surface_id_ = SurfaceId::New(); | 105 surface_id_ = SurfaceId::New(); |
106 surface_id_->id = static_cast<uint64_t>(id_namespace_) << 32; | 106 surface_id_->id_namespace = id_namespace_; |
107 } | 107 } |
108 surface_id_->id++; | 108 surface_id_->local++; |
109 surface_->CreateSurface(surface_id_.Clone(), size.Clone()); | 109 surface_->CreateSurface(surface_id_.Clone()); |
110 view_->SetSurfaceId(surface_id_.Clone()); | 110 view_->SetSurfaceId(surface_id_.Clone()); |
111 surface_size_ = size; | 111 surface_size_ = size; |
112 } | 112 } |
113 | 113 |
114 Rect bounds; | 114 Rect bounds; |
115 bounds.width = size.width; | 115 bounds.width = size.width; |
116 bounds.height = size.height; | 116 bounds.height = size.height; |
117 PassPtr pass = CreateDefaultPass(1, bounds); | 117 PassPtr pass = CreateDefaultPass(1, bounds); |
118 FramePtr frame = Frame::New(); | 118 FramePtr frame = Frame::New(); |
119 frame->resources.resize(0u); | 119 frame->resources.resize(0u); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 | 218 |
219 quad->solid_color_quad_state = color_state.Pass(); | 219 quad->solid_color_quad_state = color_state.Pass(); |
220 pass->quads.push_back(quad.Pass()); | 220 pass->quads.push_back(quad.Pass()); |
221 } | 221 } |
222 | 222 |
223 frame->passes.push_back(pass.Pass()); | 223 frame->passes.push_back(pass.Pass()); |
224 | 224 |
225 surface_->SubmitFrame(surface_id_.Clone(), frame.Pass(), mojo::Closure()); | 225 surface_->SubmitFrame(surface_id_.Clone(), frame.Pass(), mojo::Closure()); |
226 } | 226 } |
227 | 227 |
| 228 void BitmapUploader::SetIdNamespace(uint32_t id_namespace) { |
| 229 } |
| 230 |
228 void BitmapUploader::ReturnResources(Array<ReturnedResourcePtr> resources) { | 231 void BitmapUploader::ReturnResources(Array<ReturnedResourcePtr> resources) { |
229 if (!resources.size()) | 232 if (!resources.size()) |
230 return; | 233 return; |
231 MojoGLES2MakeCurrent(gles2_context_); | 234 MojoGLES2MakeCurrent(gles2_context_); |
232 // TODO(jamesr): Recycle. | 235 // TODO(jamesr): Recycle. |
233 for (size_t i = 0; i < resources.size(); ++i) { | 236 for (size_t i = 0; i < resources.size(); ++i) { |
234 ReturnedResourcePtr resource = resources[i].Pass(); | 237 ReturnedResourcePtr resource = resources[i].Pass(); |
235 DCHECK_EQ(1, resource->count); | 238 DCHECK_EQ(1, resource->count); |
236 glWaitSyncPointCHROMIUM(resource->sync_point); | 239 glWaitSyncPointCHROMIUM(resource->sync_point); |
237 uint32_t texture_id = resource_to_texture_id_map_[resource->id]; | 240 uint32_t texture_id = resource_to_texture_id_map_[resource->id]; |
(...skipping 28 matching lines...) Expand all Loading... |
266 0); | 269 0); |
267 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 270 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
268 return texture; | 271 return texture; |
269 } | 272 } |
270 | 273 |
271 uint32_t BitmapUploader::TextureFormat() { | 274 uint32_t BitmapUploader::TextureFormat() { |
272 return format_ == BGRA ? GL_BGRA_EXT : GL_RGBA; | 275 return format_ == BGRA ? GL_BGRA_EXT : GL_RGBA; |
273 } | 276 } |
274 | 277 |
275 } // namespace mojo | 278 } // namespace mojo |
OLD | NEW |