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

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

Issue 1225923010: Refugee from Dead Machine 4: MDB Monster Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Last update from dead machine Created 4 years, 7 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/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkGradientShader.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 2013 The Android Open Source Project 2 * Copyright 2013 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 "SkXfermodeImageFilter.h" 8 #include "SkXfermodeImageFilter.h"
9 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkDevice.h" 10 #include "SkDevice.h"
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 this->getInput(1)->toString(str); 113 this->getInput(1)->toString(str);
114 str->appendf(")"); 114 str->appendf(")");
115 } 115 }
116 str->append(")"); 116 str->append(")");
117 } 117 }
118 #endif 118 #endif
119 119
120 #if SK_SUPPORT_GPU 120 #if SK_SUPPORT_GPU
121 121
122 bool SkXfermodeImageFilter::canFilterImageGPU() const { 122 bool SkXfermodeImageFilter::canFilterImageGPU() const {
123 return fMode && fMode->asFragmentProcessor(nullptr, nullptr) && !cropRectIsS et(); 123 return fMode && fMode->asFragmentProcessor(nullptr, nullptr, NULL) && !cropR ectIsSet();
124 } 124 }
125 125
126 bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy, 126 bool SkXfermodeImageFilter::filterImageGPU(Proxy* proxy,
127 const SkBitmap& src, 127 const SkBitmap& src,
128 const Context& ctx, 128 const Context& ctx,
129 SkBitmap* result, 129 SkBitmap* result, SkIPoint* offset) c onst {
130 SkIPoint* offset) const {
131 SkBitmap background = src; 130 SkBitmap background = src;
132 SkIPoint backgroundOffset = SkIPoint::Make(0, 0); 131 SkIPoint backgroundOffset = SkIPoint::Make(0, 0);
133 if (!this->filterInputGPU(0, proxy, src, ctx, &background, &backgroundOffset )) { 132 if (!this->filterInputGPU(0, proxy, src, ctx, &background, &backgroundOffset )) {
134 return false; 133 return false;
135 } 134 }
136 135
137 GrTexture* backgroundTex = background.getTexture(); 136 GrTexture* backgroundTex = background.getTexture();
138 if (nullptr == backgroundTex) { 137 if (nullptr == backgroundTex) {
139 SkASSERT(false); 138 SkASSERT(false);
140 return false; 139 return false;
(...skipping 17 matching lines...) Expand all
158 auto constraint = GrTextureProvider::FromImageFilter(ctx.sizeConstraint()); 157 auto constraint = GrTextureProvider::FromImageFilter(ctx.sizeConstraint());
159 SkAutoTUnref<GrTexture> dst(context->textureProvider()->createTexture(desc, constraint)); 158 SkAutoTUnref<GrTexture> dst(context->textureProvider()->createTexture(desc, constraint));
160 if (!dst) { 159 if (!dst) {
161 return false; 160 return false;
162 } 161 }
163 162
164 GrPaint paint; 163 GrPaint paint;
165 SkMatrix bgMatrix; 164 SkMatrix bgMatrix;
166 bgMatrix.setIDiv(backgroundTex->width(), backgroundTex->height()); 165 bgMatrix.setIDiv(backgroundTex->width(), backgroundTex->height());
167 SkAutoTUnref<const GrFragmentProcessor> bgFP( 166 SkAutoTUnref<const GrFragmentProcessor> bgFP(
168 GrSimpleTextureEffect::Create(backgroundTex, bgMatrix)); 167 GrSimpleTextureEffect::Create(backgroundTex, bgMatrix,
169 if (!fMode || !fMode->asFragmentProcessor(&xferFP, bgFP)) { 168 kLocal_GrCoordSet, dst->asRenderTarget())) ;
169 if (!fMode || !fMode->asFragmentProcessor(&xferFP, bgFP, dst->asRenderTarget ())) {
170 // canFilterImageGPU() should've taken care of this 170 // canFilterImageGPU() should've taken care of this
171 SkASSERT(false); 171 SkASSERT(false);
172 return false; 172 return false;
173 } 173 }
174 174
175 SkMatrix foregroundMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(foreg roundTex); 175 SkMatrix foregroundMatrix = GrCoordTransform::MakeDivByTextureWHMatrix(foreg roundTex);
176 foregroundMatrix.preTranslate(SkIntToScalar(backgroundOffset.fX-foregroundOf fset.fX), 176 foregroundMatrix.preTranslate(SkIntToScalar(backgroundOffset.fX-foregroundOf fset.fX),
177 SkIntToScalar(backgroundOffset.fY-foregroundOf fset.fY)); 177 SkIntToScalar(backgroundOffset.fY-foregroundOf fset.fY));
178 178
179 179
180 SkRect srcRect; 180 SkRect srcRect;
181 src.getBounds(&srcRect); 181 src.getBounds(&srcRect);
182 182
183 SkAutoTUnref<const GrFragmentProcessor> foregroundDomain(GrTextureDomainEffe ct::Create( 183 SkAutoTUnref<const GrFragmentProcessor> foregroundDomain(GrTextureDomainEffe ct::Create(
184 foregroundTex, foregroundMatrix, 184 foregroundTex, foregroundMatrix,
185 GrTextureDomain::MakeTexelDomain(foregroundTex, foreground.bounds()), 185 GrTextureDomain::MakeTexelDomain(foregroundTex, foreground.bounds()),
186 GrTextureDomain::kDecal_Mode, 186 GrTextureDomain::kDecal_Mode,
187 GrTextureParams::kNone_FilterMode) 187 GrTextureParams::kNone_FilterMode,
188 ); 188 kLocal_GrCoordSet,
189 dst->asRenderTarget()));
189 190
190 paint.addColorFragmentProcessor(foregroundDomain.get()); 191 paint.addColorFragmentProcessor(foregroundDomain.get());
191 if (xferFP) { 192 if (xferFP) {
192 paint.addColorFragmentProcessor(xferFP)->unref(); 193 paint.addColorFragmentProcessor(xferFP)->unref();
193 } 194 }
194 195
195 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(dst->asRenderTa rget())); 196 SkAutoTUnref<GrDrawContext> drawContext(context->drawContext(dst->asRenderTa rget()));
196 if (!drawContext) { 197 if (!drawContext) {
197 return false; 198 return false;
198 } 199 }
199 200
200 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), srcRect); 201 drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), srcRect);
201 202
202 offset->fX = backgroundOffset.fX; 203 offset->fX = backgroundOffset.fX;
203 offset->fY = backgroundOffset.fY; 204 offset->fY = backgroundOffset.fY;
204 WrapTexture(dst, src.width(), src.height(), result); 205 WrapTexture(dst, src.width(), src.height(), result);
205 return true; 206 return true;
206 } 207 }
207 208
208 #endif 209 #endif
209 210
OLDNEW
« no previous file with comments | « src/effects/SkTableColorFilter.cpp ('k') | src/effects/gradients/SkGradientShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698