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

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

Issue 936943002: Pass clip to context (Closed) Base URL: https://skia.googlesource.com/skia.git@pass_down_rendertarget
Patch Set: feedback inc Created 5 years, 10 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
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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 desc.fWidth = bounds.width(); 250 desc.fWidth = bounds.width();
251 desc.fHeight = bounds.height(); 251 desc.fHeight = bounds.height();
252 desc.fConfig = kRGBA_8888_GrPixelConfig; 252 desc.fConfig = kRGBA_8888_GrPixelConfig;
253 253
254 SkAutoTUnref<GrTexture> dst( 254 SkAutoTUnref<GrTexture> dst(
255 context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch)); 255 context->refScratchTexture(desc, GrContext::kApprox_ScratchTexMatch));
256 if (!dst) { 256 if (!dst) {
257 return false; 257 return false;
258 } 258 }
259 259
260 GrContext::AutoClip acs(context, dstRect); 260 // setup new clip
261 GrClip clip(dstRect);
262
261 GrFragmentProcessor* fp; 263 GrFragmentProcessor* fp;
262 offset->fX = bounds.left(); 264 offset->fX = bounds.left();
263 offset->fY = bounds.top(); 265 offset->fY = bounds.top();
264 bounds.offset(-srcOffset); 266 bounds.offset(-srcOffset);
265 SkMatrix matrix(ctx.ctm()); 267 SkMatrix matrix(ctx.ctm());
266 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to p())); 268 matrix.postTranslate(SkIntToScalar(-bounds.left()), SkIntToScalar(-bounds.to p()));
267 if (this->asFragmentProcessor(&fp, srcTexture, matrix, bounds)) { 269 if (this->asFragmentProcessor(&fp, srcTexture, matrix, bounds)) {
268 SkASSERT(fp); 270 SkASSERT(fp);
269 GrPaint paint; 271 GrPaint paint;
270 paint.addColorProcessor(fp)->unref(); 272 paint.addColorProcessor(fp)->unref();
271 context->drawNonAARectToRect(dst->asRenderTarget(), paint, SkMatrix::I() , dstRect, srcRect); 273 context->drawNonAARectToRect(dst->asRenderTarget(), clip, paint, SkMatri x::I(), dstRect,
274 srcRect);
272 275
273 WrapTexture(dst, bounds.width(), bounds.height(), result); 276 WrapTexture(dst, bounds.width(), bounds.height(), result);
274 return true; 277 return true;
275 } 278 }
276 #endif 279 #endif
277 return false; 280 return false;
278 } 281 }
279 282
280 bool SkImageFilter::applyCropRect(const Context& ctx, const SkBitmap& src, 283 bool SkImageFilter::applyCropRect(const Context& ctx, const SkBitmap& src,
281 const SkIPoint& srcOffset, SkIRect* bounds) co nst { 284 const SkIPoint& srcOffset, SkIRect* bounds) co nst {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref(); 378 result->setPixelRef(SkNEW_ARGS(SkGrPixelRef, (info, texture)))->unref();
376 } 379 }
377 380
378 bool SkImageFilter::getInputResultGPU(SkImageFilter::Proxy* proxy, 381 bool SkImageFilter::getInputResultGPU(SkImageFilter::Proxy* proxy,
379 const SkBitmap& src, const Context& ctx, 382 const SkBitmap& src, const Context& ctx,
380 SkBitmap* result, SkIPoint* offset) const { 383 SkBitmap* result, SkIPoint* offset) const {
381 // Ensure that GrContext calls under filterImage and filterImageGPU below wi ll see an identity 384 // Ensure that GrContext calls under filterImage and filterImageGPU below wi ll see an identity
382 // matrix with no clip and that the matrix, clip, and render target set befo re this function was 385 // matrix with no clip and that the matrix, clip, and render target set befo re this function was
383 // called are restored before we return to the caller. 386 // called are restored before we return to the caller.
384 GrContext* context = src.getTexture()->getContext(); 387 GrContext* context = src.getTexture()->getContext();
385 GrContext::AutoWideOpenIdentityDraw awoid(context); 388
386 if (this->canFilterImageGPU()) { 389 if (this->canFilterImageGPU()) {
387 return this->filterImageGPU(proxy, src, ctx, result, offset); 390 return this->filterImageGPU(proxy, src, ctx, result, offset);
388 } else { 391 } else {
389 if (this->filterImage(proxy, src, ctx, result, offset)) { 392 if (this->filterImage(proxy, src, ctx, result, offset)) {
390 if (!result->getTexture()) { 393 if (!result->getTexture()) {
391 const SkImageInfo info = result->info(); 394 const SkImageInfo info = result->info();
392 if (kUnknown_SkColorType == info.colorType()) { 395 if (kUnknown_SkColorType == info.colorType()) {
393 return false; 396 return false;
394 } 397 }
395 SkAutoTUnref<GrTexture> resultTex(GrRefCachedBitmapTexture(conte xt, *result, NULL)); 398 SkAutoTUnref<GrTexture> resultTex(GrRefCachedBitmapTexture(conte xt, *result, NULL));
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
486 489
487 SkImageFilter::Cache* SkImageFilter::Cache::Create(size_t maxBytes) { 490 SkImageFilter::Cache* SkImageFilter::Cache::Create(size_t maxBytes) {
488 return SkNEW_ARGS(CacheImpl, (maxBytes)); 491 return SkNEW_ARGS(CacheImpl, (maxBytes));
489 } 492 }
490 493
491 SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache); 494 SK_DECLARE_STATIC_LAZY_PTR(SkImageFilter::Cache, cache, CreateCache);
492 495
493 SkImageFilter::Cache* SkImageFilter::Cache::Get() { 496 SkImageFilter::Cache* SkImageFilter::Cache::Get() {
494 return cache.get(); 497 return cache.get();
495 } 498 }
OLDNEW
« no previous file with comments | « include/gpu/GrContext.h ('k') | src/core/SkMaskFilter.cpp » ('j') | src/gpu/GrTextContext.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698