OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "gpu/command_buffer/service/gpu_scheduler.h" | 5 #include "gpu/command_buffer/service/gpu_scheduler.h" |
6 #include "ui/gfx/gl/gl_context.h" | 6 #include "ui/gfx/gl/gl_context.h" |
7 #include "ui/gfx/gl/gl_share_group.h" | 7 #include "ui/gfx/gl/gl_share_group.h" |
8 #include "ui/gfx/gl/gl_surface.h" | 8 #include "ui/gfx/gl/gl_surface.h" |
9 | 9 |
10 using ::base::SharedMemory; | 10 using ::base::SharedMemory; |
11 | 11 |
12 namespace gpu { | 12 namespace gpu { |
13 | 13 |
14 bool GpuScheduler::Initialize( | 14 bool GpuScheduler::Initialize( |
15 gfx::PluginWindowHandle window, | 15 gfx::PluginWindowHandle window, |
16 const gfx::Size& size, | 16 const gfx::Size& size, |
17 const gles2::DisallowedExtensions& disallowed_extensions, | 17 const gles2::DisallowedExtensions& disallowed_extensions, |
18 const char* allowed_extensions, | 18 const char* allowed_extensions, |
19 const std::vector<int32>& attribs, | 19 const std::vector<int32>& attribs, |
20 GpuScheduler* parent, | |
21 uint32 parent_texture_id, | |
22 gfx::GLShareGroup* share_group) { | 20 gfx::GLShareGroup* share_group) { |
23 // Get the parent decoder. | |
24 gles2::GLES2Decoder* parent_decoder = NULL; | |
25 if (parent) { | |
26 parent_decoder = parent->decoder_.get(); | |
27 DCHECK(parent_decoder); | |
28 } | |
29 | |
30 // Create either a view or pbuffer based GLSurface. | 21 // Create either a view or pbuffer based GLSurface. |
31 scoped_refptr<gfx::GLSurface> surface; | 22 scoped_refptr<gfx::GLSurface> surface; |
32 if (window) | 23 if (window) |
33 surface = gfx::GLSurface::CreateViewGLSurface(window); | 24 surface = gfx::GLSurface::CreateViewGLSurface(window); |
34 else | 25 else |
35 surface = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); | 26 surface = gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1)); |
36 | 27 |
37 if (!surface.get()) { | 28 if (!surface.get()) { |
38 LOG(ERROR) << "GpuScheduler::Initialize failed.\n"; | 29 LOG(ERROR) << "GpuScheduler::Initialize failed.\n"; |
39 Destroy(); | 30 Destroy(); |
40 return false; | 31 return false; |
41 } | 32 } |
42 | 33 |
43 // Create a GLContext and attach the surface. | 34 // Create a GLContext and attach the surface. |
44 scoped_refptr<gfx::GLContext> context( | 35 scoped_refptr<gfx::GLContext> context( |
45 gfx::GLContext::CreateGLContext(share_group, surface.get())); | 36 gfx::GLContext::CreateGLContext(share_group, surface.get())); |
46 if (!context.get()) { | 37 if (!context.get()) { |
47 LOG(ERROR) << "CreateGLContext failed.\n"; | 38 LOG(ERROR) << "CreateGLContext failed.\n"; |
48 Destroy(); | 39 Destroy(); |
49 return false; | 40 return false; |
50 } | 41 } |
51 | 42 |
52 return InitializeCommon(surface, | 43 return InitializeCommon(surface, |
53 context, | 44 context, |
54 size, | 45 size, |
55 disallowed_extensions, | 46 disallowed_extensions, |
56 allowed_extensions, | 47 allowed_extensions, |
57 attribs, | 48 attribs); |
58 parent_decoder, | |
59 parent_texture_id); | |
60 } | 49 } |
61 | 50 |
62 void GpuScheduler::Destroy() { | 51 void GpuScheduler::Destroy() { |
63 DestroyCommon(); | 52 DestroyCommon(); |
64 } | 53 } |
65 | 54 |
66 void GpuScheduler::WillSwapBuffers() { | 55 void GpuScheduler::WillSwapBuffers() { |
67 if (wrapped_swap_buffers_callback_.get()) { | 56 if (wrapped_swap_buffers_callback_.get()) { |
68 wrapped_swap_buffers_callback_->Run(); | 57 wrapped_swap_buffers_callback_->Run(); |
69 } | 58 } |
70 } | 59 } |
71 | 60 |
72 } // namespace gpu | 61 } // namespace gpu |
OLD | NEW |