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 26 matching lines...) Expand all Loading... |
37 | 37 |
38 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING | 38 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
39 SkRectShaderImageFilter::SkRectShaderImageFilter(SkReadBuffer& buffer) | 39 SkRectShaderImageFilter::SkRectShaderImageFilter(SkReadBuffer& buffer) |
40 : INHERITED(0, buffer) { | 40 : INHERITED(0, buffer) { |
41 fShader = buffer.readShader(); | 41 fShader = buffer.readShader(); |
42 } | 42 } |
43 #endif | 43 #endif |
44 | 44 |
45 SkFlattenable* SkRectShaderImageFilter::CreateProc(SkReadBuffer& buffer) { | 45 SkFlattenable* SkRectShaderImageFilter::CreateProc(SkReadBuffer& buffer) { |
46 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0); | 46 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0); |
47 return Create(buffer.readShader(), &common.cropRect()); | 47 SkAutoTUnref<SkShader> shader(buffer.readShader()); |
| 48 return Create(shader.get(), &common.cropRect()); |
48 } | 49 } |
49 | 50 |
50 void SkRectShaderImageFilter::flatten(SkWriteBuffer& buffer) const { | 51 void SkRectShaderImageFilter::flatten(SkWriteBuffer& buffer) const { |
51 this->INHERITED::flatten(buffer); | 52 this->INHERITED::flatten(buffer); |
52 buffer.writeFlattenable(fShader); | 53 buffer.writeFlattenable(fShader); |
53 } | 54 } |
54 | 55 |
55 SkRectShaderImageFilter::~SkRectShaderImageFilter() { | 56 SkRectShaderImageFilter::~SkRectShaderImageFilter() { |
56 SkSafeUnref(fShader); | 57 SkSafeUnref(fShader); |
57 } | 58 } |
(...skipping 21 matching lines...) Expand all Loading... |
79 paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matrix))->unref()
; | 80 paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matrix))->unref()
; |
80 | 81 |
81 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo
unds.height())); | 82 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo
unds.height())); |
82 canvas.drawRect(rect, paint); | 83 canvas.drawRect(rect, paint); |
83 | 84 |
84 *result = device.get()->accessBitmap(false); | 85 *result = device.get()->accessBitmap(false); |
85 offset->fX = bounds.fLeft; | 86 offset->fX = bounds.fLeft; |
86 offset->fY = bounds.fTop; | 87 offset->fY = bounds.fTop; |
87 return true; | 88 return true; |
88 } | 89 } |
OLD | NEW |