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

Side by Side Diff: skia/ext/analysis_canvas_unittest.cc

Issue 2449583002: Support rrect clips in analysis canvas (Closed)
Patch Set: Address reviewer feedback. Created 4 years, 1 month 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 | « skia/ext/analysis_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/compiler_specific.h" 5 #include "base/compiler_specific.h"
6 #include "base/macros.h"
6 #include "skia/ext/analysis_canvas.h" 7 #include "skia/ext/analysis_canvas.h"
7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
8 #include "third_party/skia/include/core/SkPicture.h" 9 #include "third_party/skia/include/core/SkPicture.h"
9 #include "third_party/skia/include/core/SkPictureRecorder.h" 10 #include "third_party/skia/include/core/SkPictureRecorder.h"
10 #include "third_party/skia/include/core/SkRefCnt.h" 11 #include "third_party/skia/include/core/SkRefCnt.h"
11 #include "third_party/skia/include/core/SkShader.h" 12 #include "third_party/skia/include/core/SkShader.h"
12 #include "third_party/skia/include/effects/SkOffsetImageFilter.h" 13 #include "third_party/skia/include/effects/SkOffsetImageFilter.h"
13 14
14 namespace { 15 namespace {
15 16
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 canvas.clipRegion(region); 382 canvas.clipRegion(region);
382 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); 383 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor));
383 384
384 canvas.restore(); 385 canvas.restore();
385 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); 386 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor));
386 387
387 SolidColorFill(canvas); 388 SolidColorFill(canvas);
388 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor)); 389 EXPECT_FALSE(canvas.GetColorIfSolid(&outputColor));
389 } 390 }
390 391
392 TEST(AnalysisCanvasTest, ClipRRectCoversCanvas) {
393
394 SkVector radii[4] = {
395 SkVector::Make(10.0, 15.0),
396 SkVector::Make(20.0, 25.0),
397 SkVector::Make(30.0, 35.0),
398 SkVector::Make(40.0, 45.0),
399 };
400
401 int rr_size = 600;
402 int canvas_size = 255;
403
404 struct {
405 SkVector offset;
406 bool expected;
407 } cases [] = {
408 // Not within bounding box of |rr|.
409 { SkVector::Make(100.0, 100.0), false },
410
411 // Intersects UL corner.
412 { SkVector::Make(0.0, 0.0), false },
413
414 // Between UL and UR.
415 { SkVector::Make(-50.0, 0), true },
416
417 // Intersects UR corner.
418 { SkVector::Make(canvas_size - rr_size, 0), false },
419
420 // Between UR and LR.
421 { SkVector::Make(canvas_size - rr_size, -50.0), true },
422
423 // Intersects LR corner.
424 { SkVector::Make(canvas_size - rr_size, canvas_size - rr_size), false },
425
426 // Between LL and LR
427 { SkVector::Make(-50, canvas_size - rr_size), true },
428
429 // Intersects LL corner
430 { SkVector::Make(0, canvas_size - rr_size), false },
431
432 // Between UL and LL
433 { SkVector::Make(0, -50), true },
434
435 // In center
436 { SkVector::Make(-100, -100), true},
437 };
438
439 SkColor outputColor;
440
441 for (size_t i = 0; i < arraysize(cases); ++i) {
442 skia::AnalysisCanvas canvas(canvas_size, canvas_size);
443
444 SkRect bounding_rect = SkRect::MakeXYWH(
445 cases[i].offset.x(), cases[i].offset.y(), rr_size, rr_size);
446
447 SkRRect rr;
448 rr.setRectRadii(bounding_rect, radii);
449
450 canvas.clipRRect(rr);
451 EXPECT_EQ(cases[i].expected, canvas.GetColorIfSolid(&outputColor)) << i;
452 }
453 }
454
391 } // namespace skia 455 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/analysis_canvas.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698