Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Side by Side Diff: src/effects/SkMergeImageFilter.cpp

Issue 1826893002: Switch new SkImageFilter internal methods over to sk_sp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Change method name to drawSpriteWithFilter Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/effects/SkImageSource.cpp ('k') | src/effects/SkOffsetImageFilter.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 this->initModes(modes); 50 this->initModes(modes);
51 } 51 }
52 52
53 SkMergeImageFilter::~SkMergeImageFilter() { 53 SkMergeImageFilter::~SkMergeImageFilter() {
54 54
55 if (fModes != SkTCast<uint8_t*>(fStorage)) { 55 if (fModes != SkTCast<uint8_t*>(fStorage)) {
56 sk_free(fModes); 56 sk_free(fModes);
57 } 57 }
58 } 58 }
59 59
60 SkSpecialImage* SkMergeImageFilter::onFilterImage(SkSpecialImage* source, const Context& ctx, 60 sk_sp<SkSpecialImage> SkMergeImageFilter::onFilterImage(SkSpecialImage* source, const Context& ctx,
61 SkIPoint* offset) const { 61 SkIPoint* offset) const {
62 int inputCount = this->countInputs(); 62 int inputCount = this->countInputs();
63 if (inputCount < 1) { 63 if (inputCount < 1) {
64 return nullptr; 64 return nullptr;
65 } 65 }
66 66
67 SkIRect bounds; 67 SkIRect bounds;
68 bounds.setEmpty(); 68 bounds.setEmpty();
69 69
70 SkAutoTDeleteArray<SkAutoTUnref<SkSpecialImage>> inputs( 70 SkAutoTDeleteArray<sk_sp<SkSpecialImage>> inputs(new sk_sp<SkSpecialImage>[i nputCount]);
71 new SkAutoTUnref<SkSpecialIm age>[inputCount]);
72 SkAutoTDeleteArray<SkIPoint> offsets(new SkIPoint[inputCount]); 71 SkAutoTDeleteArray<SkIPoint> offsets(new SkIPoint[inputCount]);
73 72
74 // Filter all of the inputs. 73 // Filter all of the inputs.
75 for (int i = 0; i < inputCount; ++i) { 74 for (int i = 0; i < inputCount; ++i) {
76 offsets[i].setZero(); 75 offsets[i].setZero();
77 inputs[i].reset(this->filterInput(i, source, ctx, &offsets[i])); 76 inputs[i] = this->filterInput(i, source, ctx, &offsets[i]);
78 if (!inputs[i]) { 77 if (!inputs[i]) {
79 continue; 78 continue;
80 } 79 }
81 const SkIRect inputBounds = SkIRect::MakeXYWH(offsets[i].fX, offsets[i]. fY, 80 const SkIRect inputBounds = SkIRect::MakeXYWH(offsets[i].fX, offsets[i]. fY,
82 inputs[i]->width(), inputs [i]->height()); 81 inputs[i]->width(), inputs [i]->height());
83 bounds.join(inputBounds); 82 bounds.join(inputBounds);
84 } 83 }
85 if (bounds.isEmpty()) { 84 if (bounds.isEmpty()) {
86 return nullptr; 85 return nullptr;
87 } 86 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 paint.setXfermodeMode((SkXfermode::Mode)fModes[i]); 118 paint.setXfermodeMode((SkXfermode::Mode)fModes[i]);
120 } 119 }
121 120
122 inputs[i]->draw(canvas, 121 inputs[i]->draw(canvas,
123 SkIntToScalar(offsets[i].x() - x0), SkIntToScalar(offset s[i].y() - y0), 122 SkIntToScalar(offsets[i].x() - x0), SkIntToScalar(offset s[i].y() - y0),
124 &paint); 123 &paint);
125 } 124 }
126 125
127 offset->fX = bounds.left(); 126 offset->fX = bounds.left();
128 offset->fY = bounds.top(); 127 offset->fY = bounds.top();
129 return surf->makeImageSnapshot().release(); 128 return surf->makeImageSnapshot();
130 } 129 }
131 130
132 SkFlattenable* SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) { 131 SkFlattenable* SkMergeImageFilter::CreateProc(SkReadBuffer& buffer) {
133 Common common; 132 Common common;
134 if (!common.unflatten(buffer, -1)) { 133 if (!common.unflatten(buffer, -1)) {
135 return nullptr; 134 return nullptr;
136 } 135 }
137 136
138 const int count = common.inputCount(); 137 const int count = common.inputCount();
139 bool hasModes = buffer.readBool(); 138 bool hasModes = buffer.readBool();
(...skipping 30 matching lines...) Expand all
170 for (int i = 0; i < this->countInputs(); ++i) { 169 for (int i = 0; i < this->countInputs(); ++i) {
171 SkImageFilter* filter = this->getInput(i); 170 SkImageFilter* filter = this->getInput(i);
172 str->appendf("%d: (", i); 171 str->appendf("%d: (", i);
173 filter->toString(str); 172 filter->toString(str);
174 str->appendf(")"); 173 str->appendf(")");
175 } 174 }
176 175
177 str->append(")"); 176 str->append(")");
178 } 177 }
179 #endif 178 #endif
OLDNEW
« no previous file with comments | « src/effects/SkImageSource.cpp ('k') | src/effects/SkOffsetImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698