| 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 "SkPictureShader.h" | 8 #include "SkPictureShader.h" |
| 9 | 9 |
| 10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 | 49 |
| 50 buffer.write32(fTmx); | 50 buffer.write32(fTmx); |
| 51 buffer.write32(fTmy); | 51 buffer.write32(fTmy); |
| 52 fPicture->flatten(buffer); | 52 fPicture->flatten(buffer); |
| 53 } | 53 } |
| 54 | 54 |
| 55 SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri
x* localM) const { | 55 SkShader* SkPictureShader::refBitmapShader(const SkMatrix& matrix, const SkMatri
x* localM) const { |
| 56 SkASSERT(fPicture && fPicture->width() > 0 && fPicture->height() > 0); | 56 SkASSERT(fPicture && fPicture->width() > 0 && fPicture->height() > 0); |
| 57 | 57 |
| 58 SkMatrix m; | 58 SkMatrix m; |
| 59 m.setConcat(matrix, this->getLocalMatrix()); | 59 if (this->hasLocalMatrix()) { |
| 60 m.setConcat(matrix, this->getLocalMatrix()); |
| 61 } else { |
| 62 m = matrix; |
| 63 } |
| 60 if (localM) { | 64 if (localM) { |
| 61 m.preConcat(*localM); | 65 m.preConcat(*localM); |
| 62 } | 66 } |
| 63 | 67 |
| 64 // Use a rotation-invariant scale | 68 // Use a rotation-invariant scale |
| 65 SkPoint scale; | 69 SkPoint scale; |
| 66 if (!SkDecomposeUpper2x2(m, NULL, &scale, NULL)) { | 70 if (!SkDecomposeUpper2x2(m, NULL, &scale, NULL)) { |
| 67 // Decomposition failed, use an approximation. | 71 // Decomposition failed, use an approximation. |
| 68 scale.set(SkScalarSqrt(m.getScaleX() * m.getScaleX() + m.getSkewX() * m.
getSkewX()), | 72 scale.set(SkScalarSqrt(m.getScaleX() * m.getScaleX() + m.getSkewX() * m.
getSkewX()), |
| 69 SkScalarSqrt(m.getScaleY() * m.getScaleY() + m.getSkewY() * m.
getSkewY())); | 73 SkScalarSqrt(m.getScaleY() * m.getScaleY() + m.getSkewY() * m.
getSkewY())); |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 193 |
| 190 #if SK_SUPPORT_GPU | 194 #if SK_SUPPORT_GPU |
| 191 GrEffectRef* SkPictureShader::asNewEffect(GrContext* context, const SkPaint& pai
nt) const { | 195 GrEffectRef* SkPictureShader::asNewEffect(GrContext* context, const SkPaint& pai
nt) const { |
| 192 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix
(), NULL)); | 196 SkAutoTUnref<SkShader> bitmapShader(this->refBitmapShader(context->getMatrix
(), NULL)); |
| 193 if (!bitmapShader) { | 197 if (!bitmapShader) { |
| 194 return NULL; | 198 return NULL; |
| 195 } | 199 } |
| 196 return bitmapShader->asNewEffect(context, paint); | 200 return bitmapShader->asNewEffect(context, paint); |
| 197 } | 201 } |
| 198 #endif | 202 #endif |
| OLD | NEW |