| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/ozone/demo/gl_renderer.h" | 5 #include "ui/ozone/demo/gl_renderer.h" |
| 6 | 6 |
| 7 #include "base/location.h" | 7 #include "base/location.h" |
| 8 #include "base/thread_task_runner_handle.h" | 8 #include "base/thread_task_runner_handle.h" |
| 9 #include "base/trace_event/trace_event.h" | 9 #include "base/trace_event/trace_event.h" |
| 10 #include "ui/gl/gl_bindings.h" | 10 #include "ui/gl/gl_bindings.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 } | 22 } |
| 23 | 23 |
| 24 bool GlRenderer::Initialize() { | 24 bool GlRenderer::Initialize() { |
| 25 context_ = gfx::GLContext::CreateGLContext(NULL, surface_.get(), | 25 context_ = gfx::GLContext::CreateGLContext(NULL, surface_.get(), |
| 26 gfx::PreferIntegratedGpu); | 26 gfx::PreferIntegratedGpu); |
| 27 if (!context_.get()) { | 27 if (!context_.get()) { |
| 28 LOG(ERROR) << "Failed to create GL context"; | 28 LOG(ERROR) << "Failed to create GL context"; |
| 29 return false; | 29 return false; |
| 30 } | 30 } |
| 31 | 31 |
| 32 surface_->Resize(size_); | 32 surface_->Resize(size_, 1.f); |
| 33 | 33 |
| 34 if (!context_->MakeCurrent(surface_.get())) { | 34 if (!context_->MakeCurrent(surface_.get())) { |
| 35 LOG(ERROR) << "Failed to make GL context current"; | 35 LOG(ERROR) << "Failed to make GL context current"; |
| 36 return false; | 36 return false; |
| 37 } | 37 } |
| 38 | 38 |
| 39 PostRenderFrameTask(gfx::SwapResult::SWAP_ACK); | 39 PostRenderFrameTask(gfx::SwapResult::SWAP_ACK); |
| 40 return true; | 40 return true; |
| 41 } | 41 } |
| 42 | 42 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 56 LOG(FATAL) << "Failed to swap buffers"; | 56 LOG(FATAL) << "Failed to swap buffers"; |
| 57 } | 57 } |
| 58 | 58 |
| 59 void GlRenderer::PostRenderFrameTask(gfx::SwapResult result) { | 59 void GlRenderer::PostRenderFrameTask(gfx::SwapResult result) { |
| 60 base::ThreadTaskRunnerHandle::Get()->PostTask( | 60 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 61 FROM_HERE, | 61 FROM_HERE, |
| 62 base::Bind(&GlRenderer::RenderFrame, weak_ptr_factory_.GetWeakPtr())); | 62 base::Bind(&GlRenderer::RenderFrame, weak_ptr_factory_.GetWeakPtr())); |
| 63 } | 63 } |
| 64 | 64 |
| 65 } // namespace ui | 65 } // namespace ui |
| OLD | NEW |