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

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

Issue 105003005: Revert of Teach Skia to use discardable memory (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years 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') | Source/platform/graphics/ImageFrameGenerator.h » ('j') | 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 17567e564e6fb6b0a40842c866dacb7bd4bd4cca..795ade041e30a4c8ec8f75eb7a9d4580cd97d5d1 100644
--- a/Source/platform/graphics/DeferredImageDecoder.cpp
+++ b/Source/platform/graphics/DeferredImageDecoder.cpp
@@ -26,9 +26,8 @@
#include "config.h"
#include "platform/graphics/DeferredImageDecoder.h"
-#include "platform/graphics/DecodingImageGenerator.h"
#include "platform/graphics/LazyDecodingPixelRef.h"
-#include "third_party/skia/include/core/SkImageInfo.h"
+
#include "wtf/PassOwnPtr.h"
namespace WebCore {
@@ -38,13 +37,9 @@
// 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)
@@ -73,18 +68,12 @@
{
return bitmap.pixelRef()
&& bitmap.pixelRef()->getURI()
- && (!memcmp(bitmap.pixelRef()->getURI(), labelLazyDecoded, sizeof(labelLazyDecoded))
- || !memcmp(bitmap.pixelRef()->getURI(), labelDiscardable, sizeof(labelDiscardable)));
+ && !memcmp(bitmap.pixelRef()->getURI(), labelLazyDecoded, sizeof(labelLazyDecoded));
}
void DeferredImageDecoder::setEnabled(bool enabled)
{
s_enabled = enabled;
-}
-
-void DeferredImageDecoder::setSkiaDiscardableMemoryEnabled(bool enabled)
-{
- s_skiaDiscardableMemoryEnabled = enabled;
}
String DeferredImageDecoder::filenameExtension() const
@@ -219,7 +208,7 @@
m_lazyDecodedFrames.resize(m_actualDecoder->frameCount());
for (size_t i = previousSize; i < m_lazyDecodedFrames.size(); ++i) {
OwnPtr<ImageFrame> frame(adoptPtr(new ImageFrame()));
- frame->setSkBitmap(createBitmap(i));
+ frame->setSkBitmap(createLazyDecodingBitmap(i));
frame->setDuration(m_actualDecoder->frameDurationAtIndex(i));
frame->setStatus(m_actualDecoder->frameIsCompleteAtIndex(i) ? ImageFrame::FrameComplete : ImageFrame::FramePartial);
m_lazyDecodedFrames[i] = frame.release();
@@ -235,36 +224,6 @@
m_actualDecoder.clear();
m_data = nullptr;
}
-}
-
-// Creates either a SkBitmap backed by SkDiscardablePixelRef or a SkBitmap using the
-// legacy LazyDecodingPixelRef.
-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)
-{
- 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 = kBGRA_8888_SkColorType;
- info.fAlphaType = frameHasAlphaAtIndex(index) ? kPremul_SkAlphaType : kOpaque_SkAlphaType;
-
- SkBitmap bitmap;
- bool installed = SkInstallDiscardablePixelRef(new DecodingImageGenerator(m_frameGenerator, info, index), &bitmap);
- ASSERT_UNUSED(installed, installed);
- bitmap.pixelRef()->setURI(labelDiscardable);
- return bitmap;
}
SkBitmap DeferredImageDecoder::createLazyDecodingBitmap(size_t index)
« no previous file with comments | « Source/platform/graphics/DeferredImageDecoder.h ('k') | Source/platform/graphics/ImageFrameGenerator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698