| 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 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 GpuScheduler::~GpuScheduler() { | 59 GpuScheduler::~GpuScheduler() { |
| 60 Destroy(); | 60 Destroy(); |
| 61 } | 61 } |
| 62 | 62 |
| 63 bool GpuScheduler::InitializeCommon( | 63 bool GpuScheduler::InitializeCommon( |
| 64 const scoped_refptr<gfx::GLSurface>& surface, | 64 const scoped_refptr<gfx::GLSurface>& surface, |
| 65 const scoped_refptr<gfx::GLContext>& context, | 65 const scoped_refptr<gfx::GLContext>& context, |
| 66 const gfx::Size& size, | 66 const gfx::Size& size, |
| 67 const gles2::DisallowedExtensions& disallowed_extensions, | 67 const gles2::DisallowedExtensions& disallowed_extensions, |
| 68 const char* allowed_extensions, | 68 const char* allowed_extensions, |
| 69 const std::vector<int32>& attribs, | 69 const std::vector<int32>& attribs) { |
| 70 gles2::GLES2Decoder* parent_decoder, | |
| 71 uint32 parent_texture_id) { | |
| 72 DCHECK(context); | 70 DCHECK(context); |
| 73 | 71 |
| 74 if (!context->MakeCurrent(surface)) | 72 if (!context->MakeCurrent(surface)) |
| 75 return false; | 73 return false; |
| 76 | 74 |
| 77 #if !defined(OS_MACOSX) | 75 #if !defined(OS_MACOSX) |
| 78 // Set up swap interval for onscreen contexts. | 76 // Set up swap interval for onscreen contexts. |
| 79 if (!surface->IsOffscreen()) { | 77 if (!surface->IsOffscreen()) { |
| 80 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync)) | 78 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableGpuVsync)) |
| 81 context->SetSwapInterval(0); | 79 context->SetSwapInterval(0); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 104 } | 102 } |
| 105 | 103 |
| 106 // Initialize the decoder with either the view or pbuffer GLContext. | 104 // Initialize the decoder with either the view or pbuffer GLContext. |
| 107 // TODO(apatrick): The GpuScheduler should know nothing about the surface the | 105 // TODO(apatrick): The GpuScheduler should know nothing about the surface the |
| 108 // decoder is rendering to. Get rid of the surface parameter. | 106 // decoder is rendering to. Get rid of the surface parameter. |
| 109 if (!decoder_->Initialize(surface, | 107 if (!decoder_->Initialize(surface, |
| 110 context, | 108 context, |
| 111 size, | 109 size, |
| 112 disallowed_extensions, | 110 disallowed_extensions, |
| 113 allowed_extensions, | 111 allowed_extensions, |
| 114 attribs, | 112 attribs)) { |
| 115 parent_decoder, | |
| 116 parent_texture_id)) { | |
| 117 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because decoder " | 113 LOG(ERROR) << "GpuScheduler::InitializeCommon failed because decoder " |
| 118 << "failed to initialize."; | 114 << "failed to initialize."; |
| 119 Destroy(); | 115 Destroy(); |
| 120 return false; | 116 return false; |
| 121 } | 117 } |
| 122 | 118 |
| 123 return true; | 119 return true; |
| 124 } | 120 } |
| 125 | 121 |
| 126 void GpuScheduler::DestroyCommon() { | 122 void GpuScheduler::DestroyCommon() { |
| 127 bool have_context = false; | 123 bool have_context = false; |
| 128 if (decoder_.get()) { | 124 if (decoder_.get()) { |
| 129 have_context = decoder_->MakeCurrent(); | 125 have_context = decoder_->MakeCurrent(); |
| 130 decoder_->Destroy(); | 126 decoder_->Destroy(); |
| 131 decoder_.reset(); | 127 decoder_.reset(); |
| 132 } | 128 } |
| 133 | 129 |
| 134 parser_.reset(); | 130 parser_.reset(); |
| 135 } | 131 } |
| 136 | 132 |
| 133 bool GpuScheduler::SetParent(GpuScheduler* parent_scheduler, |
| 134 uint32 parent_texture_id) { |
| 135 if (parent_scheduler) |
| 136 return decoder_->SetParent(parent_scheduler->decoder_.get(), |
| 137 parent_texture_id); |
| 138 else |
| 139 return decoder_->SetParent(NULL, 0); |
| 140 } |
| 141 |
| 137 #if defined(OS_MACOSX) | 142 #if defined(OS_MACOSX) |
| 138 namespace { | 143 namespace { |
| 139 const unsigned int kMaxOutstandingSwapBuffersCallsPerOnscreenContext = 1; | 144 const unsigned int kMaxOutstandingSwapBuffersCallsPerOnscreenContext = 1; |
| 140 } | 145 } |
| 141 #endif | 146 #endif |
| 142 | 147 |
| 143 void GpuScheduler::PutChanged(bool sync) { | 148 void GpuScheduler::PutChanged(bool sync) { |
| 144 TRACE_EVENT1("gpu", "GpuScheduler:PutChanged", "this", this); | 149 TRACE_EVENT1("gpu", "GpuScheduler:PutChanged", "this", this); |
| 145 CommandBuffer::State state = command_buffer_->GetState(); | 150 CommandBuffer::State state = command_buffer_->GetState(); |
| 146 parser_->set_put(state.put_offset); | 151 parser_->set_put(state.put_offset); |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 307 method_factory_.NewRunnableMethod(&GpuScheduler::ProcessCommands)); | 312 method_factory_.NewRunnableMethod(&GpuScheduler::ProcessCommands)); |
| 308 } | 313 } |
| 309 | 314 |
| 310 void GpuScheduler::WillResize(gfx::Size size) { | 315 void GpuScheduler::WillResize(gfx::Size size) { |
| 311 if (wrapped_resize_callback_.get()) { | 316 if (wrapped_resize_callback_.get()) { |
| 312 wrapped_resize_callback_->Run(size); | 317 wrapped_resize_callback_->Run(size); |
| 313 } | 318 } |
| 314 } | 319 } |
| 315 | 320 |
| 316 } // namespace gpu | 321 } // namespace gpu |
| OLD | NEW |