OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 The Android Open Source Project | 2 * Copyright 2012 The Android Open Source Project |
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 "SkColorFilterImageFilter.h" | 8 #include "SkColorFilterImageFilter.h" |
9 | 9 |
10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); | 45 SK_IMAGEFILTER_UNFLATTEN_COMMON(common, 1); |
46 sk_sp<SkColorFilter> cf(buffer.readColorFilter()); | 46 sk_sp<SkColorFilter> cf(buffer.readColorFilter()); |
47 return Create(cf.get(), common.getInput(0), &common.cropRect()); | 47 return Create(cf.get(), common.getInput(0), &common.cropRect()); |
48 } | 48 } |
49 | 49 |
50 void SkColorFilterImageFilter::flatten(SkWriteBuffer& buffer) const { | 50 void SkColorFilterImageFilter::flatten(SkWriteBuffer& buffer) const { |
51 this->INHERITED::flatten(buffer); | 51 this->INHERITED::flatten(buffer); |
52 buffer.writeFlattenable(fColorFilter.get()); | 52 buffer.writeFlattenable(fColorFilter.get()); |
53 } | 53 } |
54 | 54 |
55 SkSpecialImage* SkColorFilterImageFilter::onFilterImage(SkSpecialImage* source,
const Context& ctx, | 55 sk_sp<SkSpecialImage> SkColorFilterImageFilter::onFilterImage(SkSpecialImage* so
urce, |
56 SkIPoint* offset) const
{ | 56 const Context& ctx
, |
| 57 SkIPoint* offset)
const { |
57 SkIPoint inputOffset = SkIPoint::Make(0, 0); | 58 SkIPoint inputOffset = SkIPoint::Make(0, 0); |
58 SkAutoTUnref<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputO
ffset)); | 59 sk_sp<SkSpecialImage> input(this->filterInput(0, source, ctx, &inputOffset))
; |
59 if (!input) { | 60 if (!input) { |
60 return nullptr; | 61 return nullptr; |
61 } | 62 } |
62 | 63 |
63 SkIRect bounds; | 64 SkIRect bounds; |
64 const SkIRect inputBounds = SkIRect::MakeXYWH(inputOffset.fX, inputOffset.fY
, | 65 const SkIRect inputBounds = SkIRect::MakeXYWH(inputOffset.fX, inputOffset.fY
, |
65 input->width(), input->height(
)); | 66 input->width(), input->height(
)); |
66 if (!this->applyCropRect(ctx, inputBounds, &bounds)) { | 67 if (!this->applyCropRect(ctx, inputBounds, &bounds)) { |
67 return nullptr; | 68 return nullptr; |
68 } | 69 } |
(...skipping 15 matching lines...) Expand all Loading... |
84 paint.setXfermodeMode(SkXfermode::kSrc_Mode); | 85 paint.setXfermodeMode(SkXfermode::kSrc_Mode); |
85 paint.setColorFilter(fColorFilter); | 86 paint.setColorFilter(fColorFilter); |
86 | 87 |
87 input->draw(canvas, | 88 input->draw(canvas, |
88 SkIntToScalar(inputOffset.fX - bounds.fLeft), | 89 SkIntToScalar(inputOffset.fX - bounds.fLeft), |
89 SkIntToScalar(inputOffset.fY - bounds.fTop), | 90 SkIntToScalar(inputOffset.fY - bounds.fTop), |
90 &paint); | 91 &paint); |
91 | 92 |
92 offset->fX = bounds.fLeft; | 93 offset->fX = bounds.fLeft; |
93 offset->fY = bounds.fTop; | 94 offset->fY = bounds.fTop; |
94 return surf->makeImageSnapshot().release(); | 95 return surf->makeImageSnapshot(); |
95 } | 96 } |
96 | 97 |
97 bool SkColorFilterImageFilter::onIsColorFilterNode(SkColorFilter** filter) const
{ | 98 bool SkColorFilterImageFilter::onIsColorFilterNode(SkColorFilter** filter) const
{ |
98 SkASSERT(1 == this->countInputs()); | 99 SkASSERT(1 == this->countInputs()); |
99 if (!this->cropRectIsSet()) { | 100 if (!this->cropRectIsSet()) { |
100 if (filter) { | 101 if (filter) { |
101 *filter = SkRef(fColorFilter.get()); | 102 *filter = SkRef(fColorFilter.get()); |
102 } | 103 } |
103 return true; | 104 return true; |
104 } | 105 } |
(...skipping 16 matching lines...) Expand all Loading... |
121 if (this->getInput(0)) { | 122 if (this->getInput(0)) { |
122 this->getInput(0)->toString(str); | 123 this->getInput(0)->toString(str); |
123 } | 124 } |
124 | 125 |
125 str->appendf(") color filter: "); | 126 str->appendf(") color filter: "); |
126 fColorFilter->toString(str); | 127 fColorFilter->toString(str); |
127 | 128 |
128 str->append(")"); | 129 str->append(")"); |
129 } | 130 } |
130 #endif | 131 #endif |
OLD | NEW |