Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(706)

Side by Side Diff: content/renderer/pepper/pepper_video_encoder_host.cc

Issue 1864723003: Make lost context and error message callbacks on GpuControl go to client (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: errorcallback: gputestexpect Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/pepper_video_encoder_host.h" 5 #include "content/renderer/pepper/pepper_video_encoder_host.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 OnHostMsgRecycleBitstreamBuffer) 225 OnHostMsgRecycleBitstreamBuffer)
226 PPAPI_DISPATCH_HOST_RESOURCE_CALL( 226 PPAPI_DISPATCH_HOST_RESOURCE_CALL(
227 PpapiHostMsg_VideoEncoder_RequestEncodingParametersChange, 227 PpapiHostMsg_VideoEncoder_RequestEncodingParametersChange,
228 OnHostMsgRequestEncodingParametersChange) 228 OnHostMsgRequestEncodingParametersChange)
229 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoEncoder_Close, 229 PPAPI_DISPATCH_HOST_RESOURCE_CALL_0(PpapiHostMsg_VideoEncoder_Close,
230 OnHostMsgClose) 230 OnHostMsgClose)
231 PPAPI_END_MESSAGE_MAP() 231 PPAPI_END_MESSAGE_MAP()
232 return PP_ERROR_FAILED; 232 return PP_ERROR_FAILED;
233 } 233 }
234 234
235 void PepperVideoEncoderHost::OnGpuControlLostContext() {
236 #if DCHECK_IS_ON()
237 // This should never occur more than once.
238 DCHECK(!lost_context_);
239 lost_context_ = true;
240 #endif
241 NotifyPepperError(PP_ERROR_RESOURCE_FAILED);
242 }
243
235 int32_t PepperVideoEncoderHost::OnHostMsgGetSupportedProfiles( 244 int32_t PepperVideoEncoderHost::OnHostMsgGetSupportedProfiles(
236 ppapi::host::HostMessageContext* context) { 245 ppapi::host::HostMessageContext* context) {
237 std::vector<PP_VideoProfileDescription> pp_profiles; 246 std::vector<PP_VideoProfileDescription> pp_profiles;
238 GetSupportedProfiles(&pp_profiles); 247 GetSupportedProfiles(&pp_profiles);
239 248
240 host()->SendReply( 249 host()->SendReply(
241 context->MakeReplyMessageContext(), 250 context->MakeReplyMessageContext(),
242 PpapiPluginMsg_VideoEncoder_GetSupportedProfilesReply(pp_profiles)); 251 PpapiPluginMsg_VideoEncoder_GetSupportedProfilesReply(pp_profiles));
243 252
244 return PP_OK_COMPLETIONPENDING; 253 return PP_OK_COMPLETIONPENDING;
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 command_buffer_ = channel_->CreateCommandBuffer( 521 command_buffer_ = channel_->CreateCommandBuffer(
513 gpu::kNullSurfaceHandle, gfx::Size(), nullptr, 522 gpu::kNullSurfaceHandle, gfx::Size(), nullptr,
514 gpu::GpuChannelHost::kDefaultStreamId, 523 gpu::GpuChannelHost::kDefaultStreamId,
515 gpu::GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(), 524 gpu::GpuChannelHost::kDefaultStreamPriority, attribs, GURL::EmptyGURL(),
516 gfx::PreferIntegratedGpu); 525 gfx::PreferIntegratedGpu);
517 if (!command_buffer_) { 526 if (!command_buffer_) {
518 Close(); 527 Close();
519 return false; 528 return false;
520 } 529 }
521 530
522 command_buffer_->SetContextLostCallback(media::BindToCurrentLoop( 531 command_buffer_->SetGpuControlClient(this);
523 base::Bind(&PepperVideoEncoderHost::NotifyPepperError, 532
524 weak_ptr_factory_.GetWeakPtr(), PP_ERROR_RESOURCE_FAILED)));
525 if (!command_buffer_->Initialize()) { 533 if (!command_buffer_->Initialize()) {
526 Close(); 534 Close();
527 return false; 535 return false;
528 } 536 }
529 537
530 return true; 538 return true;
531 } 539 }
532 540
533 bool PepperVideoEncoderHost::InitializeHardware( 541 bool PepperVideoEncoderHost::InitializeHardware(
534 media::VideoPixelFormat input_format, 542 media::VideoPixelFormat input_format,
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 } 674 }
667 675
668 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32_t buffer_id) { 676 uint8_t* PepperVideoEncoderHost::ShmHandleToAddress(int32_t buffer_id) {
669 DCHECK(RenderThreadImpl::current()); 677 DCHECK(RenderThreadImpl::current());
670 DCHECK_GE(buffer_id, 0); 678 DCHECK_GE(buffer_id, 0);
671 DCHECK_LT(buffer_id, static_cast<int32_t>(shm_buffers_.size())); 679 DCHECK_LT(buffer_id, static_cast<int32_t>(shm_buffers_.size()));
672 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory()); 680 return static_cast<uint8_t*>(shm_buffers_[buffer_id]->shm->memory());
673 } 681 }
674 682
675 } // namespace content 683 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698