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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 return false; | 60 return false; |
61 } | 61 } |
62 | 62 |
63 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), | 63 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), |
64 bounds.height())); | 64 bounds.height())); |
65 if (NULL == device.get()) { | 65 if (NULL == device.get()) { |
66 return false; | 66 return false; |
67 } | 67 } |
68 SkCanvas canvas(device.get()); | 68 SkCanvas canvas(device.get()); |
69 SkPaint paint; | 69 SkPaint paint; |
70 paint.setShader(fShader); | |
71 SkMatrix matrix(ctx.ctm()); | 70 SkMatrix matrix(ctx.ctm()); |
72 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to p())); | 71 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to p())); |
73 fShader->setLocalMatrix(matrix); | 72 paint.setShader(SkShader::CreateLocalMatrixWrapper(fShader, matrix)); |
scroggo
2014/04/24 17:02:53
Don't we need to unref this shader? (Previously we
Dominik Grewe
2014/04/24 17:16:47
Yeah, I think you're right.
| |
74 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo unds.height())); | 73 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo unds.height())); |
75 canvas.drawRect(rect, paint); | 74 canvas.drawRect(rect, paint); |
76 *result = device.get()->accessBitmap(false); | 75 *result = device.get()->accessBitmap(false); |
77 offset->fX = bounds.fLeft; | 76 offset->fX = bounds.fLeft; |
78 offset->fY = bounds.fTop; | 77 offset->fY = bounds.fTop; |
79 return true; | 78 return true; |
80 } | 79 } |
OLD | NEW |