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 "ui/gl/gl_bindings.h" | 7 #include "ui/gl/gl_bindings.h" |
8 #include "ui/gl/gl_context.h" | 8 #include "ui/gl/gl_context.h" |
9 #include "ui/gl/gl_surface.h" | 9 #include "ui/gl/gl_surface.h" |
10 | 10 |
11 namespace ui { | 11 namespace ui { |
12 | 12 |
13 GlRenderer::GlRenderer(gfx::AcceleratedWidget widget, const gfx::Size& size) | 13 GlRenderer::GlRenderer(gfx::AcceleratedWidget widget, const gfx::Size& size) |
14 : RendererBase(widget, size) { | 14 : RendererBase(widget, size) { |
15 } | 15 } |
16 | 16 |
17 GlRenderer::~GlRenderer() { | 17 GlRenderer::~GlRenderer() { |
18 } | 18 } |
19 | 19 |
20 bool GlRenderer::Initialize() { | 20 bool GlRenderer::Initialize() { |
21 surface_ = gfx::GLSurface::CreateViewGLSurface(widget_); | 21 surface_ = CreateSurface(); |
22 if (!surface_.get()) { | 22 if (!surface_.get()) { |
23 LOG(ERROR) << "Failed to create GL surface"; | 23 LOG(ERROR) << "Failed to create GL surface"; |
24 return false; | 24 return false; |
25 } | 25 } |
26 | 26 |
27 context_ = gfx::GLContext::CreateGLContext(NULL, surface_.get(), | 27 context_ = gfx::GLContext::CreateGLContext(NULL, surface_.get(), |
28 gfx::PreferIntegratedGpu); | 28 gfx::PreferIntegratedGpu); |
29 if (!context_.get()) { | 29 if (!context_.get()) { |
30 LOG(ERROR) << "Failed to create GL context"; | 30 LOG(ERROR) << "Failed to create GL context"; |
31 return false; | 31 return false; |
(...skipping 15 matching lines...) Expand all Loading... |
47 context_->MakeCurrent(surface_.get()); | 47 context_->MakeCurrent(surface_.get()); |
48 | 48 |
49 glViewport(0, 0, size_.width(), size_.height()); | 49 glViewport(0, 0, size_.width(), size_.height()); |
50 glClearColor(1 - fraction, fraction, 0.0, 1.0); | 50 glClearColor(1 - fraction, fraction, 0.0, 1.0); |
51 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); | 51 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
52 | 52 |
53 if (!surface_->SwapBuffers()) | 53 if (!surface_->SwapBuffers()) |
54 LOG(FATAL) << "Failed to swap buffers"; | 54 LOG(FATAL) << "Failed to swap buffers"; |
55 } | 55 } |
56 | 56 |
| 57 scoped_refptr<gfx::GLSurface> GlRenderer::CreateSurface() { |
| 58 return gfx::GLSurface::CreateViewGLSurface(widget_); |
| 59 } |
| 60 |
57 } // namespace ui | 61 } // namespace ui |
OLD | NEW |