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

Unified Diff: Source/platform/graphics/DeferredImageDecoder.cpp

Issue 303033004: Enable Skia discardable memory path on Android (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/platform/graphics/DeferredImageDecoder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/DeferredImageDecoder.cpp
diff --git a/Source/platform/graphics/DeferredImageDecoder.cpp b/Source/platform/graphics/DeferredImageDecoder.cpp
index abc9f8d929ae10bc1dfe637dd903060f0d4f809e..4f3822ee4e45856193d1fd68afefb19e605bda06 100644
--- a/Source/platform/graphics/DeferredImageDecoder.cpp
+++ b/Source/platform/graphics/DeferredImageDecoder.cpp
@@ -36,16 +36,12 @@ namespace WebCore {
namespace {
-// URI label for a lazily decoded SkPixelRef.
-const char labelLazyDecoded[] = "lazy";
-
// URI label for SkDiscardablePixelRef.
const char labelDiscardable[] = "discardable";
} // namespace
bool DeferredImageDecoder::s_enabled = false;
-bool DeferredImageDecoder::s_skiaDiscardableMemoryEnabled = false;
DeferredImageDecoder::DeferredImageDecoder(PassOwnPtr<ImageDecoder> actualDecoder)
: m_allDataReceived(false)
@@ -77,21 +73,14 @@ bool DeferredImageDecoder::isLazyDecoded(const SkBitmap& bitmap)
{
return bitmap.pixelRef()
&& bitmap.pixelRef()->getURI()
- && (!memcmp(bitmap.pixelRef()->getURI(), labelLazyDecoded, sizeof(labelLazyDecoded))
- || !memcmp(bitmap.pixelRef()->getURI(), labelDiscardable, sizeof(labelDiscardable)));
+ && !memcmp(bitmap.pixelRef()->getURI(), labelDiscardable, sizeof(labelDiscardable));
}
void DeferredImageDecoder::setEnabled(bool enabled)
{
s_enabled = enabled;
-#if !OS(ANDROID)
- // FIXME: This code is temporary to enable discardable memory for
- // non-Android platforms. In the future all platforms will be
- // the same and we can remove this code.
- s_skiaDiscardableMemoryEnabled = enabled;
if (enabled)
ImageDecodingStore::setImageCachingEnabled(false);
-#endif
}
bool DeferredImageDecoder::enabled()
@@ -273,18 +262,8 @@ void DeferredImageDecoder::prepareLazyDecodedFrames()
}
}
-// Creates either a SkBitmap backed by SkDiscardablePixelRef or a SkBitmap using the
-// legacy LazyDecodingPixelRef.
Stephen White 2014/05/29 20:07:44 Out of curiosity, does this mean we can also remov
-SkBitmap DeferredImageDecoder::createBitmap(size_t index)
-{
- // This code is temporary until the transition to SkDiscardablePixelRef is complete.
- if (s_skiaDiscardableMemoryEnabled)
- return createSkiaDiscardableBitmap(index);
- return createLazyDecodingBitmap(index);
-}
-
// Creates a SkBitmap that is backed by SkDiscardablePixelRef.
-SkBitmap DeferredImageDecoder::createSkiaDiscardableBitmap(size_t index)
+SkBitmap DeferredImageDecoder::createBitmap(size_t index)
{
IntSize decodedSize = m_actualDecoder->decodedSize();
ASSERT(decodedSize.width() > 0);
@@ -293,7 +272,11 @@ SkBitmap DeferredImageDecoder::createSkiaDiscardableBitmap(size_t index)
SkImageInfo info;
info.fWidth = decodedSize.width();
info.fHeight = decodedSize.height();
+#if SK_B32_SHIFT // Little-endian RGBA pixels. (Android)
reveman 2014/05/29 03:30:55 I assume this is the reason my previous patch fail
+ info.fColorType = kRGBA_8888_SkColorType;
+#else
info.fColorType = kBGRA_8888_SkColorType;
+#endif
info.fAlphaType = kPremul_SkAlphaType;
SkBitmap bitmap;
@@ -305,34 +288,6 @@ SkBitmap DeferredImageDecoder::createSkiaDiscardableBitmap(size_t index)
return bitmap;
}
-SkBitmap DeferredImageDecoder::createLazyDecodingBitmap(size_t index)
-{
- IntSize decodedSize = m_actualDecoder->decodedSize();
- ASSERT(decodedSize.width() > 0);
- ASSERT(decodedSize.height() > 0);
-
- SkImageInfo info;
- info.fWidth = decodedSize.width();
- info.fHeight = decodedSize.height();
- info.fColorType = kPMColor_SkColorType;
- info.fAlphaType = kPremul_SkAlphaType;
-
- // Creates a lazily decoded SkPixelRef that references the entire image without scaling.
- SkBitmap bitmap;
- bitmap.setConfig(info);
- bitmap.setPixelRef(new LazyDecodingPixelRef(info, m_frameGenerator, index))->unref();
-
- // Use the URI to identify this as a lazily decoded SkPixelRef of type LazyDecodingPixelRef.
- // FIXME: It would be more useful to give the actual image URI.
- bitmap.pixelRef()->setURI(labelLazyDecoded);
-
- // Inform the bitmap that we will never change the pixels. This is a performance hint
- // subsystems that may try to cache this bitmap (e.g. pictures, pipes, gpu, pdf, etc.)
- bitmap.setImmutable();
-
- return bitmap;
-}
-
bool DeferredImageDecoder::hotSpot(IntPoint& hotSpot) const
{
// TODO: Implement.
« no previous file with comments | « Source/platform/graphics/DeferredImageDecoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698