OLD | NEW |
(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(FATAL) << "Failed to initialize GL"; |
| 21 |
| 22 gfx::AcceleratedWidget widget = |
| 23 ui::SurfaceFactoryOzone::GetInstance()->GetAcceleratedWidget(); |
| 24 scoped_refptr<gfx::GLSurface> surface = |
| 25 gfx::GLSurface::CreateViewGLSurface(widget); |
| 26 if (!surface) |
| 27 LOG(FATAL) << "Failed to create GL surface"; |
| 28 |
| 29 scoped_refptr<gfx::GLContext> context = gfx::GLContext::CreateGLContext( |
| 30 NULL, surface.get(), gfx::PreferIntegratedGpu); |
| 31 if (!context) |
| 32 LOG(FATAL) << "Failed to create GL context"; |
| 33 |
| 34 const gfx::Size window_size(800, 600); |
| 35 int iterations = 120; |
| 36 |
| 37 surface->Resize(window_size); |
| 38 if (!context->MakeCurrent(surface.get())) |
| 39 LOG(FATAL) << "Failed to make current on GL context"; |
| 40 |
| 41 for (int i = 0; i < iterations; ++i) { |
| 42 glViewport(0, 0, window_size.width(), window_size.height()); |
| 43 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
| 44 float fraction = static_cast<float>(i) / iterations; |
| 45 glClearColor(1 - fraction, fraction, 0.0, 1.0); |
| 46 |
| 47 if (!surface->SwapBuffers()) |
| 48 LOG(FATAL) << "Failed to swap buffers"; |
| 49 } |
| 50 |
| 51 return 0; |
| 52 } |
OLD | NEW |