| 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/threading/thread_task_runner_handle.h" | 8 #include "base/threading/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" |
| 11 #include "ui/gl/gl_context.h" | 11 #include "ui/gl/gl_context.h" |
| 12 #include "ui/gl/gl_surface.h" | 12 #include "ui/gl/gl_surface.h" |
| 13 #include "ui/gl/init/gl_factory.h" | 13 #include "ui/gl/init/gl_factory.h" |
| 14 | 14 |
| 15 namespace ui { | 15 namespace ui { |
| 16 | 16 |
| 17 GlRenderer::GlRenderer(gfx::AcceleratedWidget widget, | 17 GlRenderer::GlRenderer(gfx::AcceleratedWidget widget, |
| 18 const scoped_refptr<gfx::GLSurface>& surface, | 18 const scoped_refptr<gl::GLSurface>& surface, |
| 19 const gfx::Size& size) | 19 const gfx::Size& size) |
| 20 : RendererBase(widget, size), surface_(surface), weak_ptr_factory_(this) {} | 20 : RendererBase(widget, size), surface_(surface), weak_ptr_factory_(this) {} |
| 21 | 21 |
| 22 GlRenderer::~GlRenderer() { | 22 GlRenderer::~GlRenderer() { |
| 23 } | 23 } |
| 24 | 24 |
| 25 bool GlRenderer::Initialize() { | 25 bool GlRenderer::Initialize() { |
| 26 context_ = gl::init::CreateGLContext(nullptr, surface_.get(), | 26 context_ = gl::init::CreateGLContext(nullptr, surface_.get(), |
| 27 gfx::PreferIntegratedGpu); | 27 gl::PreferIntegratedGpu); |
| 28 if (!context_.get()) { | 28 if (!context_.get()) { |
| 29 LOG(ERROR) << "Failed to create GL context"; | 29 LOG(ERROR) << "Failed to create GL context"; |
| 30 return false; | 30 return false; |
| 31 } | 31 } |
| 32 | 32 |
| 33 surface_->Resize(size_, 1.f, true); | 33 surface_->Resize(size_, 1.f, true); |
| 34 | 34 |
| 35 if (!context_->MakeCurrent(surface_.get())) { | 35 if (!context_->MakeCurrent(surface_.get())) { |
| 36 LOG(ERROR) << "Failed to make GL context current"; | 36 LOG(ERROR) << "Failed to make GL context current"; |
| 37 return false; | 37 return false; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 56 weak_ptr_factory_.GetWeakPtr())); | 56 weak_ptr_factory_.GetWeakPtr())); |
| 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 |