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

Side by Side Diff: tests/BlurTest.cpp

Issue 2222083004: Create blurred RRect mask on GPU (rather than uploading it) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: SkColor -> GrColor Created 4 years, 4 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 | « src/gpu/SkGpuDevice_drawTexture.cpp ('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 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkBlurMask.h" 8 #include "SkBlurMask.h"
9 #include "SkBlurMaskFilter.h" 9 #include "SkBlurMaskFilter.h"
10 #include "SkBlurDrawLooper.h" 10 #include "SkBlurDrawLooper.h"
(...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 SkRRect rr = SkRRect::MakeRectXY(r, 10, 10); 567 SkRRect rr = SkRRect::MakeRectXY(r, 10, 10);
568 568
569 SkPaint p; 569 SkPaint p;
570 p.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 0.01f)); 570 p.setMaskFilter(SkBlurMaskFilter::Make(kNormal_SkBlurStyle, 0.01f));
571 571
572 canvas->drawRRect(rr, p); 572 canvas->drawRRect(rr, p);
573 } 573 }
574 574
575 #endif 575 #endif
576 576
577
578 DEF_TEST(BlurredRRectNinePatchComputation, reporter) {
579 const SkRect r = SkRect::MakeXYWH(10, 10, 100, 100);
580
581 bool ninePatchable;
582 SkRRect rrectToDraw;
583 SkISize size;
584 SkScalar xs[4], ys[4];
585 int numXs, numYs;
586
587 // not nine-patchable
588 {
589 SkVector radii[4] = { { 100, 100 }, { 0, 0 }, { 100, 100 }, { 0, 0 } };
590
591 SkRRect rr;
592 rr.setRectRadii(r, radii);
593
594 ninePatchable = SkBlurMaskFilter::ComputeBlurredRRectParams(rr, 3.0f, &r rectToDraw, &size,
595 xs, &numXs, ys, &numYs);
596 REPORTER_ASSERT(reporter, !ninePatchable);
597 }
598
599 // simple circular
600 {
601 SkRRect rr;
602 rr.setRectXY(r, 10, 10);
603
604 ninePatchable = SkBlurMaskFilter::ComputeBlurredRRectParams(rr, 3.0f, &r rectToDraw, &size,
605 xs, &numXs, ys, &numYs);
606 REPORTER_ASSERT(reporter, ninePatchable);
607 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SkIntToScalar(size.fWidth) , 57.0f));
608 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SkIntToScalar(size.fHeight ), 57.0));
609 REPORTER_ASSERT(reporter, 4 == numXs && 4 == numYs);
610 for (int i = 0; i < numXs; ++i) {
611 REPORTER_ASSERT(reporter, xs[i] >= 0.0f && xs[i] <= 1.0f);
612 }
613 for (int i = 0; i < numYs; ++i) {
614 REPORTER_ASSERT(reporter, ys[i] >= 0.0f && ys[i] <= 1.0f);
615 }
616 }
617
618 // simple elliptical
619 {
620 SkRRect rr;
621 rr.setRectXY(r, 2, 10);
622
623 ninePatchable = SkBlurMaskFilter::ComputeBlurredRRectParams(rr, 3.0f, &r rectToDraw, &size,
624 xs, &numXs, ys, &numYs);
625 REPORTER_ASSERT(reporter, ninePatchable);
626 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SkIntToScalar(size.fWidth) , 41.0f));
627 REPORTER_ASSERT(reporter, SkScalarNearlyEqual(SkIntToScalar(size.fHeight ), 57.0));
628 REPORTER_ASSERT(reporter, 4 == numXs && 4 == numYs);
629 for (int i = 0; i < numXs; ++i) {
630 REPORTER_ASSERT(reporter, xs[i] >= 0.0f && xs[i] <= 1.0f);
631 }
632 for (int i = 0; i < numYs; ++i) {
633 REPORTER_ASSERT(reporter, ys[i] >= 0.0f && ys[i] <= 1.0f);
634 }
635 }
636
637 }
638
577 //////////////////////////////////////////////////////////////////////////////// /////////// 639 //////////////////////////////////////////////////////////////////////////////// ///////////
OLDNEW
« no previous file with comments | « src/gpu/SkGpuDevice_drawTexture.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698