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