| 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 "SkMergeImageFilter.h" | 8 #include "SkMergeImageFilter.h" |
| 9 | 9 |
| 10 #include "SkCanvas.h" | 10 #include "SkCanvas.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 if (!bounds.intersect(ctx.clipBounds())) { | 91 if (!bounds.intersect(ctx.clipBounds())) { |
| 92 return nullptr; | 92 return nullptr; |
| 93 } | 93 } |
| 94 | 94 |
| 95 const int x0 = bounds.left(); | 95 const int x0 = bounds.left(); |
| 96 const int y0 = bounds.top(); | 96 const int y0 = bounds.top(); |
| 97 | 97 |
| 98 SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(), | 98 SkImageInfo info = SkImageInfo::MakeN32(bounds.width(), bounds.height(), |
| 99 kPremul_SkAlphaType); | 99 kPremul_SkAlphaType); |
| 100 | 100 |
| 101 SkAutoTUnref<SkSpecialSurface> surf(source->newSurface(info)); | 101 sk_sp<SkSpecialSurface> surf(source->makeSurface(info)); |
| 102 if (!surf) { | 102 if (!surf) { |
| 103 return nullptr; | 103 return nullptr; |
| 104 } | 104 } |
| 105 | 105 |
| 106 SkCanvas* canvas = surf->getCanvas(); | 106 SkCanvas* canvas = surf->getCanvas(); |
| 107 SkASSERT(canvas); | 107 SkASSERT(canvas); |
| 108 | 108 |
| 109 canvas->clear(0x0); | 109 canvas->clear(0x0); |
| 110 | 110 |
| 111 // Composite all of the filter inputs. | 111 // Composite all of the filter inputs. |
| 112 for (int i = 0; i < inputCount; ++i) { | 112 for (int i = 0; i < inputCount; ++i) { |
| 113 if (!inputs[i]) { | 113 if (!inputs[i]) { |
| 114 continue; | 114 continue; |
| 115 } | 115 } |
| 116 | 116 |
| 117 SkPaint paint; | 117 SkPaint paint; |
| 118 if (fModes) { | 118 if (fModes) { |
| 119 paint.setXfermodeMode((SkXfermode::Mode)fModes[i]); | 119 paint.setXfermodeMode((SkXfermode::Mode)fModes[i]); |
| 120 } | 120 } |
| 121 | 121 |
| 122 inputs[i]->draw(canvas, | 122 inputs[i]->draw(canvas, |
| 123 SkIntToScalar(offsets[i].x() - x0), SkIntToScalar(offset
s[i].y() - y0), | 123 SkIntToScalar(offsets[i].x() - x0), SkIntToScalar(offset
s[i].y() - y0), |
| 124 &paint); | 124 &paint); |
| 125 } | 125 } |
| 126 | 126 |
| 127 offset->fX = bounds.left(); | 127 offset->fX = bounds.left(); |
| 128 offset->fY = bounds.top(); | 128 offset->fY = bounds.top(); |
| 129 return surf->newImageSnapshot(); | 129 return surf->makeImageSnapshot().release(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 SkFlattenable* SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) { | 132 SkFlattenable* SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) { |
| 133 Common common; | 133 Common common; |
| 134 if (!common.unflatten(buffer, -1)) { | 134 if (!common.unflatten(buffer, -1)) { |
| 135 return nullptr; | 135 return nullptr; |
| 136 } | 136 } |
| 137 | 137 |
| 138 const int count = common.inputCount(); | 138 const int count = common.inputCount(); |
| 139 bool hasModes = buffer.readBool(); | 139 bool hasModes = buffer.readBool(); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 170 for (int i = 0; i < this->countInputs(); ++i) { | 170 for (int i = 0; i < this->countInputs(); ++i) { |
| 171 SkImageFilter* filter = this->getInput(i); | 171 SkImageFilter* filter = this->getInput(i); |
| 172 str->appendf("%d: (", i); | 172 str->appendf("%d: (", i); |
| 173 filter->toString(str); | 173 filter->toString(str); |
| 174 str->appendf(")"); | 174 str->appendf(")"); |
| 175 } | 175 } |
| 176 | 176 |
| 177 str->append(")"); | 177 str->append(")"); |
| 178 } | 178 } |
| 179 #endif | 179 #endif |
| OLD | NEW |