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/view_manager/public/cpp/types.h" | 9 #include "components/view_manager/public/cpp/types.h" |
10 #include "components/view_manager/public/cpp/view.h" | 10 #include "components/view_manager/public/cpp/view.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 const uint32_t g_background_color = 0xFF888888; | 46 const uint32_t g_background_color = 0xFF888888; |
47 const uint32_t g_transparent_color = 0x00000000; | 47 const uint32_t g_transparent_color = 0x00000000; |
48 | 48 |
49 namespace pdf_viewer { | 49 namespace pdf_viewer { |
50 namespace { | 50 namespace { |
51 | 51 |
52 void LostContext(void*) { | 52 void LostContext(void*) { |
53 DCHECK(false); | 53 DCHECK(false); |
54 } | 54 } |
55 | 55 |
| 56 void OnGotContentHandlerID(uint32_t content_handler_id) {} |
| 57 |
56 // BitmapUploader is useful if you want to draw a bitmap or color in a View. | 58 // BitmapUploader is useful if you want to draw a bitmap or color in a View. |
57 class BitmapUploader : public mojo::SurfaceClient { | 59 class BitmapUploader : public mojo::SurfaceClient { |
58 public: | 60 public: |
59 explicit BitmapUploader(mojo::View* view) | 61 explicit BitmapUploader(mojo::View* view) |
60 : view_(view), | 62 : view_(view), |
61 color_(g_transparent_color), | 63 color_(g_transparent_color), |
62 width_(0), | 64 width_(0), |
63 height_(0), | 65 height_(0), |
64 format_(BGRA), | 66 format_(BGRA), |
65 next_resource_id_(1u), | 67 next_resource_id_(1u), |
66 id_namespace_(0u), | 68 id_namespace_(0u), |
67 local_id_(0u), | 69 local_id_(0u), |
68 returner_binding_(this) { | 70 returner_binding_(this) { |
69 } | 71 } |
70 ~BitmapUploader() override { | 72 ~BitmapUploader() override { |
71 MojoGLES2DestroyContext(gles2_context_); | 73 MojoGLES2DestroyContext(gles2_context_); |
72 } | 74 } |
73 | 75 |
74 void Init(mojo::Shell* shell) { | 76 void Init(mojo::Shell* shell) { |
75 surface_ = view_->RequestSurface(); | 77 surface_ = view_->RequestSurface(); |
76 | 78 |
77 mojo::ServiceProviderPtr gpu_service_provider; | 79 mojo::ServiceProviderPtr gpu_service_provider; |
78 mojo::URLRequestPtr request2(mojo::URLRequest::New()); | 80 mojo::URLRequestPtr request2(mojo::URLRequest::New()); |
79 request2->url = mojo::String::From("mojo:view_manager"); | 81 request2->url = mojo::String::From("mojo:view_manager"); |
80 shell->ConnectToApplication(request2.Pass(), | 82 shell->ConnectToApplication(request2.Pass(), |
81 mojo::GetProxy(&gpu_service_provider), nullptr, | 83 mojo::GetProxy(&gpu_service_provider), nullptr, |
82 nullptr); | 84 nullptr, base::Bind(&OnGotContentHandlerID)); |
83 ConnectToService(gpu_service_provider.get(), &gpu_service_); | 85 ConnectToService(gpu_service_provider.get(), &gpu_service_); |
84 | 86 |
85 mojo::CommandBufferPtr gles2_client; | 87 mojo::CommandBufferPtr gles2_client; |
86 gpu_service_->CreateOffscreenGLES2Context(GetProxy(&gles2_client)); | 88 gpu_service_->CreateOffscreenGLES2Context(GetProxy(&gles2_client)); |
87 gles2_context_ = MojoGLES2CreateContext( | 89 gles2_context_ = MojoGLES2CreateContext( |
88 gles2_client.PassInterface().PassHandle().release().value(), | 90 gles2_client.PassInterface().PassHandle().release().value(), |
89 &LostContext, NULL, mojo::Environment::GetDefaultAsyncWaiter()); | 91 &LostContext, NULL, mojo::Environment::GetDefaultAsyncWaiter()); |
90 MojoGLES2MakeCurrent(gles2_context_); | 92 MojoGLES2MakeCurrent(gles2_context_); |
91 } | 93 } |
92 | 94 |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 DISALLOW_COPY_AND_ASSIGN(PDFViewer); | 507 DISALLOW_COPY_AND_ASSIGN(PDFViewer); |
506 }; | 508 }; |
507 | 509 |
508 } // namespace | 510 } // namespace |
509 } // namespace pdf_viewer | 511 } // namespace pdf_viewer |
510 | 512 |
511 MojoResult MojoMain(MojoHandle application_request) { | 513 MojoResult MojoMain(MojoHandle application_request) { |
512 mojo::ApplicationRunner runner(new pdf_viewer::PDFViewer()); | 514 mojo::ApplicationRunner runner(new pdf_viewer::PDFViewer()); |
513 return runner.Run(application_request); | 515 return runner.Run(application_request); |
514 } | 516 } |
OLD | NEW |