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

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

Issue 2903053002: Removing canvas rendering mode switching feature (Closed)
Patch Set: fix test failure Created 3 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/RecordingImageBufferSurface.h" 5 #include "platform/graphics/RecordingImageBufferSurface.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "platform/Histogram.h" 9 #include "platform/Histogram.h"
10 #include "platform/graphics/CanvasHeuristicParameters.h"
10 #include "platform/graphics/CanvasMetrics.h" 11 #include "platform/graphics/CanvasMetrics.h"
11 #include "platform/graphics/ExpensiveCanvasHeuristicParameters.h"
12 #include "platform/graphics/GraphicsContext.h" 12 #include "platform/graphics/GraphicsContext.h"
13 #include "platform/graphics/ImageBuffer.h" 13 #include "platform/graphics/ImageBuffer.h"
14 #include "platform/graphics/UnacceleratedImageBufferSurface.h" 14 #include "platform/graphics/UnacceleratedImageBufferSurface.h"
15 #include "platform/graphics/paint/PaintRecorder.h" 15 #include "platform/graphics/paint/PaintRecorder.h"
16 #include "platform/wtf/PassRefPtr.h" 16 #include "platform/wtf/PassRefPtr.h"
17 #include "platform/wtf/PtrUtil.h" 17 #include "platform/wtf/PtrUtil.h"
18 18
19 namespace blink { 19 namespace blink {
20 20
21 RecordingImageBufferSurface::RecordingImageBufferSurface( 21 RecordingImageBufferSurface::RecordingImageBufferSurface(
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 return true; 324 return true;
325 } 325 }
326 326
327 if (!frame_was_cleared_) { 327 if (!frame_was_cleared_) {
328 *fallback_reason = kFallbackReasonCanvasNotClearedBetweenFrames; 328 *fallback_reason = kFallbackReasonCanvasNotClearedBetweenFrames;
329 return false; 329 return false;
330 } 330 }
331 331
332 if (allow_fallback_ == kAllowFallback && 332 if (allow_fallback_ == kAllowFallback &&
333 current_frame_->getRecordingCanvas()->getSaveCount() - 1 > 333 current_frame_->getRecordingCanvas()->getSaveCount() - 1 >
334 ExpensiveCanvasHeuristicParameters::kExpensiveRecordingStackDepth) { 334 CanvasHeuristicParameters::kExpensiveRecordingStackDepth) {
335 // (getSaveCount() decremented to account for the intial recording canvas 335 // (getSaveCount() decremented to account for the intial recording canvas
336 // save frame.) 336 // save frame.)
337 *fallback_reason = kFallbackReasonRunawayStateStack; 337 *fallback_reason = kFallbackReasonRunawayStateStack;
338 return false; 338 return false;
339 } 339 }
340 340
341 previous_frame_ = current_frame_->finishRecordingAsPicture(); 341 previous_frame_ = current_frame_->finishRecordingAsPicture();
342 previous_frame_has_expensive_op_ = current_frame_has_expensive_op_; 342 previous_frame_has_expensive_op_ = current_frame_has_expensive_op_;
343 previous_frame_pixel_count_ = current_frame_pixel_count_; 343 previous_frame_pixel_count_ = current_frame_pixel_count_;
344 InitializeCurrentFrame(); 344 InitializeCurrentFrame();
(...skipping 22 matching lines...) Expand all
367 bool RecordingImageBufferSurface::IsExpensiveToPaint() { 367 bool RecordingImageBufferSurface::IsExpensiveToPaint() {
368 if (fallback_surface_) 368 if (fallback_surface_)
369 return fallback_surface_->IsExpensiveToPaint(); 369 return fallback_surface_->IsExpensiveToPaint();
370 370
371 if (did_record_draw_commands_in_current_frame_) { 371 if (did_record_draw_commands_in_current_frame_) {
372 if (current_frame_has_expensive_op_) 372 if (current_frame_has_expensive_op_)
373 return true; 373 return true;
374 374
375 if (current_frame_pixel_count_ >= 375 if (current_frame_pixel_count_ >=
376 (size().Width() * size().Height() * 376 (size().Width() * size().Height() *
377 ExpensiveCanvasHeuristicParameters::kExpensiveOverdrawThreshold)) 377 CanvasHeuristicParameters::kExpensiveOverdrawThreshold))
378 return true; 378 return true;
379 379
380 if (frame_was_cleared_) 380 if (frame_was_cleared_)
381 return false; // early exit because previous frame is overdrawn 381 return false; // early exit because previous frame is overdrawn
382 } 382 }
383 383
384 if (previous_frame_) { 384 if (previous_frame_) {
385 if (previous_frame_has_expensive_op_) 385 if (previous_frame_has_expensive_op_)
386 return true; 386 return true;
387 387
388 if (previous_frame_pixel_count_ >= 388 if (previous_frame_pixel_count_ >=
389 (size().Width() * size().Height() * 389 (size().Width() * size().Height() *
390 ExpensiveCanvasHeuristicParameters::kExpensiveOverdrawThreshold)) 390 CanvasHeuristicParameters::kExpensiveOverdrawThreshold))
391 return true; 391 return true;
392 } 392 }
393 393
394 return false; 394 return false;
395 } 395 }
396 396
397 // Fallback passthroughs 397 // Fallback passthroughs
398 398
399 bool RecordingImageBufferSurface::Restore() { 399 bool RecordingImageBufferSurface::Restore() {
400 if (fallback_surface_) 400 if (fallback_surface_)
(...skipping 14 matching lines...) Expand all
415 } 415 }
416 416
417 void RecordingImageBufferSurface::SetIsHidden(bool hidden) { 417 void RecordingImageBufferSurface::SetIsHidden(bool hidden) {
418 if (fallback_surface_) 418 if (fallback_surface_)
419 fallback_surface_->SetIsHidden(hidden); 419 fallback_surface_->SetIsHidden(hidden);
420 else 420 else
421 ImageBufferSurface::SetIsHidden(hidden); 421 ImageBufferSurface::SetIsHidden(hidden);
422 } 422 }
423 423
424 } // namespace blink 424 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/graphics/ImageBuffer.cpp ('k') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698