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 27 matching lines...) Expand all Loading... |
38 | 38 |
39 SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cr
opRect) | 39 SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cr
opRect) |
40 : INHERITED(NULL, cropRect) | 40 : INHERITED(NULL, cropRect) |
41 , fShader(s) { | 41 , fShader(s) { |
42 SkASSERT(s); | 42 SkASSERT(s); |
43 s->ref(); | 43 s->ref(); |
44 } | 44 } |
45 | 45 |
46 SkRectShaderImageFilter::SkRectShaderImageFilter(SkFlattenableReadBuffer& buffer
) | 46 SkRectShaderImageFilter::SkRectShaderImageFilter(SkFlattenableReadBuffer& buffer
) |
47 : INHERITED(buffer) { | 47 : INHERITED(buffer) { |
48 fShader = buffer.readFlattenableT<SkShader>(); | 48 fShader = buffer.readShader(); |
49 } | 49 } |
50 | 50 |
51 void SkRectShaderImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { | 51 void SkRectShaderImageFilter::flatten(SkFlattenableWriteBuffer& buffer) const { |
52 this->INHERITED::flatten(buffer); | 52 this->INHERITED::flatten(buffer); |
53 | 53 |
54 buffer.writeFlattenable(fShader); | 54 buffer.writeFlattenable(fShader); |
55 } | 55 } |
56 | 56 |
57 SkRectShaderImageFilter::~SkRectShaderImageFilter() { | 57 SkRectShaderImageFilter::~SkRectShaderImageFilter() { |
58 SkSafeUnref(fShader); | 58 SkSafeUnref(fShader); |
(...skipping 18 matching lines...) Expand all Loading... |
77 SkMatrix matrix; | 77 SkMatrix matrix; |
78 matrix.setTranslate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop
)); | 78 matrix.setTranslate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop
)); |
79 fShader->setLocalMatrix(matrix); | 79 fShader->setLocalMatrix(matrix); |
80 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo
unds.height())); | 80 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo
unds.height())); |
81 canvas.drawRect(rect, paint); | 81 canvas.drawRect(rect, paint); |
82 *result = device.get()->accessBitmap(false); | 82 *result = device.get()->accessBitmap(false); |
83 offset->fX += bounds.fLeft; | 83 offset->fX += bounds.fLeft; |
84 offset->fY += bounds.fTop; | 84 offset->fY += bounds.fTop; |
85 return true; | 85 return true; |
86 } | 86 } |
OLD | NEW |