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

Unified Diff: src/codec/SkJpegCodec.cpp

Issue 2023093004: Revert of Create SkColorSpaceXform to handle color conversions (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 7 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/codec/SkJpegCodec.h ('k') | src/core/SkColorSpaceXform.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/codec/SkJpegCodec.cpp
diff --git a/src/codec/SkJpegCodec.cpp b/src/codec/SkJpegCodec.cpp
index 0413f79a3c358466f4542d5812461adab209104e..85de356118ccda95e314c7b2ec7376100bb6684b 100644
--- a/src/codec/SkJpegCodec.cpp
+++ b/src/codec/SkJpegCodec.cpp
@@ -120,7 +120,7 @@
* (1) Discover all ICC profile markers and verify that they are numbered properly.
* (2) Copy the data from each marker into a contiguous ICC profile.
*/
-static sk_sp<SkData> get_icc_profile(jpeg_decompress_struct* dinfo) {
+static sk_sp<SkColorSpace> get_icc_profile(jpeg_decompress_struct* dinfo) {
// Note that 256 will be enough storage space since each markerIndex is stored in 8-bits.
jpeg_marker_struct* markerSequence[256];
memset(markerSequence, 0, sizeof(markerSequence));
@@ -165,8 +165,8 @@
}
// Combine the ICC marker data into a contiguous profile.
- sk_sp<SkData> iccData = SkData::MakeUninitialized(totalBytes);
- void* dst = iccData->writable_data();
+ SkAutoMalloc iccData(totalBytes);
+ void* dst = iccData.get();
for (uint32_t i = 1; i <= numMarkers; i++) {
jpeg_marker_struct* marker = markerSequence[i];
if (!marker) {
@@ -180,7 +180,7 @@
dst = SkTAddOffset<void>(dst, bytes);
}
- return iccData;
+ return SkColorSpace::NewICC(iccData.get(), totalBytes);
}
bool SkJpegCodec::ReadHeader(SkStream* stream, SkCodec** codecOut,
@@ -221,14 +221,7 @@
SkEncodedInfo info = SkEncodedInfo::Make(color, SkEncodedInfo::kOpaque_Alpha, 8);
Origin orientation = get_exif_orientation(decoderMgr->dinfo());
- sk_sp<SkData> iccData = get_icc_profile(decoderMgr->dinfo());
- sk_sp<SkColorSpace> colorSpace = nullptr;
- if (iccData) {
- colorSpace = SkColorSpace::NewICC(iccData->data(), iccData->size());
- if (!colorSpace) {
- SkCodecPrintf("Could not create SkColorSpace from ICC data.\n");
- }
- }
+ sk_sp<SkColorSpace> colorSpace = get_icc_profile(decoderMgr->dinfo());
if (!colorSpace) {
// Treat unmarked jpegs as sRGB.
colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
@@ -237,7 +230,7 @@
const int width = decoderMgr->dinfo()->image_width;
const int height = decoderMgr->dinfo()->image_height;
*codecOut = new SkJpegCodec(width, height, info, stream, decoderMgr.release(),
- std::move(colorSpace), orientation, std::move(iccData));
+ std::move(colorSpace), orientation);
} else {
SkASSERT(nullptr != decoderMgrOut);
*decoderMgrOut = decoderMgr.release();
@@ -258,13 +251,11 @@
}
SkJpegCodec::SkJpegCodec(int width, int height, const SkEncodedInfo& info, SkStream* stream,
- JpegDecoderMgr* decoderMgr, sk_sp<SkColorSpace> colorSpace, Origin origin,
- sk_sp<SkData> iccData)
+ JpegDecoderMgr* decoderMgr, sk_sp<SkColorSpace> colorSpace, Origin origin)
: INHERITED(width, height, info, stream, std::move(colorSpace), origin)
, fDecoderMgr(decoderMgr)
, fReadyState(decoderMgr->dinfo()->global_state)
, fSwizzlerSubset(SkIRect::MakeEmpty())
- , fICCData(std::move(iccData))
{}
/*
« no previous file with comments | « src/codec/SkJpegCodec.h ('k') | src/core/SkColorSpaceXform.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698