diff options
author | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-16 19:57:22 +0000 |
---|---|---|
committer | mark@chromium.org <mark@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-16 19:57:22 +0000 |
commit | 09c6dec4e18784861660f716d038035be9540601 (patch) | |
tree | b5e5419aff269cb15c13ea6a3eab0c90a527ef4a /webkit/glue/image_decoder.cc | |
parent | 66980a010042f2e44efb21360e662daeae8c5668 (diff) | |
download | chromium_src-09c6dec4e18784861660f716d038035be9540601.zip chromium_src-09c6dec4e18784861660f716d038035be9540601.tar.gz chromium_src-09c6dec4e18784861660f716d038035be9540601.tar.bz2 |
Add file icons to chrome://downloads/ on the Mac. Add Skia helper
CGImageToSkBitmap().
Patch by Robert Sesek <rsesek@bluestatic.org>
Review URL: http://codereview.chromium.org/118488
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18517 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue/image_decoder.cc')
-rw-r--r-- | webkit/glue/image_decoder.cc | 40 |
1 files changed, 2 insertions, 38 deletions
diff --git a/webkit/glue/image_decoder.cc b/webkit/glue/image_decoder.cc index 8f138ca..73c3f9b 100644 --- a/webkit/glue/image_decoder.cc +++ b/webkit/glue/image_decoder.cc @@ -15,6 +15,7 @@ MSVC_PUSH_WARNING_LEVEL(0); #elif defined(OS_MACOSX) #include "ImageSource.h" #include "RetainPtr.h" +#include "skia/ext/skia_utils_mac.h" #endif #include "IntSize.h" #include "RefPtr.h" @@ -73,44 +74,7 @@ SkBitmap ImageDecoder::Decode(const unsigned char* data, size_t size) const { // BitmapImage releases automatically, but we're bypassing it so we'll need // to do the releasing. RetainPtr<CGImageRef> image(AdoptCF, frame0); - - SkBitmap result; - result.setConfig(SkBitmap::kARGB_8888_Config, CGImageGetWidth(image.get()), - CGImageGetHeight(image.get())); - - // TODO(port): - // This line is a waste, but is needed when the renderer sends a - // ViewHostMsg_DidDownloadImage and tries to pickle the SkBitmap. - // Presumably this will be removed when we (ImageDecoder::Decode()) - // are changed to not return a fake SkBitmap. - result.allocPixels(); - - RetainPtr<CGColorSpace> cg_color(AdoptCF, CGColorSpaceCreateDeviceRGB()); - // The last parameter is a total guess. Feel free to adjust it if images draw - // incorrectly. TODO(avi): Verify byte ordering; it should be possible to - // swizzle bytes with various combinations of the byte order and alpha - // constants. - RetainPtr<CGContextRef> context(AdoptCF, CGBitmapContextCreate( - result.getPixels(), - result.width(), - result.height(), - result.bytesPerPixel() * 8 / 4, - result.rowBytes(), - cg_color.get(), - kCGImageAlphaPremultipliedFirst | - kCGBitmapByteOrder32Host)); - CGRect rect = CGRectMake(0, 0, - CGImageGetWidth(image.get()), - CGImageGetHeight(image.get())); - - // We want to copy transparent pixels from |image| over to |result|, instead - // of blending |image| onto the uninitialized pixels of |result|. Since - // |context| is used only locally, there's no need to restore the blend mode. - CGContextSetBlendMode(context.get(), kCGBlendModeCopy); - - CGContextDrawImage(context.get(), rect, image.get()); - - return result; + return gfx::CGImageToSkBitmap(image.get()); #endif } |