Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2008, Google Inc. All rights reserved. | 2 * Copyright (c) 2008, Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 405 info.fAlphaType = kPremul_SkAlphaType; | 405 info.fAlphaType = kPremul_SkAlphaType; |
| 406 | 406 |
| 407 SkBitmap result; | 407 SkBitmap result; |
| 408 result.allocPixels(info); | 408 result.allocPixels(info); |
| 409 result.eraseColor(SK_ColorTRANSPARENT); | 409 result.eraseColor(SK_ColorTRANSPARENT); |
| 410 bitmap.copyPixelsTo(reinterpret_cast<uint8_t*>(result.getPixels()), result.r owBytes() * result.height(), result.rowBytes()); | 410 bitmap.copyPixelsTo(reinterpret_cast<uint8_t*>(result.getPixels()), result.r owBytes() * result.height(), result.rowBytes()); |
| 411 | 411 |
| 412 return result; | 412 return result; |
| 413 } | 413 } |
| 414 | 414 |
| 415 static SkVector computeScaleVector(const SkMatrix& matrix) | |
| 416 { | |
| 417 SkScalar scaleX = matrix.getScaleX(); | |
| 418 SkScalar scaleY = matrix.getScaleY(); | |
| 419 SkScalar skewX = matrix.getSkewX(); | |
| 420 SkScalar skewY = matrix.getSkewY(); | |
| 421 return SkVector::Make(sqrt(scaleX * scaleX + skewY * skewY), sqrt(scaleY * s caleY + skewX * skewX)); | |
|
Stephen White
2014/04/03 12:25:04
This looks a lot like AffineTransform::xScale() an
fs
2014/04/03 14:01:31
That was the intention...
| |
| 422 } | |
| 423 | |
| 415 void NativeImageSkia::drawPattern( | 424 void NativeImageSkia::drawPattern( |
| 416 GraphicsContext* context, | 425 GraphicsContext* context, |
| 417 const FloatRect& floatSrcRect, | 426 const FloatRect& floatSrcRect, |
| 418 const FloatSize& scale, | 427 const FloatSize& scale, |
| 419 const FloatPoint& phase, | 428 const FloatPoint& phase, |
| 420 CompositeOperator compositeOp, | 429 CompositeOperator compositeOp, |
| 421 const FloatRect& destRect, | 430 const FloatRect& destRect, |
| 422 blink::WebBlendMode blendMode, | 431 blink::WebBlendMode blendMode, |
| 423 const IntSize& repeatSpacing) const | 432 const IntSize& repeatSpacing) const |
| 424 { | 433 { |
| 425 FloatRect normSrcRect = floatSrcRect; | 434 FloatRect normSrcRect = floatSrcRect; |
| 426 normSrcRect.intersect(FloatRect(0, 0, bitmap().width(), bitmap().height())); | 435 normSrcRect.intersect(FloatRect(0, 0, bitmap().width(), bitmap().height())); |
| 427 if (destRect.isEmpty() || normSrcRect.isEmpty()) | 436 if (destRect.isEmpty() || normSrcRect.isEmpty()) |
| 428 return; // nothing to draw | 437 return; // nothing to draw |
| 429 | 438 |
| 430 SkMatrix totalMatrix = context->getTotalMatrix(); | 439 SkMatrix totalMatrix = context->getTotalMatrix(); |
| 431 SkScalar ctmScaleX = totalMatrix.getScaleX(); | 440 SkVector ctmScale = computeScaleVector(totalMatrix); |
|
Stephen White
2014/04/03 12:25:04
Could this be
AffineTransform ctm = context->getC
fs
2014/04/03 14:01:31
...because I failed to find this one. Changed to u
| |
| 432 SkScalar ctmScaleY = totalMatrix.getScaleY(); | 441 SkScalar ctmScaleX = ctmScale.x(); |
| 442 SkScalar ctmScaleY = ctmScale.y(); | |
| 433 totalMatrix.preScale(scale.width(), scale.height()); | 443 totalMatrix.preScale(scale.width(), scale.height()); |
| 434 | 444 |
| 435 // Figure out what size the bitmap will be in the destination. The | 445 // Figure out what size the bitmap will be in the destination. The |
| 436 // destination rect is the bounds of the pattern, we need to use the | 446 // destination rect is the bounds of the pattern, we need to use the |
| 437 // matrix to see how big it will be. | 447 // matrix to see how big it will be. |
| 438 SkRect destRectTarget; | 448 SkRect destRectTarget; |
| 439 totalMatrix.mapRect(&destRectTarget, normSrcRect); | 449 totalMatrix.mapRect(&destRectTarget, normSrcRect); |
| 440 | 450 |
| 441 float destBitmapWidth = SkScalarToFloat(destRectTarget.width()); | 451 float destBitmapWidth = SkScalarToFloat(destRectTarget.width()); |
| 442 float destBitmapHeight = SkScalarToFloat(destRectTarget.height()); | 452 float destBitmapHeight = SkScalarToFloat(destRectTarget.height()); |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 587 SkIRect NativeImageSkia::ImageResourceInfo::rectInSubset(const SkIRect& otherSca ledImageSubset) | 597 SkIRect NativeImageSkia::ImageResourceInfo::rectInSubset(const SkIRect& otherSca ledImageSubset) |
| 588 { | 598 { |
| 589 if (!scaledImageSubset.contains(otherScaledImageSubset)) | 599 if (!scaledImageSubset.contains(otherScaledImageSubset)) |
| 590 return SkIRect::MakeEmpty(); | 600 return SkIRect::MakeEmpty(); |
| 591 SkIRect subsetRect = otherScaledImageSubset; | 601 SkIRect subsetRect = otherScaledImageSubset; |
| 592 subsetRect.offset(-scaledImageSubset.x(), -scaledImageSubset.y()); | 602 subsetRect.offset(-scaledImageSubset.x(), -scaledImageSubset.y()); |
| 593 return subsetRect; | 603 return subsetRect; |
| 594 } | 604 } |
| 595 | 605 |
| 596 } // namespace WebCore | 606 } // namespace WebCore |
| OLD | NEW |