Commit 92406445 authored by beidson@apple.com's avatar beidson@apple.com

https://bugs.webkit.org/show_bug.cgi?id=57973 and https://bugs.webkit.org/show_bug.cgi?id=57973

WK2 icon database should be able to get a CGImage of a specific size

Reviewed by Anders Carlsson.

../WebCore: 

* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
(WebCore::Image::getFirstCGImageRefOfSize):
        
* platform/graphics/cg/ImageCG.cpp:
(WebCore::BitmapImage::getFirstCGImageRefOfSize): Walk the frames of the image until reaching the
  first frame of the requested size.

../WebKit2: 

* UIProcess/API/C/cg/WKIconDatabaseCG.cpp:
(WKIconDatabaseTryGetCGImageForURL): Change this API to take a requested size, and find the first matching
  CGImage in the icon.
* UIProcess/API/C/cg/WKIconDatabaseCG.h:



git-svn-id: svn://svn.chromium.org/blink/trunk@83091 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent f4c7c330
2011-04-06 Brady Eidson <beidson@apple.com>
Reviewed by Anders Carlsson.
https://bugs.webkit.org/show_bug.cgi?id=57973 and https://bugs.webkit.org/show_bug.cgi?id=57973
WK2 icon database should be able to get a CGImage of a specific size
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
(WebCore::Image::getFirstCGImageRefOfSize):
* platform/graphics/cg/ImageCG.cpp:
(WebCore::BitmapImage::getFirstCGImageRefOfSize): Walk the frames of the image until reaching the
first frame of the requested size.
2011-04-06 Malcolm MacLeod <malcolm.macleod@tshwanedje.com>
Reviewed by Kevin Ollivier.
......@@ -141,6 +141,7 @@ public:
#if PLATFORM(CG)
virtual CGImageRef getCGImageRef();
virtual CGImageRef getFirstCGImageRefOfSize(const IntSize&);
#endif
#if PLATFORM(WIN) || (PLATFORM(QT) && OS(WINDOWS))
......
......@@ -138,6 +138,7 @@ public:
#if PLATFORM(CG)
virtual CGImageRef getCGImageRef() { return 0; }
virtual CGImageRef getFirstCGImageRefOfSize(const IntSize&) { return 0; }
#endif
#if PLATFORM(WIN)
......
......@@ -154,6 +154,18 @@ CGImageRef BitmapImage::getCGImageRef()
return frameAtIndex(0);
}
CGImageRef BitmapImage::getFirstCGImageRefOfSize(const IntSize& size)
{
for (size_t i = 0; i < m_frames.size(); ++i) {
CGImageRef cgImage = frameAtIndex(i);
if (IntSize(CGImageGetWidth(cgImage), CGImageGetHeight(cgImage)) == size)
return cgImage;
}
// Fallback to the default CGImageRef if we can't find the right size
return getCGImageRef();
}
void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& destRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp)
{
startAnimation();
......
2011-04-06 Brady Eidson <beidson@apple.com>
Reviewed by Anders Carlsson.
https://bugs.webkit.org/show_bug.cgi?id=57973 and https://bugs.webkit.org/show_bug.cgi?id=57973
WK2 icon database should be able to get a CGImage of a specific size
* UIProcess/API/C/cg/WKIconDatabaseCG.cpp:
(WKIconDatabaseTryGetCGImageForURL): Change this API to take a requested size, and find the first matching
CGImage in the icon.
* UIProcess/API/C/cg/WKIconDatabaseCG.h:
2011-04-06 Jessie Berlin <jberlin@apple.com>
Reviewed by Anders Carlsson.
......
......@@ -34,8 +34,8 @@
using namespace WebKit;
using namespace WebCore;
CGImageRef WKIconDatabaseTryGetCGImageForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef)
CGImageRef WKIconDatabaseTryGetCGImageForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef, WKSize size)
{
Image* image = toImpl(iconDatabaseRef)->imageForPageURL(toWTFString(urlRef));
return image ? image->getCGImageRef() : 0;
return image ? image->getFirstCGImageRefOfSize(IntSize(static_cast<int>(size.width), static_cast<int>(size.height))) : 0;
}
......@@ -28,12 +28,13 @@
#include <CoreGraphics/CGImage.h>
#include <WebKit2/WKBase.h>
#include <WebKit2/WKGeometry.h>
#ifdef __cplusplus
extern "C" {
#endif
WK_EXPORT CGImageRef WKIconDatabaseTryGetCGImageForURL(WKIconDatabaseRef iconDatabase, WKURLRef urlString);
WK_EXPORT CGImageRef WKIconDatabaseTryGetCGImageForURL(WKIconDatabaseRef iconDatabase, WKURLRef urlString, WKSize size);
#ifdef __cplusplus
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment