summaryrefslogtreecommitdiffstats
path: root/skia/ext/skia_utils_mac.mm
diff options
context:
space:
mode:
authoravi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-18 21:41:58 +0000
committeravi@google.com <avi@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-18 21:41:58 +0000
commitac7f222757304095a60909ae7adc3ba22548632e (patch)
treedb53e2c99be4a8a40999c78adcb78965c9a23d47 /skia/ext/skia_utils_mac.mm
parent2b68c89d7ebca6f0d85d5fb9d7ffe819d3c3a9a8 (diff)
downloadchromium_src-ac7f222757304095a60909ae7adc3ba22548632e.zip
chromium_src-ac7f222757304095a60909ae7adc3ba22548632e.tar.gz
chromium_src-ac7f222757304095a60909ae7adc3ba22548632e.tar.bz2
Reverting r18743.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18755 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'skia/ext/skia_utils_mac.mm')
-rw-r--r--skia/ext/skia_utils_mac.mm88
1 files changed, 0 insertions, 88 deletions
diff --git a/skia/ext/skia_utils_mac.mm b/skia/ext/skia_utils_mac.mm
index 3295be0..6880ea8 100644
--- a/skia/ext/skia_utils_mac.mm
+++ b/skia/ext/skia_utils_mac.mm
@@ -10,19 +10,6 @@
#include "base/scoped_cftyperef.h"
#include "base/scoped_ptr.h"
#include "skia/ext/bitmap_platform_device_mac.h"
-#include "third_party/skia/include/utils/mac/SkCGUtils.h"
-#include "third_party/skia/include/core/SkColorPriv.h"
-
-namespace {
-
-// Callback passed to CGDataProviderCreateWithData()
-void ReleaseData(void* info, const void* pixelData, size_t size) {
- // info is a non-const pixelData
- if (info)
- free(info);
-}
-
-}
namespace gfx {
@@ -169,79 +156,4 @@ SkBitmap NSImageToSkBitmap(NSImage* image, NSSize size, bool is_opaque) {
return bitmap;
}
-NSImage* SkBitmapToNSImage(const SkBitmap& icon) {
- // First convert SkBitmap to CGImageRef.
- CGImageRef cgimage;
- if (icon.config() != SkBitmap::kARGB_8888_Config) {
- cgimage = SkCreateCGImageRef(icon);
- } else {
- // The above code returns a valid NSImage even in the
- // kARGB_8888_Config case. As an example, the unit test which
- // draws a blue SkBitmap can lockPixels, NSReadPixel, and pull out
- // a single pixel from the NSImage and see it blue. However, the
- // NSImage returned will be in ABGR format. Although Cocoa is
- // otherwise happy with that format (as seen in simple tests
- // outside Chromium), Chromium is NOT happy. In Chromium, B and R
- // are swapped.
- //
- // As a hint, CIImage supports a few formats, such as ARGB.
- // Interestingly, it does NOT support ABGR. I speculate there is
- // some way we set up our drawing context which has the format
- // specified wrong (in skia/ext/bitmap_platform_device_mac.cc),
- // but I have not been able to solve this yet.
- //
- // TODO(jrg): track down the disconnect.
- // TODO(jrg): Remove byte conversion.
- // TODO(jrg): Fix unit tests to NOT swap bytes.
- // http://crbug.com/14020
- CGBitmapInfo info = (kCGImageAlphaPremultipliedFirst |
- kCGBitmapByteOrder32Host);
- int width = icon.width();
- int height = icon.height();
- int rowbytes = icon.rowBytes();
- int rowwords = rowbytes/4;
- unsigned length = rowbytes * height;
- DCHECK(length > 0);
- uint32_t* rawptr = static_cast<uint32_t*>(malloc(length));
- DCHECK(rawptr);
- if (!rawptr || !length)
- return nil;
-
- // Convert ABGR to ARGB
- icon.lockPixels();
- uint32_t* rawbitmap = static_cast<uint32_t*>(icon.getPixels());
- uint32_t rawbit;
- int offset;
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- offset = x + y*rowwords;
- rawbit = rawbitmap[offset];
- rawptr[offset] = SkPackARGB32(SkGetPackedA32(rawbit),
- SkGetPackedR32(rawbit),
- SkGetPackedG32(rawbit),
- SkGetPackedB32(rawbit));
- }
- }
- icon.unlockPixels();
-
- CGDataProviderRef dataRef =
- CGDataProviderCreateWithData(rawptr, rawptr, length, ReleaseData);
- CGColorSpaceRef space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);
- cgimage = CGImageCreate(width, height, 8,
- icon.bytesPerPixel() * 8,
- rowbytes, space, info, dataRef,
- NULL, false, kCGRenderingIntentDefault);
- CGColorSpaceRelease(space);
- CGDataProviderRelease(dataRef);
- }
-
- // Now convert to NSImage.
- NSBitmapImageRep* bitmap = [[[NSBitmapImageRep alloc]
- initWithCGImage:cgimage] autorelease];
- CFRelease(cgimage);
- NSImage* image = [[[NSImage alloc] init] autorelease];
- [image addRepresentation:bitmap];
- return image;
-}
-
} // namespace gfx