diff options
author | 2015-02-19 20:00:33 -0800 | |
---|---|---|
committer | 2015-02-19 20:00:33 -0800 | |
commit | b92b706dfdd68958f0fec76f8f5e0b7590798907 (patch) | |
tree | 6eb910a3adc08240f03c03499cbabe8da936d903 /src/core/SkBitmapProcState.cpp | |
parent | 56f4ace232b78dccbe77daf30b7c95ea9d5c8a83 (diff) |
Revert of Make SkPixelRef::isLocked() debug-only, remove related dead code. (patchset #1 id:1 of https://codereview.chromium.org/940083002/)
Reason for revert:
Broke callers in chrome
../../skia/ext/platform_canvas_unittest.cc:421:56: error: no member named 'isLocked' in 'SkPixelRef'
EXPECT_TRUE(platform_bitmap->GetBitmap().pixelRef()->isLocked());
Original issue's description:
> Make SkPixelRef::isLocked() debug-only, remove related dead code.
>
> DM's okay locally with no diffs, no failures.
>
> BUG=skia:
>
> Committed: https://skia.googlesource.com/skia/+/8e65712486c66108677a9b0a55ad3e7ca94db555
TBR=reed@google.com,mtklein@google.com,mtklein@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Review URL: https://codereview.chromium.org/940323003
Diffstat (limited to 'src/core/SkBitmapProcState.cpp')
-rw-r--r-- | src/core/SkBitmapProcState.cpp | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/src/core/SkBitmapProcState.cpp b/src/core/SkBitmapProcState.cpp index 335924fc35..81c14a2ffd 100644 --- a/src/core/SkBitmapProcState.cpp +++ b/src/core/SkBitmapProcState.cpp @@ -241,12 +241,43 @@ void SkBitmapProcState::processMediumRequest() { } } +static bool get_locked_pixels(const SkBitmap& src, int pow2, SkBitmap* dst) { + SkPixelRef* pr = src.pixelRef(); + if (pr && pr->decodeInto(pow2, dst)) { + return true; + } + + /* + * If decodeInto() fails, it is possibe that we have an old subclass that + * does not, or cannot, implement that. In that case we fall back to the + * older protocol of having the pixelRef handle the caching for us. + */ + *dst = src; + dst->lockPixels(); + return SkToBool(dst->getPixels()); +} + bool SkBitmapProcState::lockBaseBitmap() { - // TODO(reed): use bitmap cache here? - fScaledBitmap = fOrigBitmap; - fScaledBitmap.lockPixels(); - if (NULL == fScaledBitmap.getPixels()) { - return false; + SkPixelRef* pr = fOrigBitmap.pixelRef(); + + if (pr->isLocked() || !pr->implementsDecodeInto()) { + // fast-case, no need to look in our cache + fScaledBitmap = fOrigBitmap; + fScaledBitmap.lockPixels(); + if (NULL == fScaledBitmap.getPixels()) { + return false; + } + } else { + if (!SkBitmapCache::Find(fOrigBitmap, 1, 1, &fScaledBitmap)) { + if (!get_locked_pixels(fOrigBitmap, 0, &fScaledBitmap)) { + return false; + } + + // TODO: if fScaled comes back at a different width/height than fOrig, + // we need to update the matrix we are using to sample from this guy. + + SkBitmapCache::Add(fOrigBitmap, 1, 1, fScaledBitmap); + } } fBitmap = &fScaledBitmap; return true; @@ -356,7 +387,7 @@ bool SkBitmapProcState::chooseProcs(const SkMatrix& inv, const SkPaint& paint) { fShaderProc16 = NULL; fSampleProc32 = NULL; fSampleProc16 = NULL; - + // recompute the triviality of the matrix here because we may have // changed it! @@ -530,10 +561,10 @@ bool SkBitmapProcState::chooseScanlineProcs(bool trivialMatrix, bool clampClamp, fShaderProc32 = this->chooseShaderProc32(); } } - + // see if our platform has any accelerated overrides this->platformProcs(); - + return true; } |