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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "components/mus/public/cpp/scoped_window_ptr.h" | 9 #include "components/mus/public/cpp/scoped_window_ptr.h" |
10 #include "components/mus/public/cpp/types.h" | 10 #include "components/mus/public/cpp/types.h" |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 0, | 152 0, |
153 bitmap_size.width, | 153 bitmap_size.width, |
154 bitmap_size.height, | 154 bitmap_size.height, |
155 TextureFormat(), | 155 TextureFormat(), |
156 GL_UNSIGNED_BYTE, | 156 GL_UNSIGNED_BYTE, |
157 &((*bitmap_)[0])); | 157 &((*bitmap_)[0])); |
158 | 158 |
159 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; | 159 GLbyte mailbox[GL_MAILBOX_SIZE_CHROMIUM]; |
160 glGenMailboxCHROMIUM(mailbox); | 160 glGenMailboxCHROMIUM(mailbox); |
161 glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox); | 161 glProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox); |
162 GLuint sync_point = glInsertSyncPointCHROMIUM(); | 162 gpu::SyncToken sync_token(glInsertSyncPointCHROMIUM()); |
163 | 163 |
164 mus::mojom::TransferableResourcePtr resource = | 164 mus::mojom::TransferableResourcePtr resource = |
165 mus::mojom::TransferableResource::New(); | 165 mus::mojom::TransferableResource::New(); |
166 resource->id = next_resource_id_++; | 166 resource->id = next_resource_id_++; |
167 resource_to_texture_id_map_[resource->id] = texture_id; | 167 resource_to_texture_id_map_[resource->id] = texture_id; |
168 resource->format = mus::mojom::RESOURCE_FORMAT_RGBA_8888; | 168 resource->format = mus::mojom::RESOURCE_FORMAT_RGBA_8888; |
169 resource->filter = GL_LINEAR; | 169 resource->filter = GL_LINEAR; |
170 resource->size = bitmap_size.Clone(); | 170 resource->size = bitmap_size.Clone(); |
171 mus::mojom::MailboxHolderPtr mailbox_holder = | 171 mus::mojom::MailboxHolderPtr mailbox_holder = |
172 mus::mojom::MailboxHolder::New(); | 172 mus::mojom::MailboxHolder::New(); |
173 mailbox_holder->mailbox = mus::mojom::Mailbox::New(); | 173 mailbox_holder->mailbox = mus::mojom::Mailbox::New(); |
174 for (int i = 0; i < GL_MAILBOX_SIZE_CHROMIUM; ++i) | 174 for (int i = 0; i < GL_MAILBOX_SIZE_CHROMIUM; ++i) |
175 mailbox_holder->mailbox->name.push_back(mailbox[i]); | 175 mailbox_holder->mailbox->name.push_back(mailbox[i]); |
176 mailbox_holder->texture_target = GL_TEXTURE_2D; | 176 mailbox_holder->texture_target = GL_TEXTURE_2D; |
177 mailbox_holder->sync_point = sync_point; | 177 mailbox_holder->sync_token = |
| 178 mus::mojom::SyncToken::From<gpu::SyncToken>(sync_token); |
178 resource->mailbox_holder = mailbox_holder.Pass(); | 179 resource->mailbox_holder = mailbox_holder.Pass(); |
179 resource->is_repeated = false; | 180 resource->is_repeated = false; |
180 resource->is_software = false; | 181 resource->is_software = false; |
181 | 182 |
182 mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); | 183 mus::mojom::QuadPtr quad = mus::mojom::Quad::New(); |
183 quad->material = mus::mojom::MATERIAL_TEXTURE_CONTENT; | 184 quad->material = mus::mojom::MATERIAL_TEXTURE_CONTENT; |
184 | 185 |
185 mojo::RectPtr rect = mojo::Rect::New(); | 186 mojo::RectPtr rect = mojo::Rect::New(); |
186 if (width_ <= bounds.width() && height_ <= bounds.height()) { | 187 if (width_ <= bounds.width() && height_ <= bounds.height()) { |
187 rect->width = width_; | 188 rect->width = width_; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 } | 279 } |
279 | 280 |
280 // SurfaceClient implementation. | 281 // SurfaceClient implementation. |
281 void ReturnResources( | 282 void ReturnResources( |
282 mojo::Array<mus::mojom::ReturnedResourcePtr> resources) override { | 283 mojo::Array<mus::mojom::ReturnedResourcePtr> resources) override { |
283 MojoGLES2MakeCurrent(gles2_context_); | 284 MojoGLES2MakeCurrent(gles2_context_); |
284 // TODO(jamesr): Recycle. | 285 // TODO(jamesr): Recycle. |
285 for (size_t i = 0; i < resources.size(); ++i) { | 286 for (size_t i = 0; i < resources.size(); ++i) { |
286 mus::mojom::ReturnedResourcePtr resource = resources[i].Pass(); | 287 mus::mojom::ReturnedResourcePtr resource = resources[i].Pass(); |
287 DCHECK_EQ(1, resource->count); | 288 DCHECK_EQ(1, resource->count); |
288 glWaitSyncPointCHROMIUM(resource->sync_point); | 289 glWaitSyncTokenCHROMIUM( |
| 290 resource->sync_token.To<gpu::SyncToken>().GetConstData()); |
289 uint32_t texture_id = resource_to_texture_id_map_[resource->id]; | 291 uint32_t texture_id = resource_to_texture_id_map_[resource->id]; |
290 DCHECK_NE(0u, texture_id); | 292 DCHECK_NE(0u, texture_id); |
291 resource_to_texture_id_map_.erase(resource->id); | 293 resource_to_texture_id_map_.erase(resource->id); |
292 glDeleteTextures(1, &texture_id); | 294 glDeleteTextures(1, &texture_id); |
293 } | 295 } |
294 } | 296 } |
295 | 297 |
296 mus::Window* view_; | 298 mus::Window* view_; |
297 mus::mojom::GpuPtr gpu_service_; | 299 mus::mojom::GpuPtr gpu_service_; |
298 scoped_ptr<mus::WindowSurface> surface_; | 300 scoped_ptr<mus::WindowSurface> surface_; |
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 | 637 |
636 DISALLOW_COPY_AND_ASSIGN(PDFViewer); | 638 DISALLOW_COPY_AND_ASSIGN(PDFViewer); |
637 }; | 639 }; |
638 } // namespace | 640 } // namespace |
639 } // namespace pdf_viewer | 641 } // namespace pdf_viewer |
640 | 642 |
641 MojoResult MojoMain(MojoHandle application_request) { | 643 MojoResult MojoMain(MojoHandle application_request) { |
642 mojo::ApplicationRunner runner(new pdf_viewer::PDFViewer()); | 644 mojo::ApplicationRunner runner(new pdf_viewer::PDFViewer()); |
643 return runner.Run(application_request); | 645 return runner.Run(application_request); |
644 } | 646 } |
OLD | NEW |