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

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

Issue 2359643002: color: Make images without embedded profiles sRGB by default (Closed)
Patch Set: Use DCHECK Created 4 years, 3 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 | « no previous file | 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) 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2008, 2009 Google, Inc. 3 * Copyright (C) 2008, 2009 Google, Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 m_bitmap.reset(); 95 m_bitmap.reset();
96 return other.m_bitmap.copyTo(&m_bitmap, other.m_bitmap.colorType()); 96 return other.m_bitmap.copyTo(&m_bitmap, other.m_bitmap.colorType());
97 } 97 }
98 98
99 bool ImageFrame::setSizeAndColorProfile(int newWidth, int newHeight, const ICCPr ofile& newIccProfile) 99 bool ImageFrame::setSizeAndColorProfile(int newWidth, int newHeight, const ICCPr ofile& newIccProfile)
100 { 100 {
101 // setSizeAndColorProfile() should only be called once, it leaks memory othe rwise. 101 // setSizeAndColorProfile() should only be called once, it leaks memory othe rwise.
102 ASSERT(!width() && !height()); 102 ASSERT(!width() && !height());
103 103
104 sk_sp<SkColorSpace> colorSpace; 104 sk_sp<SkColorSpace> colorSpace;
105 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled() && !newIccProfile .isEmpty()) 105 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) {
106 colorSpace = SkColorSpace::NewICC(newIccProfile.data(), newIccProfile.si ze()); 106 if (newIccProfile.isEmpty())
107 colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named);
108 else
109 colorSpace = SkColorSpace::NewICC(newIccProfile.data(), newIccProfil e.size());
110 DCHECK(colorSpace);
111 }
107 112
108 m_bitmap.setInfo(SkImageInfo::MakeN32(newWidth, newHeight, 113 m_bitmap.setInfo(SkImageInfo::MakeN32(newWidth, newHeight,
109 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, colorS pace)); 114 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, colorS pace));
110 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) 115 if (!m_bitmap.tryAllocPixels(m_allocator, 0))
111 return false; 116 return false;
112 117
113 zeroFillPixelData(); 118 zeroFillPixelData();
114 return true; 119 return true;
115 } 120 }
116 121
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // If the frame is not fully loaded, there will be transparent pixels, 157 // If the frame is not fully loaded, there will be transparent pixels,
153 // so we can't tell skia we're opaque, even for image types that logically 158 // so we can't tell skia we're opaque, even for image types that logically
154 // always are (e.g. jpeg). 159 // always are (e.g. jpeg).
155 if (!m_hasAlpha && m_status == FrameComplete) 160 if (!m_hasAlpha && m_status == FrameComplete)
156 return kOpaque_SkAlphaType; 161 return kOpaque_SkAlphaType;
157 162
158 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; 163 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType;
159 } 164 }
160 165
161 } // namespace blink 166 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698