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

Side by Side Diff: third_party/WebKit/Source/modules/canvas2d/CanvasRenderingContext2DUsageTrackingTest.cpp

Issue 2699713005: Fix missing finalizeFrame barriers in WebGL animations (Closed)
Patch Set: Comments + readability improvements Created 3 years, 10 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 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 "modules/canvas2d/CanvasRenderingContext2D.h" 5 #include "modules/canvas2d/CanvasRenderingContext2D.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/frame/FrameView.h" 8 #include "core/frame/FrameView.h"
9 #include "core/frame/Settings.h" 9 #include "core/frame/Settings.h"
10 #include "core/html/HTMLCanvasElement.h" 10 #include "core/html/HTMLCanvasElement.h"
(...skipping 619 matching lines...) Expand 10 before | Expand all | Expand 10 after
630 0.1); 630 0.1);
631 EXPECT_NEAR( 631 EXPECT_NEAR(
632 perimeterTimesShadowBlurSquared, 632 perimeterTimesShadowBlurSquared,
633 context2d()->getUsage().boundingBoxPerimeterTimesShadowBlurSquared, 0.1); 633 context2d()->getUsage().boundingBoxPerimeterTimesShadowBlurSquared, 0.1);
634 } 634 }
635 635
636 TEST_F(CanvasRenderingContextUsageTrackingTest, incrementFrameCount) { 636 TEST_F(CanvasRenderingContextUsageTrackingTest, incrementFrameCount) {
637 createContext(NonOpaque); 637 createContext(NonOpaque);
638 EXPECT_EQ(0, context2d()->getUsage().numFramesSinceReset); 638 EXPECT_EQ(0, context2d()->getUsage().numFramesSinceReset);
639 639
640 context2d()->incrementFrameCount(); 640 context2d()->finalizeFrame();
641 EXPECT_EQ(1, context2d()->getUsage().numFramesSinceReset); 641 EXPECT_EQ(1, context2d()->getUsage().numFramesSinceReset);
642 642
643 context2d()->incrementFrameCount(); 643 context2d()->finalizeFrame();
644 context2d()->incrementFrameCount(); 644 context2d()->finalizeFrame();
645 EXPECT_EQ(3, context2d()->getUsage().numFramesSinceReset); 645 EXPECT_EQ(3, context2d()->getUsage().numFramesSinceReset);
646 } 646 }
647 647
648 TEST_F(CanvasRenderingContextUsageTrackingTest, resetUsageTracking) { 648 TEST_F(CanvasRenderingContextUsageTrackingTest, resetUsageTracking) {
649 createContext(NonOpaque); 649 createContext(NonOpaque);
650 EXPECT_EQ(0, context2d()->getUsage().numFramesSinceReset); 650 EXPECT_EQ(0, context2d()->getUsage().numFramesSinceReset);
651 651
652 context2d()->incrementFrameCount(); 652 context2d()->finalizeFrame();
653 context2d()->incrementFrameCount(); 653 context2d()->finalizeFrame();
654 EXPECT_EQ(2, context2d()->getUsage().numFramesSinceReset); 654 EXPECT_EQ(2, context2d()->getUsage().numFramesSinceReset);
655 655
656 const int numReps = 100; 656 const int numReps = 100;
657 for (int i = 0; i < numReps; i++) { 657 for (int i = 0; i < numReps; i++) {
658 context2d()->fillRect(10, 10, 100, 100); 658 context2d()->fillRect(10, 10, 100, 100);
659 } 659 }
660 EXPECT_EQ( 660 EXPECT_EQ(
661 numReps, 661 numReps,
662 context2d()->getUsage().numDrawCalls[BaseRenderingContext2D::FillRect]); 662 context2d()->getUsage().numDrawCalls[BaseRenderingContext2D::FillRect]);
663 663
664 context2d()->resetUsageTracking(); 664 context2d()->resetUsageTracking();
665 EXPECT_EQ(0, context2d()->getUsage().numFramesSinceReset); 665 EXPECT_EQ(0, context2d()->getUsage().numFramesSinceReset);
666 EXPECT_EQ( 666 EXPECT_EQ(
667 0, 667 0,
668 context2d()->getUsage().numDrawCalls[BaseRenderingContext2D::FillRect]); 668 context2d()->getUsage().numDrawCalls[BaseRenderingContext2D::FillRect]);
669 669
670 for (int i = 0; i < numReps; i++) { 670 for (int i = 0; i < numReps; i++) {
671 context2d()->fillRect(10, 10, 100, 100); 671 context2d()->fillRect(10, 10, 100, 100);
672 } 672 }
673 EXPECT_EQ( 673 EXPECT_EQ(
674 numReps, 674 numReps,
675 context2d()->getUsage().numDrawCalls[BaseRenderingContext2D::FillRect]); 675 context2d()->getUsage().numDrawCalls[BaseRenderingContext2D::FillRect]);
676 } 676 }
677 677
678 } // namespace UsageTrackingTests 678 } // namespace UsageTrackingTests
679 } // namespace blink 679 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698