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

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

Issue 2880813002: Revert of Add stable id to PaintImage. (Closed)
Patch Set: Created 3 years, 7 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_image.cc ('k') | cc/paint/record_paint_canvas.cc » ('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 "cc/paint/display_item_list.h" 6 #include "cc/paint/display_item_list.h"
7 #include "cc/test/skia_common.h" 7 #include "cc/test/skia_common.h"
8 #include "cc/test/test_skcanvas.h" 8 #include "cc/test/test_skcanvas.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after
426 426
427 TEST(PaintOpBufferTest, DiscardableImagesTracking_NoImageOp) { 427 TEST(PaintOpBufferTest, DiscardableImagesTracking_NoImageOp) {
428 PaintOpBuffer buffer; 428 PaintOpBuffer buffer;
429 PaintFlags flags; 429 PaintFlags flags;
430 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags); 430 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags);
431 EXPECT_FALSE(buffer.HasDiscardableImages()); 431 EXPECT_FALSE(buffer.HasDiscardableImages());
432 } 432 }
433 433
434 TEST(PaintOpBufferTest, DiscardableImagesTracking_DrawImage) { 434 TEST(PaintOpBufferTest, DiscardableImagesTracking_DrawImage) {
435 PaintOpBuffer buffer; 435 PaintOpBuffer buffer;
436 PaintImage image = PaintImage(PaintImage::GetNextId(), 436 PaintImage image = PaintImage(CreateDiscardableImage(gfx::Size(100, 100)));
437 CreateDiscardableImage(gfx::Size(100, 100)));
438 buffer.push<DrawImageOp>(image, SkIntToScalar(0), SkIntToScalar(0), nullptr); 437 buffer.push<DrawImageOp>(image, SkIntToScalar(0), SkIntToScalar(0), nullptr);
439 EXPECT_TRUE(buffer.HasDiscardableImages()); 438 EXPECT_TRUE(buffer.HasDiscardableImages());
440 } 439 }
441 440
442 TEST(PaintOpBufferTest, DiscardableImagesTracking_DrawImageRect) { 441 TEST(PaintOpBufferTest, DiscardableImagesTracking_DrawImageRect) {
443 PaintOpBuffer buffer; 442 PaintOpBuffer buffer;
444 PaintImage image = PaintImage(PaintImage::GetNextId(), 443 PaintImage image = PaintImage(CreateDiscardableImage(gfx::Size(100, 100)));
445 CreateDiscardableImage(gfx::Size(100, 100)));
446 buffer.push<DrawImageRectOp>( 444 buffer.push<DrawImageRectOp>(
447 image, SkRect::MakeWH(100, 100), SkRect::MakeWH(100, 100), nullptr, 445 image, SkRect::MakeWH(100, 100), SkRect::MakeWH(100, 100), nullptr,
448 PaintCanvas::SrcRectConstraint::kFast_SrcRectConstraint); 446 PaintCanvas::SrcRectConstraint::kFast_SrcRectConstraint);
449 EXPECT_TRUE(buffer.HasDiscardableImages()); 447 EXPECT_TRUE(buffer.HasDiscardableImages());
450 } 448 }
451 449
452 TEST(PaintOpBufferTest, DiscardableImagesTracking_NestedDrawOp) { 450 TEST(PaintOpBufferTest, DiscardableImagesTracking_NestedDrawOp) {
453 sk_sp<PaintRecord> record = sk_make_sp<PaintRecord>(); 451 sk_sp<PaintRecord> record = sk_make_sp<PaintRecord>();
454 PaintImage image = PaintImage(PaintImage::GetNextId(), 452 PaintImage image = PaintImage(CreateDiscardableImage(gfx::Size(100, 100)));
455 CreateDiscardableImage(gfx::Size(100, 100)));
456 record->push<DrawImageOp>(image, SkIntToScalar(0), SkIntToScalar(0), nullptr); 453 record->push<DrawImageOp>(image, SkIntToScalar(0), SkIntToScalar(0), nullptr);
457 454
458 PaintOpBuffer buffer; 455 PaintOpBuffer buffer;
459 buffer.push<DrawRecordOp>(record); 456 buffer.push<DrawRecordOp>(record);
460 EXPECT_TRUE(buffer.HasDiscardableImages()); 457 EXPECT_TRUE(buffer.HasDiscardableImages());
461 458
462 scoped_refptr<DisplayItemList> list = new DisplayItemList; 459 scoped_refptr<DisplayItemList> list = new DisplayItemList;
463 list->CreateAndAppendDrawingItem<DrawingDisplayItem>( 460 list->CreateAndAppendDrawingItem<DrawingDisplayItem>(
464 gfx::Rect(0, 0, 100, 100), record); 461 gfx::Rect(0, 0, 100, 100), record);
465 list->Finalize(); 462 list->Finalize();
466 PaintOpBuffer new_buffer; 463 PaintOpBuffer new_buffer;
467 new_buffer.push<DrawDisplayItemListOp>(list); 464 new_buffer.push<DrawDisplayItemListOp>(list);
468 EXPECT_TRUE(new_buffer.HasDiscardableImages()); 465 EXPECT_TRUE(new_buffer.HasDiscardableImages());
469 } 466 }
470 467
471 TEST(PaintOpBufferTest, DiscardableImagesTracking_OpWithFlags) { 468 TEST(PaintOpBufferTest, DiscardableImagesTracking_OpWithFlags) {
472 PaintOpBuffer buffer; 469 PaintOpBuffer buffer;
473 PaintFlags flags; 470 PaintFlags flags;
474 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(100, 100)); 471 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(100, 100));
475 flags.setShader( 472 flags.setShader(
476 image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode)); 473 image->makeShader(SkShader::kClamp_TileMode, SkShader::kClamp_TileMode));
477 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags); 474 buffer.push<DrawRectOp>(SkRect::MakeWH(100, 100), flags);
478 EXPECT_TRUE(buffer.HasDiscardableImages()); 475 EXPECT_TRUE(buffer.HasDiscardableImages());
479 } 476 }
480 477
481 } // namespace cc 478 } // namespace cc
OLDNEW
« no previous file with comments | « cc/paint/paint_image.cc ('k') | cc/paint/record_paint_canvas.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698