Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(753)

Side by Side Diff: ui/ozone/demo/gl_renderer.cc

Issue 975733004: [Ozone-Demo] Update Surfaceless renderer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_gn
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/ozone/demo/gl_renderer.h ('k') | ui/ozone/demo/surfaceless_gl_renderer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « ui/ozone/demo/gl_renderer.h ('k') | ui/ozone/demo/surfaceless_gl_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698