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

Side by Side Diff: tools/sk_tool_utils.cpp

Issue 2203153002: Add new bench for occluded blurmaskfilter draws (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Appease compilers 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 | « tools/sk_tool_utils.h ('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 2014 Google Inc. 2 * Copyright 2014 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 "sk_tool_utils.h" 8 #include "sk_tool_utils.h"
9 #include "sk_tool_utils_flags.h" 9 #include "sk_tool_utils_flags.h"
10 10
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 456
457 for (int y = 0; y < src.height(); ++y) { 457 for (int y = 0; y < src.height(); ++y) {
458 for (int x = 0; x < src.width(); ++x) { 458 for (int x = 0; x < src.width(); ++x) {
459 *dst.getAddr32(x, y) = blur_pixel(src, x, y, kernel.get(), wh); 459 *dst.getAddr32(x, y) = blur_pixel(src, x, y, kernel.get(), wh);
460 } 460 }
461 } 461 }
462 462
463 return dst; 463 return dst;
464 } 464 }
465 465
466 // compute the intersection point between the diagonal and the ellipse in the
467 // lower right corner
468 static SkPoint intersection(SkScalar w, SkScalar h) {
469 SkASSERT(w > 0.0f || h > 0.0f);
470
471 return SkPoint::Make(w / SK_ScalarSqrt2, h / SK_ScalarSqrt2);
472 }
473
474 // Use the intersection of the corners' diagonals with their ellipses to shrink
475 // the bounding rect
476 SkRect compute_central_occluder(const SkRRect& rr) {
477 const SkRect r = rr.getBounds();
478
479 SkScalar newL = r.fLeft, newT = r.fTop, newR = r.fRight, newB = r.fBottom;
480
481 SkVector radii = rr.radii(SkRRect::kUpperLeft_Corner);
482 if (!radii.isZero()) {
483 SkPoint p = intersection(radii.fX, radii.fY);
484
485 newL = SkTMax(newL, r.fLeft + radii.fX - p.fX);
486 newT = SkTMax(newT, r.fTop + radii.fY - p.fY);
487 }
488
489 radii = rr.radii(SkRRect::kUpperRight_Corner);
490 if (!radii.isZero()) {
491 SkPoint p = intersection(radii.fX, radii.fY);
492
493 newR = SkTMin(newR, r.fRight + p.fX - radii.fX);
494 newT = SkTMax(newT, r.fTop + radii.fY - p.fY);
495 }
496
497 radii = rr.radii(SkRRect::kLowerRight_Corner);
498 if (!radii.isZero()) {
499 SkPoint p = intersection(radii.fX, radii.fY);
500
501 newR = SkTMin(newR, r.fRight + p.fX - radii.fX);
502 newB = SkTMin(newB, r.fBottom - radii.fY + p.fY);
503 }
504
505 radii = rr.radii(SkRRect::kLowerLeft_Corner);
506 if (!radii.isZero()) {
507 SkPoint p = intersection(radii.fX, radii.fY);
508
509 newL = SkTMax(newL, r.fLeft + radii.fX - p.fX);
510 newB = SkTMin(newB, r.fBottom - radii.fY + p.fY);
511 }
512
513 return SkRect::MakeLTRB(newL, newT, newR, newB);
514 }
515
466 } // namespace sk_tool_utils 516 } // namespace sk_tool_utils
OLDNEW
« no previous file with comments | « tools/sk_tool_utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698