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

Side by Side Diff: cc/paint/paint_op_buffer_unittest.cc

Issue 2893083002: cc: Move SkShader construction to a single spot in PaintShader (Closed)
Patch Set: update 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
« no previous file with comments | « cc/paint/paint_op_buffer.h ('k') | cc/paint/paint_shader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 "cc/paint/paint_op_buffer.h" 5 #include "cc/paint/paint_op_buffer.h"
6 #include "base/memory/ptr_util.h"
6 #include "cc/paint/display_item_list.h" 7 #include "cc/paint/display_item_list.h"
7 #include "cc/test/skia_common.h" 8 #include "cc/test/skia_common.h"
8 #include "cc/test/test_skcanvas.h" 9 #include "cc/test/test_skcanvas.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/skia/include/effects/SkDashPathEffect.h" 11 #include "third_party/skia/include/effects/SkDashPathEffect.h"
11 12
12 using testing::_; 13 using testing::_;
13 using testing::Property; 14 using testing::Property;
14 using testing::Mock; 15 using testing::Mock;
15 16
(...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after
440 list->Finalize(); 441 list->Finalize();
441 PaintOpBuffer new_buffer; 442 PaintOpBuffer new_buffer;
442 new_buffer.push<DrawDisplayItemListOp>(list); 443 new_buffer.push<DrawDisplayItemListOp>(list);
443 EXPECT_TRUE(new_buffer.HasDiscardableImages()); 444 EXPECT_TRUE(new_buffer.HasDiscardableImages());
444 } 445 }
445 446
446 TEST(PaintOpBufferTest, DiscardableImagesTracking_OpWithFlags) { 447 TEST(PaintOpBufferTest, DiscardableImagesTracking_OpWithFlags) {
447 PaintOpBuffer buffer; 448 PaintOpBuffer buffer;
448 PaintFlags flags; 449 PaintFlags flags;
449 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(100, 100)); 450 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(100, 100));
450 flags.setShader( 451 flags.setShader(PaintShader::MakeImage(std::move(image),
451 image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode)); 452 SkShader::kClamp_TileMode,
453 SkShader::kClamp_TileMode, nullptr));
452 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags); 454 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags);
453 EXPECT_TRUE(buffer.HasDiscardableImages()); 455 EXPECT_TRUE(buffer.HasDiscardableImages());
454 } 456 }
455 457
456 TEST(PaintOpBufferTest, SlowPaths) { 458 TEST(PaintOpBufferTest, SlowPaths) {
457 auto buffer = sk_make_sp<PaintOpBuffer>(); 459 auto buffer = sk_make_sp<PaintOpBuffer>();
458 EXPECT_EQ(buffer->numSlowPaths(), 0); 460 EXPECT_EQ(buffer->numSlowPaths(), 0);
459 461
460 // Op without slow paths 462 // Op without slow paths
461 PaintFlags noop_flags; 463 PaintFlags noop_flags;
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
981 EXPECT_CALL(canvas, OnSaveLayer()).InSequence(s); 983 EXPECT_CALL(canvas, OnSaveLayer()).InSequence(s);
982 EXPECT_CALL(canvas, OnDrawRectWithColor(1u)).InSequence(s); 984 EXPECT_CALL(canvas, OnDrawRectWithColor(1u)).InSequence(s);
983 EXPECT_CALL(canvas, OnDrawRectWithColor(2u)).InSequence(s); 985 EXPECT_CALL(canvas, OnDrawRectWithColor(2u)).InSequence(s);
984 EXPECT_CALL(canvas, willRestore()).InSequence(s); 986 EXPECT_CALL(canvas, willRestore()).InSequence(s);
985 // We will restore back to the original save count regardless with 2 restores. 987 // We will restore back to the original save count regardless with 2 restores.
986 EXPECT_CALL(canvas, willRestore()).InSequence(s); 988 EXPECT_CALL(canvas, willRestore()).InSequence(s);
987 buffer.PlaybackRanges({0}, {0}, &canvas); 989 buffer.PlaybackRanges({0}, {0}, &canvas);
988 } 990 }
989 991
990 } // namespace cc 992 } // namespace cc
OLDNEW
« no previous file with comments | « cc/paint/paint_op_buffer.h ('k') | cc/paint/paint_shader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698