khtml: cleanup and fix alpha channel detection regression since 2f72cbbd

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2016-02-29 03:45:57 +02:00
parent aef9f7cf16
commit ac6aaa5fee
8 changed files with 18 additions and 52 deletions

View file

@ -190,9 +190,6 @@ hash_prop (register const char *str, register unsigned int len)
#ifdef __GNUC__
__inline
#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
__attribute__ ((__gnu_inline__))
#endif
#endif
const struct css_prop *
findProp (register const char *str, register unsigned int len)

View file

@ -175,9 +175,6 @@ hash_val (register const char *str, register unsigned int len)
#ifdef __GNUC__
__inline
#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
__attribute__ ((__gnu_inline__))
#endif
#endif
const struct css_value *
findValue (register const char *str, register unsigned int len)

View file

@ -131,10 +131,9 @@ bool Image::processData(char* data, int length)
}
}
int stat = loader->processData(data, length);
const bool success = loader->processData(data, length);
//If we just finished decoding...
if (stat == ImageLoader::Done)
if (success)
{
if (original && original->animProvider)
original->animProvider->setShowAnimations(animationAdvice);
@ -142,15 +141,11 @@ bool Image::processData(char* data, int length)
fullyDecoded = true;
owner->imageDone(this);
return false;
}
if (stat == ImageLoader::Error)
{
loadError();
return false;
}
return true; //Need more stuff
loadError();
return false;
}
void Image::notifyImageInfo(int _width, int _height)
@ -406,13 +401,6 @@ QImage* Image::qimage() const
return &static_cast<RawImagePlane*>(original->parent)->image;
}
bool Image::hasAlpha() const
{
if (!original || !original->parent)
return false;
return original->parent->format.hasAlpha();
}
void Image::setShowAnimations(KHTMLSettings::KAnimationAdvice newAdvice)
{
if (animationAdvice != newAdvice)

View file

@ -76,11 +76,6 @@ public:
*/
bool complete() const;
/**
Returns true if the image may have an alpha channel
*/
bool hasAlpha() const;
/**
Returns the image of basic content. Should be treated as READ ONLY.
(but see CanvasImage)

View file

@ -90,11 +90,6 @@ struct ImageFormat
return toRet;
}
bool hasAlpha() const
{
return (type == Image_ARGB_32 || type == Image_ARGB_32_DontPremult);
}
mutable QVector<QRgb> palette;
//A helper for setting up a format descriptor for 8-bit grayscale

View file

@ -118,18 +118,12 @@ public:
virtual ~ImageLoader()
{}
enum Status
{
Done = -2,
Error = -1
};
/**
Decodes a portion of the image, and returns the appropriate
status, or the number of bytes read
Decodes the image, and returns the appropriate status,
or the number of bytes read
*/
virtual int processData(char* data, int length) = 0;
virtual bool processData(char* data, int length) = 0;
};
}

View file

@ -96,7 +96,7 @@ public:
{
}
virtual int processData(char* data, int length)
virtual bool processData(char* data, int length)
{
buffer.setData(data, length);
buffer.open(QIODevice::ReadOnly);
@ -105,7 +105,7 @@ public:
QImageReader reader(&buffer, qformat);
if (!reader.canRead()) {
return Error;
return false;
}
QSize size = reader.size();
@ -113,11 +113,11 @@ public:
if (ImageManager::isAcceptableSize(size.width(), size.height()))
notifyImageInfo(size.width(), size.height());
else
return Error;
return false;
}
if (!reader.read(&image)) {
return Error;
return false;
}
if (!size.isValid()) {
@ -125,18 +125,18 @@ public:
if (ImageManager::isAcceptableSize(image.width(), image.height()))
notifyImageInfo(image.width(), image.height());
else
return Error;
return false;
}
ImageFormat format;
if (!imageFormat(image, format)) {
return Error;
return false;
}
notifyAppendFrame(image.width(), image.height(), format);
notifyQImage(1, &image);
return Done;
return true;
}
bool imageFormat(QImage &image, ImageFormat &format) {
switch(image.format()) {

View file

@ -616,7 +616,7 @@ QPixmap CachedImage::pixmap( ) const
int w = i->size().width();
int h = i->size().height();
if (i->hasAlpha() && QApplication::desktop()->paintEngine() &&
if (i->qimage()->hasAlphaChannel() && QApplication::desktop()->paintEngine() &&
!QApplication::desktop()->paintEngine()->hasFeature(QPaintEngine::PorterDuff)) {
QImage im(w, h, QImage::Format_ARGB32_Premultiplied);
QPainter paint(&im);
@ -627,7 +627,7 @@ QPixmap CachedImage::pixmap( ) const
return QPixmap::fromImage( im, Qt::NoOpaqueDetection );
} else {
QPixmap pm(w, h);
if (i->hasAlpha())
if (i->qimage()->hasAlphaChannel())
pm.fill(Qt::transparent);
QPainter paint(&pm);
paint.setCompositionMode(QPainter::CompositionMode_Source);