Chromium Code Reviews| 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 15 matching lines...) Expand all Loading... | |
| 26 SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const Crop Rect* cropRect, uint32_t uniqueID) { | 26 SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const Crop Rect* cropRect, uint32_t uniqueID) { |
| 27 SkASSERT(s); | 27 SkASSERT(s); |
| 28 return SkNEW_ARGS(SkRectShaderImageFilter, (s, cropRect, uniqueID)); | 28 return SkNEW_ARGS(SkRectShaderImageFilter, (s, cropRect, uniqueID)); |
| 29 } | 29 } |
| 30 | 30 |
| 31 SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cr opRect, | 31 SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cr opRect, |
| 32 uint32_t uniqueID) | 32 uint32_t uniqueID) |
| 33 : INHERITED(0, NULL, cropRect, uniqueID) | 33 : INHERITED(0, NULL, cropRect, uniqueID) |
| 34 , fShader(s) { | 34 , fShader(s) { |
| 35 SkASSERT(s); | 35 SkASSERT(s); |
| 36 s->ref(); | 36 SkSafeRef(s); |
|
sugoi1
2014/10/29 15:26:12
This class' destructor calls SkSafeUnref(), so the
reed1
2014/10/29 15:43:39
How did we get called with a NULL. Is this guy onl
sugoi1
2014/10/29 18:21:00
Done.
| |
| 37 } | 37 } |
| 38 | 38 |
| 39 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | 39 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 40 SkRectShaderImageFilter::SkRectShaderImageFilter(SkReadBuffer& buffer) | 40 SkRectShaderImageFilter::SkRectShaderImageFilter(SkReadBuffer& buffer) |
| 41 : INHERITED(0, buffer) { | 41 : INHERITED(0, buffer) { |
| 42 fShader = buffer.readShader(); | 42 fShader = buffer.readShader(); |
| 43 } | 43 } |
| 44 #endif | 44 #endif |
| 45 | 45 |
| 46 SkFlattenable* SkRectShaderImageFilter::CreateProc(SkReadBuffer& buffer) { | 46 SkFlattenable* SkRectShaderImageFilter::CreateProc(SkReadBuffer& buffer) { |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 71 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), | 71 SkAutoTUnref<SkBaseDevice> device(proxy->createDevice(bounds.width(), |
| 72 bounds.height())); | 72 bounds.height())); |
| 73 if (NULL == device.get()) { | 73 if (NULL == device.get()) { |
| 74 return false; | 74 return false; |
| 75 } | 75 } |
| 76 SkCanvas canvas(device.get()); | 76 SkCanvas canvas(device.get()); |
| 77 | 77 |
| 78 SkPaint paint; | 78 SkPaint paint; |
| 79 SkMatrix matrix(ctx.ctm()); | 79 SkMatrix matrix(ctx.ctm()); |
| 80 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to p())); | 80 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to p())); |
| 81 paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matrix))->unref() ; | 81 SkSafeUnref(paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matri x))); |
|
sugoi1
2014/10/29 15:26:12
If fShader can be NULL, then SkShader::CreateLocal
| |
| 82 | 82 |
| 83 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo unds.height())); | 83 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo unds.height())); |
| 84 canvas.drawRect(rect, paint); | 84 canvas.drawRect(rect, paint); |
| 85 | 85 |
| 86 *result = device.get()->accessBitmap(false); | 86 *result = device.get()->accessBitmap(false); |
| 87 offset->fX = bounds.fLeft; | 87 offset->fX = bounds.fLeft; |
| 88 offset->fY = bounds.fTop; | 88 offset->fY = bounds.fTop; |
| 89 return true; | 89 return true; |
| 90 } | 90 } |
| OLD | NEW |