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

Unified Diff: src/pdf/SkPDFImage.cpp

Issue 849103004: Make SkStream *not* ref counted. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Rebase, just in case. Created 5 years, 11 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/pdf/SkPDFImage.h ('k') | src/pdf/SkPDFShader.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/pdf/SkPDFImage.cpp
diff --git a/src/pdf/SkPDFImage.cpp b/src/pdf/SkPDFImage.cpp
index 65454fabc6a4b41fbd93d5ea495b0e89ce4676e1..5dc6babec9ac8614546cc11dce499cec50d5d4e8 100644
--- a/src/pdf/SkPDFImage.cpp
+++ b/src/pdf/SkPDFImage.cpp
@@ -239,40 +239,41 @@ static SkStream* extract_image_data(const SkBitmap& bitmap,
}
return NULL;
}
- bool isOpaque = true;
- bool transparent = extractAlpha;
- SkStream* stream = NULL;
SkAutoLockPixels lock(bitmap);
if (NULL == bitmap.getPixels()) {
return NULL;
}
+ bool isOpaque = true;
+ bool transparent = extractAlpha;
+ SkAutoTDelete<SkStream> stream;
+
switch (colorType) {
case kIndex_8_SkColorType:
if (!extractAlpha) {
- stream = extract_index8_image(bitmap, srcRect);
+ stream.reset(extract_index8_image(bitmap, srcRect));
}
break;
case kARGB_4444_SkColorType:
- stream = extract_argb4444_data(bitmap, srcRect, extractAlpha,
- &isOpaque, &transparent);
+ stream.reset(extract_argb4444_data(bitmap, srcRect, extractAlpha,
+ &isOpaque, &transparent));
break;
case kRGB_565_SkColorType:
if (!extractAlpha) {
- stream = extract_rgb565_image(bitmap, srcRect);
+ stream.reset(extract_rgb565_image(bitmap, srcRect));
}
break;
case kN32_SkColorType:
- stream = extract_argb8888_data(bitmap, srcRect, extractAlpha,
- &isOpaque, &transparent);
+ stream.reset(extract_argb8888_data(bitmap, srcRect, extractAlpha,
+ &isOpaque, &transparent));
break;
case kAlpha_8_SkColorType:
if (!extractAlpha) {
- stream = create_black_image();
+ stream.reset(create_black_image());
} else {
- stream = extract_a8_alpha(bitmap, srcRect,
- &isOpaque, &transparent);
+ stream.reset(extract_a8_alpha(bitmap, srcRect,
+ &isOpaque, &transparent));
}
break;
default:
@@ -283,10 +284,9 @@ static SkStream* extract_image_data(const SkBitmap& bitmap,
*isTransparent = transparent;
}
if (extractAlpha && (transparent || isOpaque)) {
- SkSafeUnref(stream);
return NULL;
}
- return stream;
+ return stream.detach();
}
static SkPDFArray* make_indexed_color_space(SkColorTable* table) {
@@ -468,7 +468,7 @@ SkPDFImage* SkPDFImage::CreateImage(const SkBitmap& bitmap,
}
bool isTransparent = false;
- SkAutoTUnref<SkStream> alphaData;
+ SkAutoTDelete<SkStream> alphaData;
if (!bitmap.isOpaque()) {
// Note that isOpaque is not guaranteed to return false for bitmaps
// with alpha support but a completely opaque alpha channel,
@@ -639,7 +639,7 @@ bool SkPDFImage::populate(SkPDFCatalog* catalog) {
}
// Fallback method
if (!fStreamValid) {
- SkAutoTUnref<SkStream> stream(
+ SkAutoTDelete<SkStream> stream(
extract_image_data(fBitmap, fSrcRect, fIsAlpha, NULL));
this->setData(stream);
fStreamValid = true;
« no previous file with comments | « src/pdf/SkPDFImage.h ('k') | src/pdf/SkPDFShader.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698