#include "public/platform/Platform.h"
#include "wtf/Assertions.h"
#include "wtf/RefPtr.h"
-#include "wtf/text/WTFString.h"
#include "wtf/Vector.h"
+#include "wtf/text/WTFString.h"
#if USE(QCMSLIB)
#include "qcms.h"
-#if OS(MACOSX)
-#include <ApplicationServices/ApplicationServices.h>
-#include "wtf/RetainPtr.h"
-#endif
#endif
-namespace WebCore {
+typedef Vector<char> ColorProfile;
+
+namespace blink {
+
+// ImagePlanes can be used to decode color components into provided buffers instead of using an ImageFrame.
+class PLATFORM_EXPORT ImagePlanes {
+public:
+ ImagePlanes();
+ ImagePlanes(void* planes[3], size_t rowBytes[3]);
+
+ void* plane(int);
+ size_t rowBytes(int) const;
+
+private:
+ void* m_planes[3];
+ size_t m_rowBytes[3];
+};
// ImageDecoder is a base for all format-specific decoders
// (e.g. JPEGImageDecoder). This base manages the ImageFrame cache.
class PLATFORM_EXPORT ImageDecoder {
WTF_MAKE_NONCOPYABLE(ImageDecoder); WTF_MAKE_FAST_ALLOCATED;
public:
+ enum SizeType { ActualSize, SizeForMemoryAllocation };
+
static const size_t noDecodedImageByteLimit = blink::Platform::noDecodedImageByteLimit;
ImageDecoder(ImageSource::AlphaOption alphaOption, ImageSource::GammaAndColorProfileOption gammaAndColorProfileOption, size_t maxDecodedBytes)
m_isAllDataReceived = allDataReceived;
}
- // Lazily-decodes enough of the image to get the size (if possible).
- // FIXME: Right now that has to be done by each subclass; factor the
- // decode call out and use it here.
virtual bool isSizeAvailable()
{
return !m_failed && m_sizeAvailable;
}
+ bool isSizeAvailable() const
+ {
+ return !m_failed && m_sizeAvailable;
+ }
+
virtual IntSize size() const { return m_size; }
// Decoders which downsample images should override this method to
// return the actual decoded size.
virtual IntSize decodedSize() const { return size(); }
+ // Decoders which support YUV decoding can override this to
+ // give potentially different sizes per component.
+ virtual IntSize decodedYUVSize(int component, SizeType) const { return decodedSize(); }
+
// 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 or WebP, since
OutputDeviceProfile()
: m_outputDeviceProfile(0)
{
- // FIXME: Add optional ICCv4 support.
-#if OS(MACOSX)
- RetainPtr<CGColorSpaceRef> monitorColorSpace(AdoptCF, CGDisplayCopyColorSpace(CGMainDisplayID()));
- CFDataRef iccProfile(CGColorSpaceCopyICCProfile(monitorColorSpace.get()));
- if (iccProfile) {
- size_t length = CFDataGetLength(iccProfile);
- const unsigned char* systemProfile = CFDataGetBytePtr(iccProfile);
- m_outputDeviceProfile = qcms_profile_from_memory(systemProfile, length);
- }
-#else
- // FIXME: add support for multiple monitors.
- ColorProfile profile;
- screenColorProfile(profile);
+ ColorProfile profile = screenColorProfile();
if (!profile.isEmpty())
m_outputDeviceProfile = qcms_profile_from_memory(profile.data(), profile.size());
-#endif
+
if (m_outputDeviceProfile && qcms_profile_is_bogus(m_outputDeviceProfile)) {
qcms_profile_release(m_outputDeviceProfile);
m_outputDeviceProfile = 0;
}
+
if (!m_outputDeviceProfile)
m_outputDeviceProfile = qcms_profile_sRGB();
if (m_outputDeviceProfile)
qcms_profile* profile() const { return m_outputDeviceProfile; }
private:
+ static ColorProfile screenColorProfile()
+ {
+ // FIXME: Add optional ICCv4 support and support for multiple monitors.
+ WebVector<char> profile;
+ Platform::current()->screenColorProfile(&profile);
+
+ ColorProfile colorProfile;
+ colorProfile.append(profile.data(), profile.size());
+ return colorProfile;
+ }
+
qcms_profile* m_outputDeviceProfile;
};
m_frameBufferCache[0].setMemoryAllocator(allocator);
}
+ virtual bool canDecodeToYUV() const { return false; }
+ virtual bool decodeToYUV() { return false; }
+ virtual void setImagePlanes(PassOwnPtr<ImagePlanes>) { }
+
protected:
// Calculates the most recent frame whose image data may be needed in
// order to decode frame |frameIndex|, based on frame disposal methods
bool m_failed;
};
-} // namespace WebCore
+} // namespace blink
#endif