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

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

Issue 356083002: [Ozone] Add Ozone EGL demo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « ui/ozone/demo/DEPS ('k') | ui/ozone/demo/ozone_demos.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/at_exit.h"
6 #include "base/command_line.h"
7 #include "ui/gfx/geometry/size.h"
8 #include "ui/gl/gl_bindings.h"
9 #include "ui/gl/gl_context.h"
10 #include "ui/gl/gl_surface.h"
11 #include "ui/ozone/ozone_platform.h"
12 #include "ui/ozone/public/surface_factory_ozone.h"
13
14 int main(int argc, char** argv) {
15 CommandLine::Init(argc, argv);
16 base::AtExitManager exit_manager;
17
18 ui::OzonePlatform::InitializeForUI();
19 if (!gfx::GLSurface::InitializeOneOff()) {
20 LOG(ERROR) << "Failed to initialize GL";
21 return 1;
22 }
23
24 gfx::AcceleratedWidget widget =
25 ui::SurfaceFactoryOzone::GetInstance()->GetAcceleratedWidget();
26 scoped_refptr<gfx::GLSurface> surface =
27 gfx::GLSurface::CreateViewGLSurface(widget);
spang 2014/07/03 18:33:23 this can fail.
dnicoara 2014/07/03 18:51:36 Done.
28 scoped_refptr<gfx::GLContext> context = gfx::GLContext::CreateGLContext(
29 NULL, surface.get(), gfx::PreferIntegratedGpu);
spang 2014/07/03 18:33:23 also can fail.
dnicoara 2014/07/03 18:51:36 Done.
30
31 const gfx::Size window_size(800, 600);
32 int iterations = 120;
33
34 surface->Resize(window_size);
35 context->MakeCurrent(surface.get());
spang 2014/07/03 18:33:23 can fail.
dnicoara 2014/07/03 18:51:36 Done.
36
37 for (int i = 0; i < iterations; ++i) {
38 glViewport(0, 0, window_size.width(), window_size.height());
39 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
40 float fraction = static_cast<float>(i) / iterations;
41 glClearColor(1 - fraction, fraction, 0.0, 1.0);
42
43 if (!surface->SwapBuffers()) {
44 LOG(ERROR) << "Failed to swap buffers";
spang 2014/07/03 18:33:23 maybe just LOG(FATAL) ?
dnicoara 2014/07/03 18:51:36 Done.
45 return 1;
46 }
47 }
48
49 return 0;
50 }
OLDNEW
« no previous file with comments | « ui/ozone/demo/DEPS ('k') | ui/ozone/demo/ozone_demos.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698