| OLD | NEW | 
|---|
| 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  Loading... | 
| 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 | 
| OLD | NEW | 
|---|