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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.cpp

Issue 2817603004: Throttle frames in OffscreenCanvasFrameDispatcherImpl (Closed)
Patch Set: move comment to right position Created 3 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
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h" 5 #include "platform/graphics/OffscreenCanvasFrameDispatcherImpl.h"
6 6
7 #include "cc/output/compositor_frame.h" 7 #include "cc/output/compositor_frame.h"
8 #include "cc/quads/texture_draw_quad.h" 8 #include "cc/quads/texture_draw_quad.h"
9 #include "gpu/command_buffer/client/gles2_interface.h" 9 #include "gpu/command_buffer/client/gles2_interface.h"
10 #include "platform/CrossThreadFunctional.h" 10 #include "platform/CrossThreadFunctional.h"
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 break; 392 break;
393 case kOffscreenCanvasCommitTypeCount: 393 case kOffscreenCanvasCommitTypeCount:
394 NOTREACHED(); 394 NOTREACHED();
395 } 395 }
396 396
397 if (change_size_for_next_commit_) { 397 if (change_size_for_next_commit_) {
398 current_local_surface_id_ = local_surface_id_allocator_.GenerateId(); 398 current_local_surface_id_ = local_surface_id_allocator_.GenerateId();
399 change_size_for_next_commit_ = false; 399 change_size_for_next_commit_ = false;
400 } 400 }
401 401
402 compositor_has_pending_frame_ = true;
402 sink_->SubmitCompositorFrame(current_local_surface_id_, std::move(frame)); 403 sink_->SubmitCompositorFrame(current_local_surface_id_, std::move(frame));
403 } 404 }
404 405
405 void OffscreenCanvasFrameDispatcherImpl::DidReceiveCompositorFrameAck( 406 void OffscreenCanvasFrameDispatcherImpl::DidReceiveCompositorFrameAck(
406 const cc::ReturnedResourceArray& resources) { 407 const cc::ReturnedResourceArray& resources) {
407 ReclaimResources(resources); 408 ReclaimResources(resources);
409 compositor_has_pending_frame_ = false;
408 // TODO(fsamuel): Implement this. 410 // TODO(fsamuel): Implement this.
Eric Seckler 2017/04/12 19:39:18 Is there more to do here? If so, let's update this
409 } 411 }
410 412
411 void OffscreenCanvasFrameDispatcherImpl::SetNeedsBeginFrame( 413 void OffscreenCanvasFrameDispatcherImpl::SetNeedsBeginFrame(
412 bool needs_begin_frame) { 414 bool needs_begin_frame) {
413 if (sink_ && needs_begin_frame != needs_begin_frame_) { 415 if (sink_ && needs_begin_frame != needs_begin_frame_) {
414 needs_begin_frame_ = needs_begin_frame; 416 needs_begin_frame_ = needs_begin_frame;
415 sink_->SetNeedsBeginFrame(needs_begin_frame); 417 sink_->SetNeedsBeginFrame(needs_begin_frame);
416 } 418 }
417 } 419 }
418 420
419 void OffscreenCanvasFrameDispatcherImpl::OnBeginFrame( 421 void OffscreenCanvasFrameDispatcherImpl::OnBeginFrame(
420 const cc::BeginFrameArgs& begin_frame_args) { 422 const cc::BeginFrameArgs& begin_frame_args) {
421 DCHECK(Client()); 423 DCHECK(Client());
424
422 // TODO(eseckler): Set correct |latest_confirmed_sequence_number|. 425 // TODO(eseckler): Set correct |latest_confirmed_sequence_number|.
423 current_begin_frame_ack_ = cc::BeginFrameAck( 426 current_begin_frame_ack_ = cc::BeginFrameAck(
424 begin_frame_args.source_id, begin_frame_args.sequence_number, 427 begin_frame_args.source_id, begin_frame_args.sequence_number,
425 begin_frame_args.sequence_number, false); 428 begin_frame_args.sequence_number, false);
429
430 if (compositor_has_pending_frame_ ||
431 (begin_frame_args.type == cc::BeginFrameArgs::MISSED &&
432 base::TimeTicks::Now() > begin_frame_args.deadline)) {
433 sink_->BeginFrameDidNotSwap(current_begin_frame_ack_);
434 return;
435 }
436
426 Client()->BeginFrame(); 437 Client()->BeginFrame();
427 // TODO(eseckler): Tell |m_sink| if we did not draw during the BeginFrame. 438 // TODO(eseckler): Tell |m_sink| if we did not draw during the BeginFrame.
428 current_begin_frame_ack_.sequence_number = 439 current_begin_frame_ack_.sequence_number =
429 cc::BeginFrameArgs::kInvalidFrameNumber; 440 cc::BeginFrameArgs::kInvalidFrameNumber;
430 } 441 }
431 442
432 void OffscreenCanvasFrameDispatcherImpl::ReclaimResources( 443 void OffscreenCanvasFrameDispatcherImpl::ReclaimResources(
433 const cc::ReturnedResourceArray& resources) { 444 const cc::ReturnedResourceArray& resources) {
434 for (const auto& resource : resources) { 445 for (const auto& resource : resources) {
435 RefPtr<StaticBitmapImage> image = cached_images_.at(resource.id); 446 RefPtr<StaticBitmapImage> image = cached_images_.at(resource.id);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 488
478 void OffscreenCanvasFrameDispatcherImpl::Reshape(int width, int height) { 489 void OffscreenCanvasFrameDispatcherImpl::Reshape(int width, int height) {
479 if (width_ != width || height_ != height) { 490 if (width_ != width || height_ != height) {
480 width_ = width; 491 width_ = width;
481 height_ = height; 492 height_ = height;
482 change_size_for_next_commit_ = true; 493 change_size_for_next_commit_ = true;
483 } 494 }
484 } 495 }
485 496
486 } // namespace blink 497 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/OffscreenCanvasFrameDispatcherImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698