From 9bf380ce7f848dfb5886dd52b82746521454b739 Mon Sep 17 00:00:00 2001 From: "robertphillips@google.com" Date: Thu, 25 Jul 2013 12:10:42 +0000 Subject: drawBitmap* cleanup https://codereview.chromium.org/19977003/ git-svn-id: http://skia.googlecode.com/svn/trunk@10342 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/gpu/SkGpuDevice.cpp | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) (limited to 'src/gpu/SkGpuDevice.cpp') diff --git a/src/gpu/SkGpuDevice.cpp b/src/gpu/SkGpuDevice.cpp index 4456f513c4..000efee84b 100644 --- a/src/gpu/SkGpuDevice.cpp +++ b/src/gpu/SkGpuDevice.cpp @@ -1078,21 +1078,10 @@ bool SkGpuDevice::shouldTileBitmap(const SkBitmap& bitmap, void SkGpuDevice::drawBitmap(const SkDraw& draw, const SkBitmap& bitmap, - const SkIRect* srcRectPtr, const SkMatrix& m, const SkPaint& paint) { - - SkRect tmp; - SkRect* tmpPtr = NULL; - - // convert from SkIRect to SkRect - if (NULL != srcRectPtr) { - tmp.set(*srcRectPtr); - tmpPtr = &tmp; - } - // We cannot call drawBitmapRect here since 'm' could be anything - this->drawBitmapCommon(draw, bitmap, tmpPtr, m, paint); + this->drawBitmapCommon(draw, bitmap, NULL, m, paint); } void SkGpuDevice::drawBitmapCommon(const SkDraw& draw, @@ -1216,9 +1205,8 @@ void SkGpuDevice::drawTiledBitmap(const SkBitmap& bitmap, } } -namespace { - -bool hasAlignedSamples(const SkRect& srcRect, const SkRect& transformedRect) { +static bool has_aligned_samples(const SkRect& srcRect, + const SkRect& transformedRect) { // detect pixel disalignment if (SkScalarAbs(SkScalarRoundToScalar(transformedRect.left()) - transformedRect.left()) < COLOR_BLEED_TOLERANCE && @@ -1233,11 +1221,12 @@ bool hasAlignedSamples(const SkRect& srcRect, const SkRect& transformedRect) { return false; } -bool mayColorBleed(const SkRect& srcRect, const SkRect& transformedRect, - const SkMatrix& m) { - // Only gets called if hasAlignedSamples returned false. +static bool may_color_bleed(const SkRect& srcRect, + const SkRect& transformedRect, + const SkMatrix& m) { + // Only gets called if has_aligned_samples returned false. // So we can assume that sampling is axis aligned but not texel aligned. - GrAssert(!hasAlignedSamples(srcRect, transformedRect)); + GrAssert(!has_aligned_samples(srcRect, transformedRect)); SkRect innerSrcRect(srcRect), innerTransformedRect, outerTransformedRect(transformedRect); innerSrcRect.inset(SK_ScalarHalf, SK_ScalarHalf); @@ -1257,7 +1246,6 @@ bool mayColorBleed(const SkRect& srcRect, const SkRect& transformedRect, return inner != outer; } -} // unnamed namespace /* * This is called by drawBitmap(), which has to handle images that may be too @@ -1294,20 +1282,19 @@ void SkGpuDevice::internalDrawBitmap(const SkBitmap& bitmap, // Need texture domain if drawing a sub rect. needsTextureDomain = srcRect.width() < bitmap.width() || srcRect.height() < bitmap.height(); - if (m.rectStaysRect() && fContext->getMatrix().rectStaysRect()) { + if (needsTextureDomain && m.rectStaysRect() && fContext->getMatrix().rectStaysRect()) { // sampling is axis-aligned SkRect transformedRect; SkMatrix srcToDeviceMatrix(m); srcToDeviceMatrix.postConcat(fContext->getMatrix()); srcToDeviceMatrix.mapRect(&transformedRect, srcRect); - if (hasAlignedSamples(srcRect, transformedRect)) { + if (has_aligned_samples(srcRect, transformedRect)) { // We could also turn off filtering here (but we already did a cache lookup with // params). needsTextureDomain = false; } else { - needsTextureDomain = needsTextureDomain && - mayColorBleed(srcRect, transformedRect, m); + needsTextureDomain = may_color_bleed(srcRect, transformedRect, m); } } } -- cgit v1.2.3