OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/examples/compositor_app/gles2_client_impl.h" | 5 #include "mojo/examples/compositor_app/gles2_client_impl.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "gpu/command_buffer/client/gles2_implementation.h" | 8 #include "gpu/command_buffer/client/gles2_implementation.h" |
9 #include "mojo/public/gles2/gles2.h" | 9 #include "mojo/public/gles2/gles2.h" |
10 | 10 |
11 namespace mojo { | 11 namespace mojo { |
12 namespace examples { | 12 namespace examples { |
13 | 13 |
14 GLES2ClientImpl::GLES2ClientImpl( | 14 GLES2ClientImpl::GLES2ClientImpl( |
15 ScopedMessagePipeHandle pipe, | 15 ScopedMessagePipeHandle pipe, |
16 const base::Callback<void(gfx::Size)>& context_created_callback) | 16 const base::Callback<void(gfx::Size)>& context_created_callback) |
17 : context_created_callback_(context_created_callback), | 17 : context_created_callback_(context_created_callback), |
18 impl_(NULL), | 18 impl_(NULL), |
19 service_(pipe.Pass()) { | 19 service_(pipe.Pass(), this) { |
20 service_.SetPeer(this); | |
21 } | 20 } |
22 | 21 |
23 GLES2ClientImpl::~GLES2ClientImpl() { service_->Destroy(); } | 22 GLES2ClientImpl::~GLES2ClientImpl() { service_->Destroy(); } |
24 | 23 |
25 void GLES2ClientImpl::DidCreateContext(uint64_t encoded, | 24 void GLES2ClientImpl::DidCreateContext(uint64_t encoded, |
26 uint32_t width, | 25 uint32_t width, |
27 uint32_t height) { | 26 uint32_t height) { |
28 TRACE_EVENT0("compositor_app", "DidCreateContext"); | 27 TRACE_EVENT0("compositor_app", "DidCreateContext"); |
29 impl_ = reinterpret_cast<gpu::gles2::GLES2Implementation*>(encoded); | 28 impl_ = reinterpret_cast<gpu::gles2::GLES2Implementation*>(encoded); |
30 if (!context_created_callback_.is_null()) | 29 if (!context_created_callback_.is_null()) |
31 context_created_callback_.Run(gfx::Size(width, height)); | 30 context_created_callback_.Run(gfx::Size(width, height)); |
32 } | 31 } |
33 | 32 |
34 gpu::gles2::GLES2Interface* GLES2ClientImpl::Interface() const { | 33 gpu::gles2::GLES2Interface* GLES2ClientImpl::Interface() const { |
35 return impl_; | 34 return impl_; |
36 } | 35 } |
37 | 36 |
38 gpu::ContextSupport* GLES2ClientImpl::Support() const { | 37 gpu::ContextSupport* GLES2ClientImpl::Support() const { |
39 return impl_; | 38 return impl_; |
40 } | 39 } |
41 | 40 |
42 void GLES2ClientImpl::ContextLost() { impl_ = NULL; } | 41 void GLES2ClientImpl::ContextLost() { impl_ = NULL; } |
43 | 42 |
44 } // namespace examples | 43 } // namespace examples |
45 } // namespace mojo | 44 } // namespace mojo |
OLD | NEW |