From 2b26cac4fd1a0ff6bfc84757f35198afba3ee1d2 Mon Sep 17 00:00:00 2001 From: "reed@android.com" Date: Mon, 22 Dec 2008 02:33:11 +0000 Subject: downgrade project files to 10.4 so more clients can use them downgrade some CG calls in test apps to not require 10.5 apis remove leftover printf in SkOSWindow_Mac.cpp git-svn-id: http://skia.googlecode.com/svn/trunk@42 2bbb7eff-a529-9590-31e7-b0007b416f81 --- src/utils/mac/SkCreateCGImageRef.cpp | 36 +++++++----------------------------- src/utils/mac/SkOSWindow_Mac.cpp | 1 - 2 files changed, 7 insertions(+), 30 deletions(-) (limited to 'src/utils/mac') diff --git a/src/utils/mac/SkCreateCGImageRef.cpp b/src/utils/mac/SkCreateCGImageRef.cpp index b2a37f0174..6c9415edc0 100644 --- a/src/utils/mac/SkCreateCGImageRef.cpp +++ b/src/utils/mac/SkCreateCGImageRef.cpp @@ -3,27 +3,7 @@ extern CGImageRef SkCreateCGImageRef(const SkBitmap&); -static const void* SkBitmap_GetBytesPointer(void* info) { - SkBitmap* bitmap = reinterpret_cast(info); - bitmap->lockPixels(); - return bitmap->getPixels(); -} - -static void SkBitmap_ReleaseBytePointer(void* info, const void* pointer) { - SkBitmap* bitmap = reinterpret_cast(info); - bitmap->unlockPixels(); -} - -static size_t SkBitmap_GetBytesAtPosition(void* info, void* buffer, - off_t offset, size_t count) { - SkBitmap* bitmap = reinterpret_cast(info); - bitmap->lockPixels(); - memcpy(buffer, (const char*)bitmap->getPixels() + offset, count); - bitmap->unlockPixels(); - return count; -} - -static void SkBitmap_ReleaseInfo(void* info) { +static void SkBitmap_ReleaseInfo(void* info, const void* pixelData, size_t size) { SkBitmap* bitmap = reinterpret_cast(info); delete bitmap; } @@ -67,15 +47,13 @@ CGImageRef SkCreateCGImageRef(const SkBitmap& bm) { const int h = bitmap->height(); const size_t s = bitmap->getSize(); - CGDataProviderDirectCallbacks procs; - procs.version = 0; - procs.getBytePointer = SkBitmap_GetBytesPointer; - procs.releaseBytePointer = SkBitmap_ReleaseBytePointer; - procs.getBytesAtPosition = SkBitmap_GetBytesAtPosition; - procs.releaseInfo = SkBitmap_ReleaseInfo; - // our provider "owns" the bitmap*, and will take care of deleting it - CGDataProviderRef dataRef = CGDataProviderCreateDirect(bitmap, s, &procs); + // we initially lock it, so we can access the pixels. The bitmap will be deleted in the release + // proc, which will in turn unlock the pixels + bitmap->lockPixels(); + CGDataProviderRef dataRef = CGDataProviderCreateWithData(bitmap, bitmap->getPixels(), s, + SkBitmap_ReleaseInfo); + CGColorSpaceRef space = CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB); CGImageRef ref = CGImageCreate(w, h, bitsPerComponent, bitmap->bytesPerPixel() * 8, diff --git a/src/utils/mac/SkOSWindow_Mac.cpp b/src/utils/mac/SkOSWindow_Mac.cpp index 2c937210c2..40ed57cc88 100644 --- a/src/utils/mac/SkOSWindow_Mac.cpp +++ b/src/utils/mac/SkOSWindow_Mac.cpp @@ -203,7 +203,6 @@ bool SkOSWindow::onEvent(const SkEvent& evt) { this->update(NULL); const SkBitmap& bm = this->getBitmap(); - SkDebugf("------ bitmap %d %d\n", bm.width(), bm.height()); CGImageRef img = SkCreateCGImageRef(bm); HIImageViewSetImage((HIViewRef)getHVIEW(), img); -- cgit v1.2.3