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 13 matching lines...) Expand all Loading... |
24 #else | 24 #else |
25 uint32_t flags = CropRect::kHasAll_CropEdge; | 25 uint32_t flags = CropRect::kHasAll_CropEdge; |
26 if (rect.width() == 0 || rect.height() == 0) { | 26 if (rect.width() == 0 || rect.height() == 0) { |
27 flags = 0x0; | 27 flags = 0x0; |
28 } | 28 } |
29 CropRect cropRect(rect, flags); | 29 CropRect cropRect(rect, flags); |
30 #endif | 30 #endif |
31 return SkNEW_ARGS(SkRectShaderImageFilter, (s, &cropRect)); | 31 return SkNEW_ARGS(SkRectShaderImageFilter, (s, &cropRect)); |
32 } | 32 } |
33 | 33 |
| 34 SkRectShaderImageFilter* SkRectShaderImageFilter::Create(SkShader* s, const Crop
Rect* cropRect) { |
| 35 SkASSERT(s); |
| 36 return SkNEW_ARGS(SkRectShaderImageFilter, (s, cropRect)); |
| 37 } |
| 38 |
34 SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cr
opRect) | 39 SkRectShaderImageFilter::SkRectShaderImageFilter(SkShader* s, const CropRect* cr
opRect) |
35 : INHERITED(NULL, cropRect) | 40 : INHERITED(NULL, cropRect) |
36 , fShader(s) { | 41 , fShader(s) { |
37 SkASSERT(s); | 42 SkASSERT(s); |
38 s->ref(); | 43 s->ref(); |
39 } | 44 } |
40 | 45 |
41 SkRectShaderImageFilter::SkRectShaderImageFilter(SkFlattenableReadBuffer& buffer
) | 46 SkRectShaderImageFilter::SkRectShaderImageFilter(SkFlattenableReadBuffer& buffer
) |
42 : INHERITED(buffer) { | 47 : INHERITED(buffer) { |
43 fShader = buffer.readFlattenableT<SkShader>(); | 48 fShader = buffer.readFlattenableT<SkShader>(); |
(...skipping 28 matching lines...) Expand all Loading... |
72 SkMatrix matrix; | 77 SkMatrix matrix; |
73 matrix.setTranslate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop
)); | 78 matrix.setTranslate(-SkIntToScalar(bounds.fLeft), -SkIntToScalar(bounds.fTop
)); |
74 fShader->setLocalMatrix(matrix); | 79 fShader->setLocalMatrix(matrix); |
75 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo
unds.height())); | 80 SkRect rect = SkRect::MakeWH(SkIntToScalar(bounds.width()), SkIntToScalar(bo
unds.height())); |
76 canvas.drawRect(rect, paint); | 81 canvas.drawRect(rect, paint); |
77 *result = device.get()->accessBitmap(false); | 82 *result = device.get()->accessBitmap(false); |
78 offset->fX += bounds.fLeft; | 83 offset->fX += bounds.fLeft; |
79 offset->fY += bounds.fTop; | 84 offset->fY += bounds.fTop; |
80 return true; | 85 return true; |
81 } | 86 } |
OLD | NEW |