Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(851)

Unified Diff: src/ports/SkImageDecoder_CG.cpp

Issue 243463005: expose CGImage -> SkBitmap (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/core/SkBitmap.cpp ('k') | src/utils/mac/SkCreateCGImageRef.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ports/SkImageDecoder_CG.cpp
diff --git a/src/ports/SkImageDecoder_CG.cpp b/src/ports/SkImageDecoder_CG.cpp
index c683752fdd5e4cf9026ab07260f6a112601f071d..b82b677b664148da4ea33351d42e1d7cd05fd30c 100644
--- a/src/ports/SkImageDecoder_CG.cpp
+++ b/src/ports/SkImageDecoder_CG.cpp
@@ -68,7 +68,9 @@ bool SkImageDecoder_CG::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
const int width = SkToInt(CGImageGetWidth(image));
const int height = SkToInt(CGImageGetHeight(image));
- bm->setConfig(SkBitmap::kARGB_8888_Config, width, height);
+ SkImageInfo skinfo = SkImageInfo::MakeN32Premul(width, height);
+
+ bm->setConfig(skinfo);
if (SkImageDecoder::kDecodeBounds_Mode == mode) {
return true;
}
@@ -76,16 +78,12 @@ bool SkImageDecoder_CG::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
if (!this->allocPixelRef(bm, NULL)) {
return false;
}
+
+ SkAutoLockPixels alp(*bm);
- bm->lockPixels();
- bm->eraseColor(SK_ColorTRANSPARENT);
-
- CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
- CGContextRef cg = CGBitmapContextCreate(bm->getPixels(), width, height, 8, bm->rowBytes(), cs, BITMAP_INFO);
- CFRelease(cs);
-
- CGContextDrawImage(cg, CGRectMake(0, 0, width, height), image);
- CGContextRelease(cg);
+ if (!SkCopyPixelsFromCGImage(bm->info(), bm->rowBytes(), bm->getPixels(), image)) {
+ return false;
+ }
CGImageAlphaInfo info = CGImageGetAlphaInfo(image);
switch (info) {
@@ -112,7 +110,6 @@ bool SkImageDecoder_CG::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
}
bm->setAlphaType(kUnpremul_SkAlphaType);
}
- bm->unlockPixels();
return true;
}
« no previous file with comments | « src/core/SkBitmap.cpp ('k') | src/utils/mac/SkCreateCGImageRef.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698