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

Side by Side Diff: cc/raster/image_hijack_canvas_unittest.cc

Issue 2842333003: cc: Update discardable image metadata generation to get PaintImages. (Closed)
Patch Set: win 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/raster/image_hijack_canvas.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "cc/raster/image_hijack_canvas.h" 4 #include "cc/raster/image_hijack_canvas.h"
5 5
6 #include "cc/test/skia_common.h" 6 #include "cc/test/skia_common.h"
7 #include "cc/tiles/image_decode_cache.h" 7 #include "cc/tiles/image_decode_cache.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 #include "third_party/skia/include/core/SkBitmap.h" 10 #include "third_party/skia/include/core/SkBitmap.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 SkPaint paint; 82 SkPaint paint;
83 canvas.drawImage(image, 0, 0, &paint); 83 canvas.drawImage(image, 0, 0, &paint);
84 canvas.drawImageRect(image, SkRect::MakeXYWH(0, 0, 10, 10), 84 canvas.drawImageRect(image, SkRect::MakeXYWH(0, 0, 10, 10),
85 SkRect::MakeXYWH(10, 10, 10, 10), &paint); 85 SkRect::MakeXYWH(10, 10, 10, 10), &paint);
86 paint.setShader(image->makeShader(SkShader::kClamp_TileMode, 86 paint.setShader(image->makeShader(SkShader::kClamp_TileMode,
87 SkShader::kClamp_TileMode, nullptr)); 87 SkShader::kClamp_TileMode, nullptr));
88 canvas.drawRect(SkRect::MakeXYWH(10, 10, 10, 10), paint); 88 canvas.drawRect(SkRect::MakeXYWH(10, 10, 10, 10), paint);
89 } 89 }
90 90
91 TEST(ImageHijackCanvasTest, ClippedOpsAreSkipped) {
92 testing::StrictMock<MockImageDecodeCache> image_decode_cache;
93 ImageIdFlatSet images_to_skip;
94 gfx::ColorSpace target_color_space = gfx::ColorSpace::CreateSRGB();
95 ImageHijackCanvas canvas(100, 100, &image_decode_cache, &images_to_skip,
96 target_color_space);
97 SkPaint paint;
98 SkRect draw_rect = SkRect::MakeXYWH(200, 200, 100, 100);
99 sk_sp<SkImage> image = CreateDiscardableImage(gfx::Size(10, 10));
100 canvas.drawImage(image, 200, 200, &paint);
101 canvas.drawImageRect(image, SkRect::MakeXYWH(0, 0, 10, 10), draw_rect,
102 &paint);
103 paint.setShader(image->makeShader(SkShader::kClamp_TileMode,
104 SkShader::kClamp_TileMode, nullptr));
105 canvas.drawRect(draw_rect, paint);
106 SkPath path;
107 path.addRect(draw_rect, SkPath::kCW_Direction);
108 canvas.drawPath(path, paint);
109 canvas.drawOval(draw_rect, paint);
110 canvas.drawArc(draw_rect, 0, 40, true, paint);
111 canvas.drawRRect(SkRRect::MakeRect(draw_rect), paint);
112 }
113
91 } // namespace 114 } // namespace
92 115
93 } // namespace cc 116 } // namespace cc
OLDNEW
« no previous file with comments | « cc/raster/image_hijack_canvas.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698