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

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

Issue 638403003: Remove uses of GrAutoScratchTexture. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: rebase Created 6 years, 2 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/SkGpuBlurUtils.cpp ('k') | src/effects/SkXfermodeImageFilter.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 "SkMorphologyImageFilter.h" 8 #include "SkMorphologyImageFilter.h"
9 #include "SkBitmap.h" 9 #include "SkBitmap.h"
10 #include "SkColorPriv.h" 10 #include "SkColorPriv.h"
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
496 radius, 496 radius,
497 morphType))->unref(); 497 morphType))->unref();
498 context->drawRectToRect(paint, SkRect::Make(dstRect), SkRect::Make(srcRect)) ; 498 context->drawRectToRect(paint, SkRect::Make(dstRect), SkRect::Make(srcRect)) ;
499 } 499 }
500 500
501 bool apply_morphology(const SkBitmap& input, 501 bool apply_morphology(const SkBitmap& input,
502 const SkIRect& rect, 502 const SkIRect& rect,
503 GrMorphologyEffect::MorphologyType morphType, 503 GrMorphologyEffect::MorphologyType morphType,
504 SkISize radius, 504 SkISize radius,
505 SkBitmap* dst) { 505 SkBitmap* dst) {
506 GrTexture* srcTexture = input.getTexture(); 506 SkAutoTUnref<GrTexture> srcTexture(SkRef(input.getTexture()));
507 SkASSERT(srcTexture); 507 SkASSERT(srcTexture);
508 GrContext* context = srcTexture->getContext(); 508 GrContext* context = srcTexture->getContext();
509 srcTexture->ref();
510 SkAutoTUnref<GrTexture> src(srcTexture);
511 509
512 GrContext::AutoMatrix am; 510 GrContext::AutoMatrix am;
513 am.setIdentity(context); 511 am.setIdentity(context);
514 512
515 GrContext::AutoClip acs(context, SkRect::MakeWH(SkIntToScalar(srcTexture->wi dth()), 513 GrContext::AutoClip acs(context, SkRect::MakeWH(SkIntToScalar(srcTexture->wi dth()),
516 SkIntToScalar(srcTexture->he ight()))); 514 SkIntToScalar(srcTexture->he ight())));
517 515
518 SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height()); 516 SkIRect dstRect = SkIRect::MakeWH(rect.width(), rect.height());
519 GrTextureDesc desc; 517 GrTextureDesc desc;
520 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit; 518 desc.fFlags = kRenderTarget_GrTextureFlagBit | kNoStencil_GrTextureFlagBit;
521 desc.fWidth = rect.width(); 519 desc.fWidth = rect.width();
522 desc.fHeight = rect.height(); 520 desc.fHeight = rect.height();
523 desc.fConfig = kSkia8888_GrPixelConfig; 521 desc.fConfig = kSkia8888_GrPixelConfig;
524 SkIRect srcRect = rect; 522 SkIRect srcRect = rect;
525 523
526 if (radius.fWidth > 0) { 524 if (radius.fWidth > 0) {
527 GrAutoScratchTexture ast(context, desc); 525 GrTexture* texture = context->refScratchTexture(desc, GrContext::kApprox _ScratchTexMatch);
528 if (NULL == ast.texture()) { 526 if (NULL == texture) {
529 return false; 527 return false;
530 } 528 }
531 GrContext::AutoRenderTarget art(context, ast.texture()->asRenderTarget() ); 529 GrContext::AutoRenderTarget art(context, texture->asRenderTarget());
532 apply_morphology_pass(context, src, srcRect, dstRect, radius.fWidth, 530 apply_morphology_pass(context, srcTexture, srcRect, dstRect, radius.fWid th,
533 morphType, Gr1DKernelEffect::kX_Direction); 531 morphType, Gr1DKernelEffect::kX_Direction);
534 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, 532 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom,
535 dstRect.width(), radius.fHeight); 533 dstRect.width(), radius.fHeight);
536 context->clear(&clearRect, GrMorphologyEffect::kErode_MorphologyType == morphType ? 534 context->clear(&clearRect, GrMorphologyEffect::kErode_MorphologyType == morphType ?
537 SK_ColorWHITE : 535 SK_ColorWHITE :
538 SK_ColorTRANSPARENT, false); 536 SK_ColorTRANSPARENT, false);
539 src.reset(ast.detach()); 537 srcTexture.reset(texture);
540 srcRect = dstRect; 538 srcRect = dstRect;
541 } 539 }
542 if (radius.fHeight > 0) { 540 if (radius.fHeight > 0) {
543 GrAutoScratchTexture ast(context, desc); 541 GrTexture* texture = context->refScratchTexture(desc, GrContext::kApprox _ScratchTexMatch);
544 if (NULL == ast.texture()) { 542 if (NULL == texture) {
545 return false; 543 return false;
546 } 544 }
547 GrContext::AutoRenderTarget art(context, ast.texture()->asRenderTarget() ); 545 GrContext::AutoRenderTarget art(context, texture->asRenderTarget());
548 apply_morphology_pass(context, src, srcRect, dstRect, radius.fHeight, 546 apply_morphology_pass(context, srcTexture, srcRect, dstRect, radius.fHei ght,
549 morphType, Gr1DKernelEffect::kY_Direction); 547 morphType, Gr1DKernelEffect::kY_Direction);
550 src.reset(ast.detach()); 548 srcTexture.reset(texture);
551 } 549 }
552 SkImageFilter::WrapTexture(src, rect.width(), rect.height(), dst); 550 SkImageFilter::WrapTexture(srcTexture, rect.width(), rect.height(), dst);
553 return true; 551 return true;
554 } 552 }
555 553
556 }; 554 };
557 555
558 bool SkMorphologyImageFilter::filterImageGPUGeneric(bool dilate, 556 bool SkMorphologyImageFilter::filterImageGPUGeneric(bool dilate,
559 Proxy* proxy, 557 Proxy* proxy,
560 const SkBitmap& src, 558 const SkBitmap& src,
561 const Context& ctx, 559 const Context& ctx,
562 SkBitmap* result, 560 SkBitmap* result,
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
603 SkBitmap* result, SkIPoint* offset) con st { 601 SkBitmap* result, SkIPoint* offset) con st {
604 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); 602 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset);
605 } 603 }
606 604
607 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx, 605 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
608 SkBitmap* result, SkIPoint* offset) cons t { 606 SkBitmap* result, SkIPoint* offset) cons t {
609 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); 607 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset);
610 } 608 }
611 609
612 #endif 610 #endif
OLDNEW
« no previous file with comments | « src/effects/SkGpuBlurUtils.cpp ('k') | src/effects/SkXfermodeImageFilter.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698