| 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   scoped_refptr<gfx::GLSurface> surface( | 21   scoped_refptr<gfx::GLSurface> surface( | 
| 31       gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1))); | 22       gfx::GLSurface::CreateOffscreenGLSurface(gfx::Size(1, 1))); | 
| 32   if (!surface.get()) { | 23   if (!surface.get()) { | 
| 33     LOG(ERROR) << "CreateOffscreenGLSurface failed.\n"; | 24     LOG(ERROR) << "CreateOffscreenGLSurface failed.\n"; | 
| 34     Destroy(); | 25     Destroy(); | 
| 35     return false; | 26     return false; | 
| 36   } | 27   } | 
| 37 | 28 | 
| 38   // Create a GLContext and attach the surface. | 29   // Create a GLContext and attach the surface. | 
| 39   scoped_refptr<gfx::GLContext> context( | 30   scoped_refptr<gfx::GLContext> context( | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 62       Destroy(); | 53       Destroy(); | 
| 63       return false; | 54       return false; | 
| 64     } | 55     } | 
| 65   } | 56   } | 
| 66 | 57 | 
| 67   return InitializeCommon(surface, | 58   return InitializeCommon(surface, | 
| 68                           context, | 59                           context, | 
| 69                           size, | 60                           size, | 
| 70                           disallowed_extensions, | 61                           disallowed_extensions, | 
| 71                           allowed_extensions, | 62                           allowed_extensions, | 
| 72                           attribs, | 63                           attribs); | 
| 73                           parent_decoder, |  | 
| 74                           parent_texture_id); |  | 
| 75 } | 64 } | 
| 76 | 65 | 
| 77 void GpuScheduler::Destroy() { | 66 void GpuScheduler::Destroy() { | 
| 78   if (surface_.get()) { | 67   if (surface_.get()) { | 
| 79     surface_->Destroy(); | 68     surface_->Destroy(); | 
| 80     surface_.reset(); | 69     surface_.reset(); | 
| 81   } | 70   } | 
| 82 | 71 | 
| 83   DestroyCommon(); | 72   DestroyCommon(); | 
| 84 } | 73 } | 
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 149   if (surface_.get()) { | 138   if (surface_.get()) { | 
| 150     surface_->SwapBuffers(); | 139     surface_->SwapBuffers(); | 
| 151   } | 140   } | 
| 152 | 141 | 
| 153   if (wrapped_swap_buffers_callback_.get()) { | 142   if (wrapped_swap_buffers_callback_.get()) { | 
| 154     wrapped_swap_buffers_callback_->Run(); | 143     wrapped_swap_buffers_callback_->Run(); | 
| 155   } | 144   } | 
| 156 } | 145 } | 
| 157 | 146 | 
| 158 }  // namespace gpu | 147 }  // namespace gpu | 
| OLD | NEW | 
|---|