Changeset 83091 in webkit


Ignore:
Timestamp:
Apr 6, 2011 1:31:39 PM (13 years ago)
Author:
beidson@apple.com
Message:

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:
Location:
trunk/Source
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r83090 r83091  
     12011-04-06  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=57973 and https://bugs.webkit.org/show_bug.cgi?id=57973
     6        WK2 icon database should be able to get a CGImage of a specific size
     7
     8        * platform/graphics/BitmapImage.h:
     9        * platform/graphics/Image.h:
     10        (WebCore::Image::getFirstCGImageRefOfSize):
     11       
     12        * platform/graphics/cg/ImageCG.cpp:
     13        (WebCore::BitmapImage::getFirstCGImageRefOfSize): Walk the frames of the image until reaching the
     14          first frame of the requested size.
     15
    1162011-04-06  Malcolm MacLeod  <malcolm.macleod@tshwanedje.com>
    217
  • trunk/Source/WebCore/platform/graphics/BitmapImage.h

    r82728 r83091  
    142142#if PLATFORM(CG)
    143143    virtual CGImageRef getCGImageRef();
     144    virtual CGImageRef getFirstCGImageRefOfSize(const IntSize&);
    144145#endif
    145146
  • trunk/Source/WebCore/platform/graphics/Image.h

    r65449 r83091  
    139139#if PLATFORM(CG)
    140140    virtual CGImageRef getCGImageRef() { return 0; }
     141    virtual CGImageRef getFirstCGImageRefOfSize(const IntSize&) { return 0; }
    141142#endif
    142143
  • trunk/Source/WebCore/platform/graphics/cg/ImageCG.cpp

    r77286 r83091  
    155155}
    156156
     157CGImageRef BitmapImage::getFirstCGImageRefOfSize(const IntSize& size)
     158{
     159    for (size_t i = 0; i < m_frames.size(); ++i) {
     160        CGImageRef cgImage = frameAtIndex(i);
     161        if (IntSize(CGImageGetWidth(cgImage), CGImageGetHeight(cgImage)) == size)
     162            return cgImage;
     163    }
     164
     165    // Fallback to the default CGImageRef if we can't find the right size
     166    return getCGImageRef();
     167}
     168
    157169void BitmapImage::draw(GraphicsContext* ctxt, const FloatRect& destRect, const FloatRect& srcRect, ColorSpace styleColorSpace, CompositeOperator compositeOp)
    158170{
  • trunk/Source/WebKit2/ChangeLog

    r83085 r83091  
     12011-04-06  Brady Eidson  <beidson@apple.com>
     2
     3        Reviewed by Anders Carlsson.
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=57973 and https://bugs.webkit.org/show_bug.cgi?id=57973
     6        WK2 icon database should be able to get a CGImage of a specific size
     7
     8        * UIProcess/API/C/cg/WKIconDatabaseCG.cpp:
     9        (WKIconDatabaseTryGetCGImageForURL): Change this API to take a requested size, and find the first matching
     10          CGImage in the icon.
     11        * UIProcess/API/C/cg/WKIconDatabaseCG.h:
     12
    1132011-04-06  Jessie Berlin  <jberlin@apple.com>
    214
  • trunk/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.cpp

    r82839 r83091  
    3535using namespace WebCore;
    3636
    37 CGImageRef WKIconDatabaseTryGetCGImageForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef)
     37CGImageRef WKIconDatabaseTryGetCGImageForURL(WKIconDatabaseRef iconDatabaseRef, WKURLRef urlRef, WKSize size)
    3838{
    3939    Image* image = toImpl(iconDatabaseRef)->imageForPageURL(toWTFString(urlRef));
    40     return image ? image->getCGImageRef() : 0;
     40    return image ? image->getFirstCGImageRefOfSize(IntSize(static_cast<int>(size.width), static_cast<int>(size.height))) : 0;
    4141}
  • trunk/Source/WebKit2/UIProcess/API/C/cg/WKIconDatabaseCG.h

    r82839 r83091  
    2929#include <CoreGraphics/CGImage.h>
    3030#include <WebKit2/WKBase.h>
     31#include <WebKit2/WKGeometry.h>
    3132
    3233#ifdef __cplusplus
     
    3435#endif
    3536
    36 WK_EXPORT CGImageRef WKIconDatabaseTryGetCGImageForURL(WKIconDatabaseRef iconDatabase, WKURLRef urlString);
     37WK_EXPORT CGImageRef WKIconDatabaseTryGetCGImageForURL(WKIconDatabaseRef iconDatabase, WKURLRef urlString, WKSize size);
    3738
    3839#ifdef __cplusplus
Note: See TracChangeset for help on using the changeset viewer.