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 16 matching lines...) Expand all Loading... |
27 SkASSERT(s); | 27 SkASSERT(s); |
28 return s ? SkNEW_ARGS(SkRectShaderImageFilter, (s, cropRect, uniqueID)) : NU
LL; | 28 return s ? SkNEW_ARGS(SkRectShaderImageFilter, (s, cropRect, uniqueID)) : NU
LL; |
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(SkRef(s)) { | 34 , fShader(SkRef(s)) { |
35 } | 35 } |
36 | 36 |
| 37 #ifdef SK_SUPPORT_LEGACY_DEEPFLATTENING |
| 38 SkRectShaderImageFilter::SkRectShaderImageFilter(SkReadBuffer& buffer) |
| 39 : INHERITED(0, buffer) { |
| 40 fShader = buffer.readShader(); |
| 41 } |
| 42 #endif |
| 43 |
37 SkFlattenable* SkRectShaderImageFilter::CreateProc(SkReadBuffer& buffer) { | 44 SkFlattenable* SkRectShaderImageFilter::CreateProc(SkReadBuffer& buffer) { |
38 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0); | 45 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 0); |
39 SkAutoTUnref<SkShader> shader(buffer.readShader()); | 46 SkAutoTUnref<SkShader> shader(buffer.readShader()); |
40 return Create(shader.get(), &common.cropRect(), common.uniqueID()); | 47 return Create(shader.get(), &common.cropRect(), common.uniqueID()); |
41 } | 48 } |
42 | 49 |
43 void SkRectShaderImageFilter::flatten(SkWriteBuffer& buffer) const { | 50 void SkRectShaderImageFilter::flatten(SkWriteBuffer& buffer) const { |
44 this->INHERITED::flatten(buffer); | 51 this->INHERITED::flatten(buffer); |
45 buffer.writeFlattenable(fShader); | 52 buffer.writeFlattenable(fShader); |
46 } | 53 } |
(...skipping 25 matching lines...) Expand all Loading... |
72 SkSafeUnref(paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matri
x))); | 79 SkSafeUnref(paint.setShader(SkShader::CreateLocalMatrixShader(fShader, matri
x))); |
73 | 80 |
74 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo
unds.height())); | 81 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo
unds.height())); |
75 canvas.drawRect(rect, paint); | 82 canvas.drawRect(rect, paint); |
76 | 83 |
77 *result = device.get()->accessBitmap(false); | 84 *result = device.get()->accessBitmap(false); |
78 offset->fX = bounds.fLeft; | 85 offset->fX = bounds.fLeft; |
79 offset->fY = bounds.fTop; | 86 offset->fY = bounds.fTop; |
80 return true; | 87 return true; |
81 } | 88 } |
OLD | NEW |