OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/ui/gl_renderer.h" | 5 #include "mojo/ui/gl_renderer.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 #include <GLES2/gl2.h> | 10 #include <GLES2/gl2.h> |
(...skipping 27 matching lines...) Expand all Loading... |
38 gl_context_->MakeCurrent(); | 38 gl_context_->MakeCurrent(); |
39 glWaitSyncPointCHROMIUM(texture_info.second); | 39 glWaitSyncPointCHROMIUM(texture_info.second); |
40 return std::move(texture_info.first); | 40 return std::move(texture_info.first); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 return std::unique_ptr<GLTexture>(new GLTexture(gl_context_, requested_size)); | 44 return std::unique_ptr<GLTexture>(new GLTexture(gl_context_, requested_size)); |
45 } | 45 } |
46 | 46 |
47 mojo::gfx::composition::ResourcePtr GLRenderer::BindTextureResource( | 47 mojo::gfx::composition::ResourcePtr GLRenderer::BindTextureResource( |
48 std::unique_ptr<GLTexture> texture) { | 48 std::unique_ptr<GLTexture> texture, |
| 49 mojo::gfx::composition::MailboxTextureResource::Origin origin) { |
49 if (!gl_context_) | 50 if (!gl_context_) |
50 return nullptr; | 51 return nullptr; |
51 | 52 |
52 // Produce the texture. | 53 // Produce the texture. |
53 gl_context_->MakeCurrent(); | 54 gl_context_->MakeCurrent(); |
54 glBindTexture(GL_TEXTURE_2D, texture->texture_id()); | 55 glBindTexture(GL_TEXTURE_2D, texture->texture_id()); |
55 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; | 56 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; |
56 glGenMailboxCHROMIUM(mailbox); | 57 glGenMailboxCHROMIUM(mailbox); |
57 glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox); | 58 glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox); |
58 glBindTexture(GL_TEXTURE_2D, 0); | 59 glBindTexture(GL_TEXTURE_2D, 0); |
59 GLuint sync_point = glInsertSyncPointCHROMIUM(); | 60 GLuint sync_point = glInsertSyncPointCHROMIUM(); |
60 | 61 |
61 // Populate the resource description. | 62 // Populate the resource description. |
62 auto resource = mojo::gfx::composition::Resource::New(); | 63 auto resource = mojo::gfx::composition::Resource::New(); |
63 resource->set_mailbox_texture( | 64 resource->set_mailbox_texture( |
64 mojo::gfx::composition::MailboxTextureResource::New()); | 65 mojo::gfx::composition::MailboxTextureResource::New()); |
65 resource->get_mailbox_texture()->mailbox_name.resize(sizeof(mailbox)); | 66 resource->get_mailbox_texture()->mailbox_name.resize(sizeof(mailbox)); |
66 memcpy(resource->get_mailbox_texture()->mailbox_name.data(), mailbox, | 67 memcpy(resource->get_mailbox_texture()->mailbox_name.data(), mailbox, |
67 sizeof(mailbox)); | 68 sizeof(mailbox)); |
68 resource->get_mailbox_texture()->sync_point = sync_point; | 69 resource->get_mailbox_texture()->sync_point = sync_point; |
69 resource->get_mailbox_texture()->size = texture->size().Clone(); | 70 resource->get_mailbox_texture()->size = texture->size().Clone(); |
| 71 resource->get_mailbox_texture()->origin = origin; |
70 resource->get_mailbox_texture()->callback = | 72 resource->get_mailbox_texture()->callback = |
71 (new GLTextureReleaser( | 73 (new GLTextureReleaser( |
72 weak_factory_.GetWeakPtr(), | 74 weak_factory_.GetWeakPtr(), |
73 GLRecycledTextureInfo(std::move(texture), sync_point))) | 75 GLRecycledTextureInfo(std::move(texture), sync_point))) |
74 ->StrongBind() | 76 ->StrongBind() |
75 .Pass(); | 77 .Pass(); |
76 | 78 |
77 bound_textures_++; | 79 bound_textures_++; |
78 DVLOG(2) << "bind: bound_textures=" << bound_textures_; | 80 DVLOG(2) << "bind: bound_textures=" << bound_textures_; |
79 return resource; | 81 return resource; |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 154 |
153 void GLRenderer::GLTextureReleaser::Release(bool recyclable) { | 155 void GLRenderer::GLTextureReleaser::Release(bool recyclable) { |
154 if (provider_) { | 156 if (provider_) { |
155 provider_->ReleaseTexture(std::move(texture_info_), recyclable); | 157 provider_->ReleaseTexture(std::move(texture_info_), recyclable); |
156 provider_.reset(); | 158 provider_.reset(); |
157 } | 159 } |
158 } | 160 } |
159 | 161 |
160 } // namespace ui | 162 } // namespace ui |
161 } // namespace mojo | 163 } // namespace mojo |
OLD | NEW |