| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "SkRectShaderImageFilter.h" | 8 #include "SkRectShaderImageFilter.h" |
| 9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), | 61 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), |
| 62 bounds.height())); | 62 bounds.height())); |
| 63 if (nullptr == device.get()) { | 63 if (nullptr == device.get()) { |
| 64 return false; | 64 return false; |
| 65 } | 65 } |
| 66 SkCanvas canvas(device.get()); | 66 SkCanvas canvas(device.get()); |
| 67 | 67 |
| 68 SkPaint paint; | 68 SkPaint paint; |
| 69 SkMatrix matrix(ctx.ctm()); | 69 SkMatrix matrix(ctx.ctm()); |
| 70 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); | 70 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to
p())); |
| 71 SkSafeUnref(paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matri
x))); | 71 SkSafeUnref(paint.setShader(fShader->newWithLocalMatrix(matrix))); |
| 72 | 72 |
| 73 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo
unds.height())); | 73 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo
unds.height())); |
| 74 canvas.drawRect(rect, paint); | 74 canvas.drawRect(rect, paint); |
| 75 | 75 |
| 76 *result = device.get()->accessBitmap(false); | 76 *result = device.get()->accessBitmap(false); |
| 77 offset->fX = bounds.fLeft; | 77 offset->fX = bounds.fLeft; |
| 78 offset->fY = bounds.fTop; | 78 offset->fY = bounds.fTop; |
| 79 return true; | 79 return true; |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool SkRectShaderImageFilter::canComputeFastBounds() const { | 82 bool SkRectShaderImageFilter::canComputeFastBounds() const { |
| 83 // http:skbug.com/4627: "make computeFastBounds and onFilterBounds() CropRec
t-aware" | 83 // http:skbug.com/4627: "make computeFastBounds and onFilterBounds() CropRec
t-aware" |
| 84 // computeFastBounds() doesn't currently take the crop rect into account, | 84 // computeFastBounds() doesn't currently take the crop rect into account, |
| 85 // so we can't compute it. If a full crop rect is set, we should return true
here. | 85 // so we can't compute it. If a full crop rect is set, we should return true
here. |
| 86 return false; | 86 return false; |
| 87 } | 87 } |
| 88 | 88 |
| 89 #ifndef SK_IGNORE_TO_STRING | 89 #ifndef SK_IGNORE_TO_STRING |
| 90 void SkRectShaderImageFilter::toString(SkString* str) const { | 90 void SkRectShaderImageFilter::toString(SkString* str) const { |
| 91 str->appendf("SkRectShaderImageFilter: ("); | 91 str->appendf("SkRectShaderImageFilter: ("); |
| 92 str->append(")"); | 92 str->append(")"); |
| 93 } | 93 } |
| 94 #endif | 94 #endif |
| OLD | NEW |