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 "mojo/services/public/cpp/view_manager/lib/bitmap_uploader.h" | 5 #include "mojo/services/public/cpp/view_manager/lib/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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 } | 99 } |
100 | 100 |
101 gfx::Rect bounds(size_); | 101 gfx::Rect bounds(size_); |
102 PassPtr pass = CreateDefaultPass(1, bounds); | 102 PassPtr pass = CreateDefaultPass(1, bounds); |
103 FramePtr frame = Frame::New(); | 103 FramePtr frame = Frame::New(); |
104 frame->resources.resize(0u); | 104 frame->resources.resize(0u); |
105 | 105 |
106 pass->quads.resize(0u); | 106 pass->quads.resize(0u); |
107 pass->shared_quad_states.push_back(CreateDefaultSQS(size_)); | 107 pass->shared_quad_states.push_back(CreateDefaultSQS(size_)); |
108 | 108 |
| 109 MojoGLES2MakeCurrent(gles2_context_); |
109 if (!bitmap_.isNull()) { | 110 if (!bitmap_.isNull()) { |
110 gfx::Size bitmap_size(bitmap_.width(), bitmap_.height()); | 111 gfx::Size bitmap_size(bitmap_.width(), bitmap_.height()); |
111 GLuint texture_id = BindTextureForSize(bitmap_size); | 112 GLuint texture_id = BindTextureForSize(bitmap_size); |
112 bitmap_.lockPixels(); | 113 bitmap_.lockPixels(); |
113 glTexSubImage2D(GL_TEXTURE_2D, | 114 glTexSubImage2D(GL_TEXTURE_2D, |
114 0, | 115 0, |
115 0, | 116 0, |
116 0, | 117 0, |
117 bitmap_size.width(), | 118 bitmap_size.width(), |
118 bitmap_size.height(), | 119 bitmap_size.height(), |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 quad->solid_color_quad_state = color_state.Pass(); | 179 quad->solid_color_quad_state = color_state.Pass(); |
179 pass->quads.push_back(quad.Pass()); | 180 pass->quads.push_back(quad.Pass()); |
180 } | 181 } |
181 | 182 |
182 frame->passes.push_back(pass.Pass()); | 183 frame->passes.push_back(pass.Pass()); |
183 | 184 |
184 surface_->SubmitFrame(SurfaceId::From(id_), frame.Pass()); | 185 surface_->SubmitFrame(SurfaceId::From(id_), frame.Pass()); |
185 } | 186 } |
186 | 187 |
187 void BitmapUploader::ReturnResources(Array<ReturnedResourcePtr> resources) { | 188 void BitmapUploader::ReturnResources(Array<ReturnedResourcePtr> resources) { |
| 189 if (!resources.size()) |
| 190 return; |
| 191 MojoGLES2MakeCurrent(gles2_context_); |
188 // TODO(jamesr): Recycle. | 192 // TODO(jamesr): Recycle. |
189 for (size_t i = 0; i < resources.size(); ++i) { | 193 for (size_t i = 0; i < resources.size(); ++i) { |
190 ReturnedResourcePtr resource = resources[i].Pass(); | 194 ReturnedResourcePtr resource = resources[i].Pass(); |
191 DCHECK_EQ(1, resource->count); | 195 DCHECK_EQ(1, resource->count); |
192 glWaitSyncPointCHROMIUM(resource->sync_point); | 196 glWaitSyncPointCHROMIUM(resource->sync_point); |
193 uint32_t texture_id = resource_to_texture_id_map_[resource->id]; | 197 uint32_t texture_id = resource_to_texture_id_map_[resource->id]; |
194 DCHECK_NE(0u, texture_id); | 198 DCHECK_NE(0u, texture_id); |
195 resource_to_texture_id_map_.erase(resource->id); | 199 resource_to_texture_id_map_.erase(resource->id); |
196 glDeleteTextures(1, &texture_id); | 200 glDeleteTextures(1, &texture_id); |
197 } | 201 } |
(...skipping 20 matching lines...) Expand all Loading... |
218 size.height(), | 222 size.height(), |
219 0, | 223 0, |
220 TextureFormat(), | 224 TextureFormat(), |
221 GL_UNSIGNED_BYTE, | 225 GL_UNSIGNED_BYTE, |
222 0); | 226 0); |
223 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 227 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
224 return texture; | 228 return texture; |
225 } | 229 } |
226 | 230 |
227 } // namespace mojo | 231 } // namespace mojo |
OLD | NEW |