OLD | NEW |
| (Empty) |
1 // Copyright 2015 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 "sky/shell/gpu_driver.h" | |
6 | |
7 #include "ui/gl/gl_bindings.h" | |
8 #include "ui/gl/gl_context.h" | |
9 #include "ui/gl/gl_share_group.h" | |
10 #include "ui/gl/gl_surface.h" | |
11 | |
12 namespace sky { | |
13 namespace shell { | |
14 | |
15 GPUDriver::GPUDriver() : weak_factory_(this) { | |
16 } | |
17 | |
18 GPUDriver::~GPUDriver() { | |
19 } | |
20 | |
21 base::WeakPtr<GPUDriver> GPUDriver::GetWeakPtr() { | |
22 return weak_factory_.GetWeakPtr(); | |
23 } | |
24 | |
25 void GPUDriver::Init(gfx::AcceleratedWidget widget) { | |
26 share_group_ = make_scoped_refptr(new gfx::GLShareGroup()); | |
27 | |
28 surface_ = gfx::GLSurface::CreateViewGLSurface(widget); | |
29 CHECK(surface_) << "GLSurface required."; | |
30 | |
31 context_ = gfx::GLContext::CreateGLContext(share_group_.get(), surface_.get(), | |
32 gfx::PreferIntegratedGpu); | |
33 CHECK(context_) << "GLContext required."; | |
34 | |
35 CHECK(context_->MakeCurrent(surface_.get())); | |
36 | |
37 glClearColor(0.0, 1.0, 0.0, 0.0); | |
38 glClear(GL_COLOR_BUFFER_BIT); | |
39 | |
40 surface_->SwapBuffers(); | |
41 } | |
42 | |
43 } // namespace shell | |
44 } // namespace sky | |
OLD | NEW |