OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "SkRRect.h" | 8 #include "SkRRect.h" |
9 #include "SkMatrix.h" | 9 #include "SkMatrix.h" |
10 | 10 |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 } | 335 } |
336 | 336 |
337 SkRect newRect; | 337 SkRect newRect; |
338 if (!matrix.mapRect(&newRect, fRect)) { | 338 if (!matrix.mapRect(&newRect, fRect)) { |
339 return false; | 339 return false; |
340 } | 340 } |
341 | 341 |
342 // At this point, this is guaranteed to succeed, so we can modify dst. | 342 // At this point, this is guaranteed to succeed, so we can modify dst. |
343 dst->fRect = newRect; | 343 dst->fRect = newRect; |
344 | 344 |
| 345 // Since the only transforms that were allowed are scale and translate, the
type |
| 346 // remains unchanged. |
| 347 dst->fType = fType; |
| 348 |
| 349 if (kOval_Type == fType) { |
| 350 for (int i = 0; i < 4; ++i) { |
| 351 dst->fRadii[i].fX = SkScalarHalf(newRect.width()); |
| 352 dst->fRadii[i].fY = SkScalarHalf(newRect.height()); |
| 353 } |
| 354 SkDEBUGCODE(dst->validate();) |
| 355 return true; |
| 356 } |
| 357 |
345 // Now scale each corner | 358 // Now scale each corner |
346 SkScalar xScale = matrix.getScaleX(); | 359 SkScalar xScale = matrix.getScaleX(); |
347 const bool flipX = xScale < 0; | 360 const bool flipX = xScale < 0; |
348 if (flipX) { | 361 if (flipX) { |
349 xScale = -xScale; | 362 xScale = -xScale; |
350 } | 363 } |
351 SkScalar yScale = matrix.getScaleY(); | 364 SkScalar yScale = matrix.getScaleY(); |
352 const bool flipY = yScale < 0; | 365 const bool flipY = yScale < 0; |
353 if (flipY) { | 366 if (flipY) { |
354 yScale = -yScale; | 367 yScale = -yScale; |
(...skipping 15 matching lines...) Expand all Loading... |
370 // Only swap in x | 383 // Only swap in x |
371 SkTSwap(dst->fRadii[kUpperRight_Corner], dst->fRadii[kUpperLeft_Corn
er]); | 384 SkTSwap(dst->fRadii[kUpperRight_Corner], dst->fRadii[kUpperLeft_Corn
er]); |
372 SkTSwap(dst->fRadii[kLowerRight_Corner], dst->fRadii[kLowerLeft_Corn
er]); | 385 SkTSwap(dst->fRadii[kLowerRight_Corner], dst->fRadii[kLowerLeft_Corn
er]); |
373 } | 386 } |
374 } else if (flipY) { | 387 } else if (flipY) { |
375 // Only swap in y | 388 // Only swap in y |
376 SkTSwap(dst->fRadii[kUpperLeft_Corner], dst->fRadii[kLowerLeft_Corner]); | 389 SkTSwap(dst->fRadii[kUpperLeft_Corner], dst->fRadii[kLowerLeft_Corner]); |
377 SkTSwap(dst->fRadii[kUpperRight_Corner], dst->fRadii[kLowerRight_Corner]
); | 390 SkTSwap(dst->fRadii[kUpperRight_Corner], dst->fRadii[kLowerRight_Corner]
); |
378 } | 391 } |
379 | 392 |
380 // Since the only transforms that were allowed are scale and translate, the
type | |
381 // remains unchanged. | |
382 dst->fType = fType; | |
383 | |
384 SkDEBUGCODE(dst->validate();) | 393 SkDEBUGCODE(dst->validate();) |
385 | 394 |
386 return true; | 395 return true; |
387 } | 396 } |
388 | 397 |
389 /////////////////////////////////////////////////////////////////////////////// | 398 /////////////////////////////////////////////////////////////////////////////// |
390 | 399 |
391 void SkRRect::inset(SkScalar dx, SkScalar dy, SkRRect* dst) const { | 400 void SkRRect::inset(SkScalar dx, SkScalar dy, SkRRect* dst) const { |
392 SkRect r = fRect; | 401 SkRect r = fRect; |
393 | 402 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
504 SkASSERT(!patchesOfNine); | 513 SkASSERT(!patchesOfNine); |
505 break; | 514 break; |
506 case kUnknown_Type: | 515 case kUnknown_Type: |
507 // no limits on this | 516 // no limits on this |
508 break; | 517 break; |
509 } | 518 } |
510 } | 519 } |
511 #endif // SK_DEBUG | 520 #endif // SK_DEBUG |
512 | 521 |
513 /////////////////////////////////////////////////////////////////////////////// | 522 /////////////////////////////////////////////////////////////////////////////// |
OLD | NEW |