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