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

Unified Diff: Source/core/platform/image-decoders/ImageDecoder.cpp

Issue 15466003: Remove image decoder down sampling (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Remove virtual setSize() from GIF decoder Created 7 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
Index: Source/core/platform/image-decoders/ImageDecoder.cpp
diff --git a/Source/core/platform/image-decoders/ImageDecoder.cpp b/Source/core/platform/image-decoders/ImageDecoder.cpp
index 37cd9327dd39379d68debb4ab690c28d772a5dd3..b98e45a3fa8f93c9a9ccfaba21d6749ce34e02fa 100644
--- a/Source/core/platform/image-decoders/ImageDecoder.cpp
+++ b/Source/core/platform/image-decoders/ImageDecoder.cpp
@@ -1,5 +1,4 @@
/*
- * Copyright (C) 2008-2009 Torch Mobile, Inc.
* Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
*
* This library is free software; you can redistribute it and/or
@@ -139,92 +138,6 @@ void ImageDecoder::reportMemoryUsage(MemoryObjectInfo* memoryObjectInfo) const
MemoryClassInfo info(memoryObjectInfo, this, PlatformMemoryTypes::Image);
info.addMember(m_data, "data");
info.addMember(m_frameBufferCache, "frameBufferCache");
- info.addMember(m_scaledColumns, "scaledColumns");
- info.addMember(m_scaledRows, "scaledRows");
-}
-
-// FIXME: don't add any more code below this line: the code below is related to
-// ENABLE(IMAGE_DECODER_DOWN_SAMPLING), a feature chrome does not use, and does
-// test, and does not need. It is therefore earmarked for removal.
-
-enum MatchType {
- Exact,
- UpperBound,
- LowerBound
-};
-
-inline void fillScaledValues(Vector<int>& scaledValues, double scaleRate, int length)
-{
- double inflateRate = 1. / scaleRate;
- scaledValues.reserveCapacity(static_cast<int>(length * scaleRate + 0.5));
- for (int scaledIndex = 0; ; ++scaledIndex) {
- int index = static_cast<int>(scaledIndex * inflateRate + 0.5);
- if (index >= length)
- break;
- scaledValues.append(index);
- }
-}
-
-template <MatchType type> static int getScaledValue(const Vector<int>& scaledValues, int valueToMatch, int searchStart)
-{
- if (scaledValues.isEmpty())
- return valueToMatch;
-
- const int* dataStart = scaledValues.data();
- const int* dataEnd = dataStart + scaledValues.size();
- const int* matched = std::lower_bound(dataStart + searchStart, dataEnd, valueToMatch);
- switch (type) {
- case Exact:
- return matched != dataEnd && *matched == valueToMatch ? matched - dataStart : -1;
- case LowerBound:
- return matched != dataEnd && *matched == valueToMatch ? matched - dataStart : matched - dataStart - 1;
- case UpperBound:
- default:
- return matched != dataEnd ? matched - dataStart : -1;
- }
-}
-
-void ImageDecoder::prepareScaleDataIfNecessary()
-{
- m_scaled = false;
- m_scaledColumns.clear();
- m_scaledRows.clear();
-
- int width = size().width();
- int height = size().height();
- int numPixels = height * width;
- if (m_maxNumPixels <= 0 || numPixels <= m_maxNumPixels)
- return;
-
- m_scaled = true;
- double scale = sqrt(m_maxNumPixels / (double)numPixels);
- fillScaledValues(m_scaledColumns, scale, width);
- fillScaledValues(m_scaledRows, scale, height);
-}
-
-int ImageDecoder::upperBoundScaledX(int origX, int searchStart)
-{
- return getScaledValue<UpperBound>(m_scaledColumns, origX, searchStart);
-}
-
-int ImageDecoder::lowerBoundScaledX(int origX, int searchStart)
-{
- return getScaledValue<LowerBound>(m_scaledColumns, origX, searchStart);
-}
-
-int ImageDecoder::upperBoundScaledY(int origY, int searchStart)
-{
- return getScaledValue<UpperBound>(m_scaledRows, origY, searchStart);
-}
-
-int ImageDecoder::lowerBoundScaledY(int origY, int searchStart)
-{
- return getScaledValue<LowerBound>(m_scaledRows, origY, searchStart);
-}
-
-int ImageDecoder::scaledY(int origY, int searchStart)
-{
- return getScaledValue<Exact>(m_scaledRows, origY, searchStart);
}
} // namespace WebCore
« no previous file with comments | « Source/core/platform/image-decoders/ImageDecoder.h ('k') | Source/core/platform/image-decoders/gif/GIFImageDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698