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

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

Issue 1321353002: Limit lifetime of GrDrawContext objects (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT Created 5 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
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 555 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 desc.fWidth = rect.width(); 566 desc.fWidth = rect.width();
567 desc.fHeight = rect.height(); 567 desc.fHeight = rect.height();
568 desc.fConfig = kSkia8888_GrPixelConfig; 568 desc.fConfig = kSkia8888_GrPixelConfig;
569 SkIRect srcRect = rect; 569 SkIRect srcRect = rect;
570 570
571 if (radius.fWidth > 0) { 571 if (radius.fWidth > 0) {
572 GrTexture* scratch = context->textureProvider()->createApproxTexture(des c); 572 GrTexture* scratch = context->textureProvider()->createApproxTexture(des c);
573 if (nullptr == scratch) { 573 if (nullptr == scratch) {
574 return false; 574 return false;
575 } 575 }
576 GrDrawContext* dstDrawContext = context->drawContext(); 576 SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
577 if (!dstDrawContext) { 577 if (!dstDrawContext) {
578 return false; 578 return false;
579 } 579 }
580 580
581 apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, s rcTexture, 581 apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, s rcTexture,
582 srcRect, dstRect, radius.fWidth, morphType, 582 srcRect, dstRect, radius.fWidth, morphType,
583 Gr1DKernelEffect::kX_Direction); 583 Gr1DKernelEffect::kX_Direction);
584 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom, 584 SkIRect clearRect = SkIRect::MakeXYWH(dstRect.fLeft, dstRect.fBottom,
585 dstRect.width(), radius.fHeight); 585 dstRect.width(), radius.fHeight);
586 GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphT ype ? 586 GrColor clearColor = GrMorphologyEffect::kErode_MorphologyType == morphT ype ?
587 SK_ColorWHITE : 587 SK_ColorWHITE :
588 SK_ColorTRANSPARENT; 588 SK_ColorTRANSPARENT;
589 dstDrawContext->clear(scratch->asRenderTarget(), &clearRect, clearColor, false); 589 dstDrawContext->clear(scratch->asRenderTarget(), &clearRect, clearColor, false);
590 590
591 srcTexture.reset(scratch); 591 srcTexture.reset(scratch);
592 srcRect = dstRect; 592 srcRect = dstRect;
593 } 593 }
594 if (radius.fHeight > 0) { 594 if (radius.fHeight > 0) {
595 GrTexture* scratch = context->textureProvider()->createApproxTexture(des c); 595 GrTexture* scratch = context->textureProvider()->createApproxTexture(des c);
596 if (nullptr == scratch) { 596 if (nullptr == scratch) {
597 return false; 597 return false;
598 } 598 }
599 GrDrawContext* dstDrawContext = context->drawContext(); 599 SkAutoTUnref<GrDrawContext> dstDrawContext(context->drawContext());
600 if (!dstDrawContext) { 600 if (!dstDrawContext) {
601 return false; 601 return false;
602 } 602 }
603 603
604 apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, s rcTexture, 604 apply_morphology_pass(dstDrawContext, scratch->asRenderTarget(), clip, s rcTexture,
605 srcRect, dstRect, radius.fHeight, morphType, 605 srcRect, dstRect, radius.fHeight, morphType,
606 Gr1DKernelEffect::kY_Direction); 606 Gr1DKernelEffect::kY_Direction);
607 607
608 srcTexture.reset(scratch); 608 srcTexture.reset(scratch);
609 } 609 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 SkBitmap* result, SkIPoint* offset) con st { 662 SkBitmap* result, SkIPoint* offset) con st {
663 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset); 663 return this->filterImageGPUGeneric(true, proxy, src, ctx, result, offset);
664 } 664 }
665 665
666 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx, 666 bool SkErodeImageFilter::filterImageGPU(Proxy* proxy, const SkBitmap& src, const Context& ctx,
667 SkBitmap* result, SkIPoint* offset) cons t { 667 SkBitmap* result, SkIPoint* offset) cons t {
668 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset); 668 return this->filterImageGPUGeneric(false, proxy, src, ctx, result, offset);
669 } 669 }
670 670
671 #endif 671 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698