Diff
Modified: trunk/Source/WebCore/ChangeLog (248997 => 248998)
--- trunk/Source/WebCore/ChangeLog 2019-08-22 06:16:08 UTC (rev 248997)
+++ trunk/Source/WebCore/ChangeLog 2019-08-22 09:12:33 UTC (rev 248998)
@@ -1,3 +1,43 @@
+2019-08-22 Fujii Hironori <[email protected]>
+
+ Remove the dead code of ScalableImageDecoder for scaling
+ https://bugs.webkit.org/show_bug.cgi?id=200498
+
+ Reviewed by Daniel Bates.
+
+ No ports are using the down scaling feature of
+ ScalableImageDecoder now. Removed it.
+
+ No behavior change.
+
+ * platform/image-decoders/ScalableImageDecoder.cpp:
+ (WebCore::ScalableImageDecoder::prepareScaleDataIfNecessary): Deleted.
+ (WebCore::ScalableImageDecoder::upperBoundScaledX): Deleted.
+ (WebCore::ScalableImageDecoder::lowerBoundScaledX): Deleted.
+ (WebCore::ScalableImageDecoder::upperBoundScaledY): Deleted.
+ (WebCore::ScalableImageDecoder::lowerBoundScaledY): Deleted.
+ (WebCore::ScalableImageDecoder::scaledY): Deleted.
+ * platform/image-decoders/ScalableImageDecoder.h:
+ (WebCore::ScalableImageDecoder::scaledSize): Deleted.
+ * platform/image-decoders/gif/GIFImageDecoder.cpp:
+ (WebCore::GIFImageDecoder::setSize):
+ (WebCore::GIFImageDecoder::findFirstRequiredFrameToDecode):
+ (WebCore::GIFImageDecoder::haveDecodedRow):
+ (WebCore::GIFImageDecoder::frameComplete):
+ (WebCore::GIFImageDecoder::initFrameBuffer):
+ * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
+ (WebCore::JPEGImageDecoder::outputScanlines):
+ (WebCore::JPEGImageDecoder::setSize): Deleted.
+ * platform/image-decoders/jpeg/JPEGImageDecoder.h:
+ * platform/image-decoders/jpeg2000/JPEG2000ImageDecoder.cpp:
+ (WebCore::JPEG2000ImageDecoder::decode):
+ * platform/image-decoders/png/PNGImageDecoder.cpp:
+ (WebCore::PNGImageDecoder::rowAvailable):
+ (WebCore::PNGImageDecoder::initFrameBuffer):
+ (WebCore::PNGImageDecoder::frameComplete):
+ (WebCore::PNGImageDecoder::setSize): Deleted.
+ * platform/image-decoders/png/PNGImageDecoder.h:
+
2019-08-21 Jer Noble <[email protected]>
Unreviewed build fix; add a 'final' declaration on shouldOverridePauseDuringRouteChange().
Modified: trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp (248997 => 248998)
--- trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp 2019-08-22 06:16:08 UTC (rev 248997)
+++ trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.cpp 2019-08-22 09:12:33 UTC (rev 248998)
@@ -153,47 +153,6 @@
return nullptr;
}
-namespace {
-
-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> 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;
- }
-}
-
-}
-
bool ScalableImageDecoder::frameIsCompleteAtIndex(size_t index) const
{
LockHolder lockHolder(m_mutex);
@@ -264,49 +223,6 @@
return buffer->backingStore()->image();
}
-void ScalableImageDecoder::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 ScalableImageDecoder::upperBoundScaledX(int origX, int searchStart)
-{
- return getScaledValue<UpperBound>(m_scaledColumns, origX, searchStart);
-}
-
-int ScalableImageDecoder::lowerBoundScaledX(int origX, int searchStart)
-{
- return getScaledValue<LowerBound>(m_scaledColumns, origX, searchStart);
-}
-
-int ScalableImageDecoder::upperBoundScaledY(int origY, int searchStart)
-{
- return getScaledValue<UpperBound>(m_scaledRows, origY, searchStart);
-}
-
-int ScalableImageDecoder::lowerBoundScaledY(int origY, int searchStart)
-{
- return getScaledValue<LowerBound>(m_scaledRows, origY, searchStart);
-}
-
-int ScalableImageDecoder::scaledY(int origY, int searchStart)
-{
- return getScaledValue<Exact>(m_scaledRows, origY, searchStart);
-}
-
#if USE(DIRECT2D)
void ScalableImageDecoder::setTargetContext(ID2D1RenderTarget*)
{
Modified: trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.h (248997 => 248998)
--- trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.h 2019-08-22 06:16:08 UTC (rev 248997)
+++ trunk/Source/WebCore/platform/image-decoders/ScalableImageDecoder.h 2019-08-22 09:12:33 UTC (rev 248998)
@@ -98,11 +98,6 @@
IntSize size() const override { return isSizeAvailable() ? m_size : IntSize(); }
- IntSize scaledSize()
- {
- return m_scaled ? IntSize(m_scaledColumns.size(), m_scaledRows.size()) : size();
- }
-
// This will only differ from size() for ICO (where each frame is a
// different icon) or other formats where different frames are different
// sizes. This does NOT differ from size() for GIF, since decoding GIFs
@@ -197,19 +192,9 @@
Optional<IntPoint> hotSpot() const override { return WTF::nullopt; }
protected:
- void prepareScaleDataIfNecessary();
- int upperBoundScaledX(int origX, int searchStart = 0);
- int lowerBoundScaledX(int origX, int searchStart = 0);
- int upperBoundScaledY(int origY, int searchStart = 0);
- int lowerBoundScaledY(int origY, int searchStart = 0);
- int scaledY(int origY, int searchStart = 0);
-
RefPtr<SharedBuffer> m_data; // The encoded data.
Vector<ScalableImageDecoderFrame, 1> m_frameBufferCache;
mutable Lock m_mutex;
- bool m_scaled { false };
- Vector<int> m_scaledColumns;
- Vector<int> m_scaledRows;
bool m_premultiplyAlpha;
bool m_ignoreGammaAndColorProfile;
ImageOrientation m_orientation;
@@ -224,12 +209,6 @@
IntSize m_size;
EncodedDataStatus m_encodedDataStatus { EncodedDataStatus::TypeAvailable };
bool m_decodingSizeFromSetData { false };
-
- // FIXME: Evaluate the need for decoded data scaling. m_scaled,
- // m_scaledColumns and m_scaledRows are member variables that are
- // affected by this value, and are not used at all since the value
- // is negavite (see prepareScaleDataIfNecessary()).
- static const int m_maxNumPixels { -1 };
};
} // namespace WebCore
Modified: trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp (248997 => 248998)
--- trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp 2019-08-22 06:16:08 UTC (rev 248997)
+++ trunk/Source/WebCore/platform/image-decoders/gif/GIFImageDecoder.cpp 2019-08-22 09:12:33 UTC (rev 248998)
@@ -53,11 +53,7 @@
if (ScalableImageDecoder::encodedDataStatus() >= EncodedDataStatus::SizeAvailable && this->size() == size)
return true;
- if (!ScalableImageDecoder::setSize(size))
- return false;
-
- prepareScaleDataIfNecessary();
- return true;
+ return ScalableImageDecoder::setSize(size);
}
size_t GIFImageDecoder::frameCount() const
@@ -126,9 +122,6 @@
const auto* frameContext = m_reader->frameContext(i - 1);
ASSERT(frameContext);
IntRect frameRect(frameContext->xOffset, frameContext->yOffset, frameContext->width, frameContext->height);
- // We would need to scale frameRect and check whether it fills the whole scaledSize(). But
- // can check whether the original frameRect fills size() instead. If the frame fills the
- // whole area then it can be decoded without dependencies.
if (frameRect.contains({ { }, size() }))
return i;
}
@@ -216,11 +209,11 @@
// that width == (size().width() - frameContext->xOffset), so
// we must ensure we don't run off the end of either the source data or the
// row's X-coordinates.
- int xBegin = upperBoundScaledX(frameContext->xOffset);
- int yBegin = upperBoundScaledY(frameContext->yOffset + rowNumber);
- int xEnd = lowerBoundScaledX(std::min(static_cast<int>(frameContext->xOffset + width), size().width()) - 1, xBegin + 1) + 1;
- int yEnd = lowerBoundScaledY(std::min(static_cast<int>(frameContext->yOffset + rowNumber + repeatCount), size().height()) - 1, yBegin + 1) + 1;
- if (rowBuffer.isEmpty() || (xBegin < 0) || (yBegin < 0) || (xEnd <= xBegin) || (yEnd <= yBegin))
+ int xBegin = frameContext->xOffset;
+ int yBegin = frameContext->yOffset + rowNumber;
+ int xEnd = std::min(static_cast<int>(frameContext->xOffset + width), size().width());
+ int yEnd = std::min(static_cast<int>(frameContext->yOffset + rowNumber + repeatCount), size().height());
+ if (rowBuffer.isEmpty() || xEnd <= xBegin || yEnd <= yBegin)
return true;
// Get the colormap.
@@ -244,7 +237,7 @@
auto* currentAddress = buffer.backingStore()->pixelAt(xBegin, yBegin);
// Write one row's worth of data into the frame.
for (int x = xBegin; x < xEnd; ++x) {
- const unsigned char sourceValue = rowBuffer[(m_scaled ? m_scaledColumns[x] : x) - frameContext->xOffset];
+ const unsigned char sourceValue = rowBuffer[x - frameContext->xOffset];
if ((!frameContext->isTransparent || (sourceValue != frameContext->tpixel)) && (sourceValue < colorMapSize)) {
const size_t colorIndex = static_cast<size_t>(sourceValue) * 3;
buffer.backingStore()->setPixel(currentAddress, colorMap[colorIndex], colorMap[colorIndex + 1], colorMap[colorIndex + 2], 255);
@@ -287,7 +280,7 @@
// The whole frame was non-transparent, so it's possible that the entire
// resulting buffer was non-transparent, and we can setHasAlpha(false).
- if (rect.contains(IntRect(IntPoint(), scaledSize())))
+ if (rect.contains(IntRect(IntPoint(), size())))
buffer.setHasAlpha(false);
else if (frameIndex) {
// Tricky case. This frame does not have alpha only if everywhere
@@ -374,7 +367,7 @@
if (!frameIndex) {
// This is the first frame, so we're not relying on any previous data.
- if (!buffer->initialize(scaledSize(), m_premultiplyAlpha))
+ if (!buffer->initialize(size(), m_premultiplyAlpha))
return setFailed();
} else {
// The starting state for this frame depends on the previous frame's
@@ -402,8 +395,8 @@
// We want to clear the previous frame to transparent, without
// affecting pixels in the image outside of the frame.
IntRect prevRect = prevBuffer->backingStore()->frameRect();
- const IntSize& bufferSize = scaledSize();
- if (!frameIndex || prevRect.contains(IntRect(IntPoint(), scaledSize()))) {
+ const IntSize& bufferSize = size();
+ if (!frameIndex || prevRect.contains(IntRect(IntPoint(), size()))) {
// Clearing the first frame, or a frame the size of the whole
// image, results in a completely empty image.
if (!buffer->initialize(bufferSize, m_premultiplyAlpha))
@@ -424,11 +417,7 @@
if (frameRect.maxY() > size().height())
frameRect.setHeight(size().height() - frameContext->yOffset);
- int left = upperBoundScaledX(frameRect.x());
- int right = lowerBoundScaledX(frameRect.maxX(), left);
- int top = upperBoundScaledY(frameRect.y());
- int bottom = lowerBoundScaledY(frameRect.maxY(), top);
- buffer->backingStore()->setFrameRect(IntRect(left, top, right - left, bottom - top));
+ buffer->backingStore()->setFrameRect(frameRect);
// Update our status to be partially complete.
buffer->setDecodingStatus(DecodingStatus::Partial);
Modified: trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp (248997 => 248998)
--- trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp 2019-08-22 06:16:08 UTC (rev 248997)
+++ trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.cpp 2019-08-22 09:12:33 UTC (rev 248998)
@@ -502,15 +502,6 @@
JPEGImageDecoder::~JPEGImageDecoder() = default;
-bool JPEGImageDecoder::setSize(const IntSize& size)
-{
- if (!ScalableImageDecoder::setSize(size))
- return false;
-
- prepareScaleDataIfNecessary();
- return true;
-}
-
ScalableImageDecoderFrame* JPEGImageDecoder::frameBufferAtIndex(size_t index)
{
if (index)
@@ -556,12 +547,12 @@
}
}
-template <J_COLOR_SPACE colorSpace, bool isScaled>
+template <J_COLOR_SPACE colorSpace>
bool JPEGImageDecoder::outputScanlines(ScalableImageDecoderFrame& buffer)
{
JSAMPARRAY samples = m_reader->samples();
jpeg_decompress_struct* info = m_reader->info();
- int width = isScaled ? m_scaledColumns.size() : info->output_width;
+ int width = info->output_width;
while (info->output_scanline < info->output_height) {
// jpeg_read_scanlines will increase the scanline counter, so we
@@ -571,13 +562,9 @@
if (jpeg_read_scanlines(info, samples, 1) != 1)
return false;
- int destY = scaledY(sourceY);
- if (destY < 0)
- continue;
-
- auto* currentAddress = buffer.backingStore()->pixelAt(0, destY);
+ auto* currentAddress = buffer.backingStore()->pixelAt(0, sourceY);
for (int x = 0; x < width; ++x) {
- setPixel<colorSpace>(buffer, currentAddress, samples, isScaled ? m_scaledColumns[x] : x);
+ setPixel<colorSpace>(buffer, currentAddress, samples, x);
++currentAddress;
}
}
@@ -584,12 +571,6 @@
return true;
}
-template <J_COLOR_SPACE colorSpace>
-bool JPEGImageDecoder::outputScanlines(ScalableImageDecoderFrame& buffer)
-{
- return m_scaled ? outputScanlines<colorSpace, true>(buffer) : outputScanlines<colorSpace, false>(buffer);
-}
-
bool JPEGImageDecoder::outputScanlines()
{
if (m_frameBufferCache.isEmpty())
@@ -598,7 +579,7 @@
// Initialize the framebuffer if needed.
auto& buffer = m_frameBufferCache[0];
if (buffer.isInvalid()) {
- if (!buffer.initialize(scaledSize(), m_premultiplyAlpha))
+ if (!buffer.initialize(size(), m_premultiplyAlpha))
return setFailed();
buffer.setDecodingStatus(DecodingStatus::Partial);
// The buffer is transparent outside the decoded area while the image is
@@ -609,7 +590,7 @@
jpeg_decompress_struct* info = m_reader->info();
#if defined(TURBO_JPEG_RGB_SWIZZLE)
- if (!m_scaled && turboSwizzled(info->out_color_space)) {
+ if (turboSwizzled(info->out_color_space)) {
while (info->output_scanline < info->output_height) {
unsigned char* row = reinterpret_cast<unsigned char*>(buffer.backingStore()->pixelAt(0, info->output_scanline));
if (jpeg_read_scanlines(info, &row, 1) != 1)
@@ -620,7 +601,7 @@
#endif
switch (info->out_color_space) {
- // The code inside outputScanlines<int, bool> will be executed
+ // The code inside outputScanlines<int> will be executed
// for each pixel, so we want to avoid any extra comparisons there.
// That is why we use template and template specializations here so
// the proper code will be generated at compile time.
Modified: trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h (248997 => 248998)
--- trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h 2019-08-22 06:16:08 UTC (rev 248997)
+++ trunk/Source/WebCore/platform/image-decoders/jpeg/JPEGImageDecoder.h 2019-08-22 09:12:33 UTC (rev 248998)
@@ -52,7 +52,6 @@
// ScalableImageDecoder
String filenameExtension() const override { return "jpg"_s; }
- bool setSize(const IntSize&) override;
ScalableImageDecoderFrame* frameBufferAtIndex(size_t index) override;
// CAUTION: setFailed() deletes |m_reader|. Be careful to avoid
// accessing deleted memory, especially when calling this from inside
@@ -59,12 +58,6 @@
// JPEGImageReader!
bool setFailed() override;
- bool willDownSample()
- {
- ASSERT(ScalableImageDecoder::encodedDataStatus() >= EncodedDataStatus::SizeAvailable);
- return m_scaled;
- }
-
bool outputScanlines();
void jpegComplete();
Modified: trunk/Source/WebCore/platform/image-decoders/jpeg2000/JPEG2000ImageDecoder.cpp (248997 => 248998)
--- trunk/Source/WebCore/platform/image-decoders/jpeg2000/JPEG2000ImageDecoder.cpp 2019-08-22 06:16:08 UTC (rev 248997)
+++ trunk/Source/WebCore/platform/image-decoders/jpeg2000/JPEG2000ImageDecoder.cpp 2019-08-22 09:12:33 UTC (rev 248998)
@@ -479,7 +479,7 @@
}
auto& buffer = m_frameBufferCache[0];
- if (!buffer.initialize(scaledSize(), m_premultiplyAlpha)) {
+ if (!buffer.initialize(size(), m_premultiplyAlpha)) {
setFailed();
return;
}
Modified: trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp (248997 => 248998)
--- trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp 2019-08-22 06:16:08 UTC (rev 248997)
+++ trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.cpp 2019-08-22 09:12:33 UTC (rev 248998)
@@ -248,15 +248,6 @@
}
#endif
-bool PNGImageDecoder::setSize(const IntSize& size)
-{
- if (!ScalableImageDecoder::setSize(size))
- return false;
-
- prepareScaleDataIfNecessary();
- return true;
-}
-
ScalableImageDecoderFrame* PNGImageDecoder::frameBufferAtIndex(size_t index)
{
#if ENABLE(APNG)
@@ -435,7 +426,7 @@
auto& buffer = m_frameBufferCache[m_currentFrame];
if (buffer.isInvalid()) {
png_structp png = m_reader->pngPtr();
- if (!buffer.initialize(scaledSize(), m_premultiplyAlpha)) {
+ if (!buffer.initialize(size(), m_premultiplyAlpha)) {
longjmp(JMPBUF(png), 1);
return;
}
@@ -477,8 +468,7 @@
// make our lives easier.
if (!rowBuffer)
return;
- int y = !m_scaled ? rowIndex : scaledY(rowIndex);
- if (y < 0 || y >= scaledSize().height())
+ if (rowIndex >= size().height())
return;
/* libpng comments (continued).
@@ -516,8 +506,8 @@
}
// Write the decoded row pixels to the frame buffer.
- auto* address = buffer.backingStore()->pixelAt(0, y);
- int width = scaledSize().width();
+ auto* address = buffer.backingStore()->pixelAt(0, rowIndex);
+ int width = size().width();
unsigned char nonTrivialAlphaMask = 0;
png_bytep pixel = row;
@@ -777,7 +767,7 @@
// We want to clear the previous frame to transparent, without
// affecting pixels in the image outside of the frame.
IntRect prevRect = prevBuffer->backingStore()->frameRect();
- if (!frameIndex || prevRect.contains(IntRect(IntPoint(), scaledSize()))) {
+ if (!frameIndex || prevRect.contains(IntRect(IntPoint(), size()))) {
// Clearing the first frame, or a frame the size of the whole
// image, results in a completely empty image.
buffer.backingStore()->clear();
@@ -801,11 +791,7 @@
if (frameRect.maxY() > size().height())
frameRect.setHeight(size().height() - m_yOffset);
- int left = upperBoundScaledX(frameRect.x());
- int right = lowerBoundScaledX(frameRect.maxX(), left);
- int top = upperBoundScaledY(frameRect.y());
- int bottom = lowerBoundScaledY(frameRect.maxY(), top);
- buffer.backingStore()->setFrameRect(IntRect(left, top, right - left, bottom - top));
+ buffer.backingStore()->setFrameRect(frameRect);
}
void PNGImageDecoder::frameComplete()
@@ -826,7 +812,6 @@
if (m_blend && !hasAlpha)
m_blend = 0;
- ASSERT(!m_scaled);
png_bytep row = interlaceBuffer;
for (int y = rect.y(); y < rect.maxY(); ++y, row += colorChannels * size().width()) {
png_bytep pixel = row;
@@ -843,7 +828,7 @@
if (!nonTrivialAlpha) {
IntRect rect = buffer.backingStore()->frameRect();
- if (rect.contains(IntRect(IntPoint(), scaledSize())))
+ if (rect.contains(IntRect(IntPoint(), size())))
buffer.setHasAlpha(false);
else {
size_t frameIndex = m_currentFrame;
Modified: trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h (248997 => 248998)
--- trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h 2019-08-22 06:16:08 UTC (rev 248997)
+++ trunk/Source/WebCore/platform/image-decoders/png/PNGImageDecoder.h 2019-08-22 09:12:33 UTC (rev 248998)
@@ -50,7 +50,6 @@
size_t frameCount() const override { return m_frameCount; }
RepetitionCount repetitionCount() const override;
#endif
- bool setSize(const IntSize&) override;
ScalableImageDecoderFrame* frameBufferAtIndex(size_t index) override;
// CAUTION: setFailed() deletes |m_reader|. Be careful to avoid
// accessing deleted memory, especially when calling this from inside