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

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
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 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 list->Finalize(); 438 list->Finalize();
438 PaintOpBuffer new_buffer; 439 PaintOpBuffer new_buffer;
439 new_buffer.push<DrawDisplayItemListOp>(list); 440 new_buffer.push<DrawDisplayItemListOp>(list);
440 EXPECT_TRUE(new_buffer.HasDiscardableImages()); 441 EXPECT_TRUE(new_buffer.HasDiscardableImages());
441 } 442 }
442 443
443 TEST(PaintOpBufferTest, DiscardableImagesTracking_OpWithFlags) { 444 TEST(PaintOpBufferTest, DiscardableImagesTracking_OpWithFlags) {
444 PaintOpBuffer buffer; 445 PaintOpBuffer buffer;
445 PaintFlags flags; 446 PaintFlags flags;
446 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(100, 100)); 447 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(100, 100));
447 flags.setShader( 448 flags.setShader(base::MakeUnique<PaintShader>(
448 image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode)); 449 image, SkShader::kClamp_TileMode, SkShader::kClamp_TileMode, nullptr));
449 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags); 450 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags);
450 EXPECT_TRUE(buffer.HasDiscardableImages()); 451 EXPECT_TRUE(buffer.HasDiscardableImages());
451 } 452 }
452 453
453 TEST(PaintOpBufferTest, SlowPaths) { 454 TEST(PaintOpBufferTest, SlowPaths) {
454 auto buffer = sk_make_sp<PaintOpBuffer>(); 455 auto buffer = sk_make_sp<PaintOpBuffer>();
455 EXPECT_EQ(buffer->numSlowPaths(), 0); 456 EXPECT_EQ(buffer->numSlowPaths(), 0);
456 457
457 // Op without slow paths 458 // Op without slow paths
458 PaintFlags noop_flags; 459 PaintFlags noop_flags;
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 { 910 {
910 testing::Sequence s; 911 testing::Sequence s;
911 EXPECT_CALL(canvas, OnDrawRectWithColor(0u)).InSequence(s); 912 EXPECT_CALL(canvas, OnDrawRectWithColor(0u)).InSequence(s);
912 EXPECT_CALL(canvas, OnDrawRectWithColor(1u)).InSequence(s); 913 EXPECT_CALL(canvas, OnDrawRectWithColor(1u)).InSequence(s);
913 EXPECT_CALL(canvas, OnDrawRectWithColor(2u)).InSequence(s); 914 EXPECT_CALL(canvas, OnDrawRectWithColor(2u)).InSequence(s);
914 buffer.PlaybackRanges(ranges, {0, 2}, &canvas); 915 buffer.PlaybackRanges(ranges, {0, 2}, &canvas);
915 } 916 }
916 } 917 }
917 918
918 } // namespace cc 919 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698