| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/renderer/pepper/ppb_graphics_3d_impl.h" | 5 #include "content/renderer/pepper/ppb_graphics_3d_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 | 161 |
| 162 gpu::CommandBuffer* PPB_Graphics3D_Impl::GetCommandBuffer() { | 162 gpu::CommandBuffer* PPB_Graphics3D_Impl::GetCommandBuffer() { |
| 163 return command_buffer_.get(); | 163 return command_buffer_.get(); |
| 164 } | 164 } |
| 165 | 165 |
| 166 gpu::GpuControl* PPB_Graphics3D_Impl::GetGpuControl() { | 166 gpu::GpuControl* PPB_Graphics3D_Impl::GetGpuControl() { |
| 167 return command_buffer_.get(); | 167 return command_buffer_.get(); |
| 168 } | 168 } |
| 169 | 169 |
| 170 int32_t PPB_Graphics3D_Impl::DoSwapBuffers(const gpu::SyncToken& sync_token, | 170 int32_t PPB_Graphics3D_Impl::DoSwapBuffers(const gpu::SyncToken& sync_token, |
| 171 int32_t width, | 171 const gfx::Size& size) { |
| 172 int32_t height) { | |
| 173 DCHECK(command_buffer_); | 172 DCHECK(command_buffer_); |
| 174 if (taken_front_buffer_.IsZero()) { | 173 if (taken_front_buffer_.IsZero()) { |
| 175 DLOG(ERROR) << "TakeFrontBuffer should be called before DoSwapBuffers"; | 174 DLOG(ERROR) << "TakeFrontBuffer should be called before DoSwapBuffers"; |
| 176 return PP_ERROR_FAILED; | 175 return PP_ERROR_FAILED; |
| 177 } | 176 } |
| 178 | 177 |
| 179 if (bound_to_instance_) { | 178 if (bound_to_instance_) { |
| 180 // If we are bound to the instance, we need to ask the compositor | 179 // If we are bound to the instance, we need to ask the compositor |
| 181 // to commit our backing texture so that the graphics appears on the page. | 180 // to commit our backing texture so that the graphics appears on the page. |
| 182 // When the backing texture will be committed we get notified via | 181 // When the backing texture will be committed we get notified via |
| 183 // ViewFlushedPaint(). | 182 // ViewFlushedPaint(). |
| 184 // | 183 // |
| 185 // Don't need to check for NULL from GetPluginInstance since when we're | 184 // Don't need to check for NULL from GetPluginInstance since when we're |
| 186 // bound, we know our instance is valid. | 185 // bound, we know our instance is valid. |
| 187 if (width < 0 || height < 0) { | |
| 188 width = original_width_; | |
| 189 height = original_height_; | |
| 190 } | |
| 191 bool is_overlay_candidate = use_image_chromium_; | 186 bool is_overlay_candidate = use_image_chromium_; |
| 192 GLenum target = | 187 GLenum target = |
| 193 is_overlay_candidate ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D; | 188 is_overlay_candidate ? GL_TEXTURE_RECTANGLE_ARB : GL_TEXTURE_2D; |
| 194 cc::TextureMailbox texture_mailbox(taken_front_buffer_, sync_token, target, | 189 cc::TextureMailbox texture_mailbox(taken_front_buffer_, sync_token, target, |
| 195 gfx::Size(width, height), | 190 size, is_overlay_candidate, false); |
| 196 is_overlay_candidate, false); | |
| 197 taken_front_buffer_.SetZero(); | 191 taken_front_buffer_.SetZero(); |
| 198 HostGlobals::Get() | 192 HostGlobals::Get() |
| 199 ->GetInstance(pp_instance()) | 193 ->GetInstance(pp_instance()) |
| 200 ->CommitTextureMailbox(texture_mailbox); | 194 ->CommitTextureMailbox(texture_mailbox); |
| 201 commit_pending_ = true; | 195 commit_pending_ = true; |
| 202 } else { | 196 } else { |
| 203 // Wait for the command to complete on the GPU to allow for throttling. | 197 // Wait for the command to complete on the GPU to allow for throttling. |
| 204 command_buffer_->SignalSyncToken( | 198 command_buffer_->SignalSyncToken( |
| 205 sync_token, base::Bind(&PPB_Graphics3D_Impl::OnSwapBuffers, | 199 sync_token, base::Bind(&PPB_Graphics3D_Impl::OnSwapBuffers, |
| 206 weak_ptr_factory_.GetWeakPtr())); | 200 weak_ptr_factory_.GetWeakPtr())); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 if (share_context) { | 248 if (share_context) { |
| 255 PPB_Graphics3D_Impl* share_graphics = | 249 PPB_Graphics3D_Impl* share_graphics = |
| 256 static_cast<PPB_Graphics3D_Impl*>(share_context); | 250 static_cast<PPB_Graphics3D_Impl*>(share_context); |
| 257 share_buffer = share_graphics->GetCommandBufferProxy(); | 251 share_buffer = share_graphics->GetCommandBufferProxy(); |
| 258 } | 252 } |
| 259 | 253 |
| 260 command_buffer_ = gpu::CommandBufferProxyImpl::Create( | 254 command_buffer_ = gpu::CommandBufferProxyImpl::Create( |
| 261 std::move(channel), gpu::kNullSurfaceHandle, share_buffer, | 255 std::move(channel), gpu::kNullSurfaceHandle, share_buffer, |
| 262 gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL, attrib_helper, | 256 gpu::GPU_STREAM_DEFAULT, gpu::GpuStreamPriority::NORMAL, attrib_helper, |
| 263 GURL::EmptyGURL(), base::ThreadTaskRunnerHandle::Get()); | 257 GURL::EmptyGURL(), base::ThreadTaskRunnerHandle::Get()); |
| 264 original_width_ = attrib_helper.offscreen_framebuffer_size.width(); | |
| 265 original_height_ = attrib_helper.offscreen_framebuffer_size.height(); | |
| 266 if (!command_buffer_) | 258 if (!command_buffer_) |
| 267 return false; | 259 return false; |
| 268 | 260 |
| 269 command_buffer_->SetGpuControlClient(this); | 261 command_buffer_->SetGpuControlClient(this); |
| 270 | 262 |
| 271 if (shared_state_handle) | 263 if (shared_state_handle) |
| 272 *shared_state_handle = command_buffer_->GetSharedStateHandle(); | 264 *shared_state_handle = command_buffer_->GetSharedStateHandle(); |
| 273 if (capabilities) | 265 if (capabilities) |
| 274 *capabilities = command_buffer_->GetCapabilities(); | 266 *capabilities = command_buffer_->GetCapabilities(); |
| 275 if (command_buffer_id) | 267 if (command_buffer_id) |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 if (!mailboxes_to_reuse_.empty()) { | 348 if (!mailboxes_to_reuse_.empty()) { |
| 357 gpu::Mailbox mailbox = mailboxes_to_reuse_.back(); | 349 gpu::Mailbox mailbox = mailboxes_to_reuse_.back(); |
| 358 mailboxes_to_reuse_.pop_back(); | 350 mailboxes_to_reuse_.pop_back(); |
| 359 return mailbox; | 351 return mailbox; |
| 360 } | 352 } |
| 361 | 353 |
| 362 return gpu::Mailbox::Generate(); | 354 return gpu::Mailbox::Generate(); |
| 363 } | 355 } |
| 364 | 356 |
| 365 } // namespace content | 357 } // namespace content |
| OLD | NEW |