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

Side by Side Diff: src/core/SkImageFilter.cpp

Issue 582963002: Solo gp (Closed) Base URL: https://skia.googlesource.com/skia.git@no_peb
Patch Set: rebase Created 6 years, 3 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/core/SkColorFilter.cpp ('k') | src/core/SkLocalMatrixShader.h » ('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 "SkImageFilter.h" 8 #include "SkImageFilter.h"
9 9
10 #include "SkBitmap.h" 10 #include "SkBitmap.h"
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 } 220 }
221 } 221 }
222 } 222 }
223 223
224 bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const Context&, 224 bool SkImageFilter::onFilterImage(Proxy*, const SkBitmap&, const Context&,
225 SkBitmap*, SkIPoint*) const { 225 SkBitmap*, SkIPoint*) const {
226 return false; 226 return false;
227 } 227 }
228 228
229 bool SkImageFilter::canFilterImageGPU() const { 229 bool SkImageFilter::canFilterImageGPU() const {
230 return this->asNewEffect(NULL, NULL, SkMatrix::I(), SkIRect()); 230 return this->asFragmentProcessor(NULL, NULL, SkMatrix::I(), SkIRect());
231 } 231 }
232 232
233 bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont ext& ctx, 233 bool SkImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Cont ext& ctx,
234 SkBitmap* result, SkIPoint* offset) const { 234 SkBitmap* result, SkIPoint* offset) const {
235 #if SK_SUPPORT_GPU 235 #if SK_SUPPORT_GPU
236 SkBitmap input = src; 236 SkBitmap input = src;
237 SkASSERT(fInputCount == 1); 237 SkASSERT(fInputCount == 1);
238 SkIPoint srcOffset = SkIPoint::Make(0, 0); 238 SkIPoint srcOffset = SkIPoint::Make(0, 0);
239 if (this->getInput(0) && 239 if (this->getInput(0) &&
240 !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffse t)) { 240 !this->getInput(0)->getInputResultGPU(proxy, src, ctx, &input, &srcOffse t)) {
(...skipping 15 matching lines...) Expand all
256 desc.fConfig = kRGBA_8888_GrPixelConfig; 256 desc.fConfig = kRGBA_8888_GrPixelConfig;
257 257
258 GrAutoScratchTexture dst(context, desc); 258 GrAutoScratchTexture dst(context, desc);
259 if (NULL == dst.texture()) { 259 if (NULL == dst.texture()) {
260 return false; 260 return false;
261 } 261 }
262 GrContext::AutoMatrix am; 262 GrContext::AutoMatrix am;
263 am.setIdentity(context); 263 am.setIdentity(context);
264 GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget()); 264 GrContext::AutoRenderTarget art(context, dst.texture()->asRenderTarget());
265 GrContext::AutoClip acs(context, dstRect); 265 GrContext::AutoClip acs(context, dstRect);
266 GrEffect* effect; 266 GrFragmentProcessor* fp;
267 offset->fX = bounds.left(); 267 offset->fX = bounds.left();
268 offset->fY = bounds.top(); 268 offset->fY = bounds.top();
269 bounds.offset(-srcOffset); 269 bounds.offset(-srcOffset);
270 SkMatrix matrix(ctx.ctm()); 270 SkMatrix matrix(ctx.ctm());
271 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to p())); 271 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to p()));
272 this->asNewEffect(&effect, srcTexture, matrix, bounds); 272 this->asFragmentProcessor(&fp, srcTexture, matrix, bounds);
273 SkASSERT(effect); 273 SkASSERT(fp);
274 GrPaint paint; 274 GrPaint paint;
275 paint.addColorEffect(effect)->unref(); 275 paint.addColorProcessor(fp)->unref();
276 context->drawRectToRect(paint, dstRect, srcRect); 276 context->drawRectToRect(paint, dstRect, srcRect);
277 277
278 SkAutoTUnref<GrTexture> resultTex(dst.detach()); 278 SkAutoTUnref<GrTexture> resultTex(dst.detach());
279 WrapTexture(resultTex, bounds.width(), bounds.height(), result); 279 WrapTexture(resultTex, bounds.width(), bounds.height(), result);
280 return true; 280 return true;
281 #else 281 #else
282 return false; 282 return false;
283 #endif 283 #endif
284 } 284 }
285 285
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 bounds.join(rect); 358 bounds.join(rect);
359 } 359 }
360 } 360 }
361 361
362 // don't modify dst until now, so we don't accidentally change it in the 362 // don't modify dst until now, so we don't accidentally change it in the
363 // loop, but then return false on the next filter. 363 // loop, but then return false on the next filter.
364 *dst = bounds; 364 *dst = bounds;
365 return true; 365 return true;
366 } 366 }
367 367
368 bool SkImageFilter::asNewEffect(GrEffect**, GrTexture*, const SkMatrix&, const S kIRect&) const { 368 bool SkImageFilter::asFragmentProcessor(GrFragmentProcessor**, GrTexture*, const SkMatrix&,
369 const SkIRect&) const {
369 return false; 370 return false;
370 } 371 }
371 372
372 bool SkImageFilter::asColorFilter(SkColorFilter**) const { 373 bool SkImageFilter::asColorFilter(SkColorFilter**) const {
373 return false; 374 return false;
374 } 375 }
375 376
376 #if SK_SUPPORT_GPU 377 #if SK_SUPPORT_GPU
377 378
378 void SkImageFilter::WrapTexture(GrTexture* texture, int width, int height, SkBit map* result) { 379 void SkImageFilter::WrapTexture(GrTexture* texture, int width, int height, SkBit map* result) {
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 } // namespace 493 } // namespace
493 494
494 SkImageFilter::Cache* SkImageFilter::Cache::Create(size_t maxBytes) { 495 SkImageFilter::Cache* SkImageFilter::Cache::Create(size_t maxBytes) {
495 return SkNEW_ARGS(CacheImpl, (maxBytes)); 496 return SkNEW_ARGS(CacheImpl, (maxBytes));
496 } 497 }
497 498
498 SkImageFilter::Cache* SkImageFilter::Cache::Get() { 499 SkImageFilter::Cache* SkImageFilter::Cache::Get() {
499 SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache); 500 SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache);
500 return cache.get(); 501 return cache.get();
501 } 502 }
OLDNEW
« no previous file with comments | « src/core/SkColorFilter.cpp ('k') | src/core/SkLocalMatrixShader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698