| 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 service_(pipe.Pass()) { | 19 service_(pipe.Pass()) { |
| 19 service_.SetPeer(this); | 20 service_.SetPeer(this); |
| 20 } | 21 } |
| 21 | 22 |
| 22 GLES2ClientImpl::~GLES2ClientImpl() { service_->Destroy(); } | 23 GLES2ClientImpl::~GLES2ClientImpl() { service_->Destroy(); } |
| 23 | 24 |
| 24 void GLES2ClientImpl::DidCreateContext(uint64_t encoded, | 25 void GLES2ClientImpl::DidCreateContext(uint64_t encoded, |
| 25 uint32_t width, | 26 uint32_t width, |
| 26 uint32_t height) { | 27 uint32_t height) { |
| 27 TRACE_EVENT0("compositor_app", "DidCreateContext"); | 28 TRACE_EVENT0("compositor_app", "DidCreateContext"); |
| 28 impl_ = reinterpret_cast<gpu::gles2::GLES2Implementation*>(encoded); | 29 impl_ = reinterpret_cast<gpu::gles2::GLES2Implementation*>(encoded); |
| 29 if (!context_created_callback_.is_null()) | 30 if (!context_created_callback_.is_null()) |
| 30 context_created_callback_.Run(gfx::Size(width, height)); | 31 context_created_callback_.Run(gfx::Size(width, height)); |
| 31 } | 32 } |
| 32 | 33 |
| 33 gpu::gles2::GLES2Interface* GLES2ClientImpl::Interface() const { | 34 gpu::gles2::GLES2Interface* GLES2ClientImpl::Interface() const { |
| 34 return impl_; | 35 return impl_; |
| 35 } | 36 } |
| 36 | 37 |
| 37 gpu::ContextSupport* GLES2ClientImpl::Support() const { | 38 gpu::ContextSupport* GLES2ClientImpl::Support() const { |
| 38 return impl_; | 39 return impl_; |
| 39 } | 40 } |
| 40 | 41 |
| 41 void GLES2ClientImpl::ContextLost() { impl_ = NULL; } | 42 void GLES2ClientImpl::ContextLost() { impl_ = NULL; } |
| 42 | 43 |
| 43 } // namespace examples | 44 } // namespace examples |
| 44 } // namespace mojo | 45 } // namespace mojo |
| OLD | NEW |