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

Side by Side Diff: third_party/WebKit/Source/platform/image-decoders/ImageDecoder.cpp

Issue 2037373002: Remove the use of OwnedPtrDeleter in ImageDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move QCMSProfileDeleter to .cpp file. Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/ImageDecoder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 14 matching lines...) Expand all
25 #include "platform/image-decoders/bmp/BMPImageDecoder.h" 25 #include "platform/image-decoders/bmp/BMPImageDecoder.h"
26 #include "platform/image-decoders/gif/GIFImageDecoder.h" 26 #include "platform/image-decoders/gif/GIFImageDecoder.h"
27 #include "platform/image-decoders/ico/ICOImageDecoder.h" 27 #include "platform/image-decoders/ico/ICOImageDecoder.h"
28 #include "platform/image-decoders/jpeg/JPEGImageDecoder.h" 28 #include "platform/image-decoders/jpeg/JPEGImageDecoder.h"
29 #include "platform/image-decoders/png/PNGImageDecoder.h" 29 #include "platform/image-decoders/png/PNGImageDecoder.h"
30 #include "platform/image-decoders/webp/WEBPImageDecoder.h" 30 #include "platform/image-decoders/webp/WEBPImageDecoder.h"
31 #include "wtf/PassOwnPtr.h" 31 #include "wtf/PassOwnPtr.h"
32 32
33 namespace blink { 33 namespace blink {
34 34
35 #if USE(QCMSLIB)
36 struct QCMSProfileDeleter {
37 void operator()(qcms_profile* profile)
38 {
39 if (profile)
40 qcms_profile_release(profile);
41 }
42 };
43
44 using QCMSProfileUniquePtr = std::unique_ptr<qcms_profile, QCMSProfileDeleter>;
45 #endif // USE(QCMSLIB)
46
47
35 inline bool matchesJPEGSignature(const char* contents) 48 inline bool matchesJPEGSignature(const char* contents)
36 { 49 {
37 return !memcmp(contents, "\xFF\xD8\xFF", 3); 50 return !memcmp(contents, "\xFF\xD8\xFF", 3);
38 } 51 }
39 52
40 inline bool matchesPNGSignature(const char* contents) 53 inline bool matchesPNGSignature(const char* contents)
41 { 54 {
42 return !memcmp(contents, "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A", 8); 55 return !memcmp(contents, "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A", 8);
43 } 56 }
44 57
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 qcms_profile* gOutputDeviceProfile = nullptr; 315 qcms_profile* gOutputDeviceProfile = nullptr;
303 316
304 } // namespace 317 } // namespace
305 318
306 // static 319 // static
307 void ImageDecoder::setColorProfileAndTransform(const char* iccData, unsigned icc Length, bool hasAlpha, bool useSRGB) 320 void ImageDecoder::setColorProfileAndTransform(const char* iccData, unsigned icc Length, bool hasAlpha, bool useSRGB)
308 { 321 {
309 m_sourceToOutputDeviceColorTransform.reset(); 322 m_sourceToOutputDeviceColorTransform.reset();
310 323
311 // Create the input profile 324 // Create the input profile
312 OwnPtr<qcms_profile> inputProfile; 325 QCMSProfileUniquePtr inputProfile;
313 if (useSRGB) { 326 if (useSRGB) {
314 inputProfile = adoptPtr(qcms_profile_sRGB()); 327 inputProfile.reset(qcms_profile_sRGB());
315 } else { 328 } else {
316 // Only accept RGB color profiles from input class devices. 329 // Only accept RGB color profiles from input class devices.
317 if (iccLength < kIccColorProfileHeaderLength) 330 if (iccLength < kIccColorProfileHeaderLength)
318 return; 331 return;
319 if (!rgbColorProfile(iccData, iccLength)) 332 if (!rgbColorProfile(iccData, iccLength))
320 return; 333 return;
321 if (!inputDeviceColorProfile(iccData, iccLength)) 334 if (!inputDeviceColorProfile(iccData, iccLength))
322 return; 335 return;
323 inputProfile = adoptPtr(qcms_profile_from_memory(iccData, iccLength)); 336 inputProfile.reset(qcms_profile_from_memory(iccData, iccLength));
324 } 337 }
325 if (!inputProfile) 338 if (!inputProfile)
326 return; 339 return;
327 340
328 // We currently only support color profiles for RGB profiled images. 341 // We currently only support color profiles for RGB profiled images.
329 ASSERT(rgbData == qcms_profile_get_color_space(inputProfile.get())); 342 ASSERT(rgbData == qcms_profile_get_color_space(inputProfile.get()));
330 343
331 // Take a lock around initializing and accessing the global device color pro file. 344 // Take a lock around initializing and accessing the global device color pro file.
332 SpinLock::Guard guard(gOutputDeviceProfileLock); 345 SpinLock::Guard guard(gOutputDeviceProfileLock);
333 346
(...skipping 16 matching lines...) Expand all
350 363
351 qcms_profile_precache_output_transform(gOutputDeviceProfile); 364 qcms_profile_precache_output_transform(gOutputDeviceProfile);
352 } 365 }
353 366
354 if (qcms_profile_match(inputProfile.get(), gOutputDeviceProfile)) 367 if (qcms_profile_match(inputProfile.get(), gOutputDeviceProfile))
355 return; 368 return;
356 369
357 qcms_data_type dataFormat = hasAlpha ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8; 370 qcms_data_type dataFormat = hasAlpha ? QCMS_DATA_RGBA_8 : QCMS_DATA_RGB_8;
358 371
359 // FIXME: Don't force perceptual intent if the image profile contains an int ent. 372 // FIXME: Don't force perceptual intent if the image profile contains an int ent.
360 m_sourceToOutputDeviceColorTransform = adoptPtr(qcms_transform_create(inputP rofile.get(), dataFormat, gOutputDeviceProfile, QCMS_DATA_RGBA_8, QCMS_INTENT_PE RCEPTUAL)); 373 m_sourceToOutputDeviceColorTransform.reset(qcms_transform_create(inputProfil e.get(), dataFormat, gOutputDeviceProfile, QCMS_DATA_RGBA_8, QCMS_INTENT_PERCEPT UAL));
361 } 374 }
362 375
363 #endif // USE(QCMSLIB) 376 #endif // USE(QCMSLIB)
364 377
365 } // namespace blink 378 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/image-decoders/ImageDecoder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698