OLD | NEW |
---|---|
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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
96 DCHECK_NE(this, other); | 96 DCHECK_NE(this, other); |
97 if (other->m_bitmap.isImmutable()) | 97 if (other->m_bitmap.isImmutable()) |
98 return false; | 98 return false; |
99 m_hasAlpha = other->m_hasAlpha; | 99 m_hasAlpha = other->m_hasAlpha; |
100 m_bitmap.reset(); | 100 m_bitmap.reset(); |
101 m_bitmap.swap(other->m_bitmap); | 101 m_bitmap.swap(other->m_bitmap); |
102 other->m_status = FrameEmpty; | 102 other->m_status = FrameEmpty; |
103 return true; | 103 return true; |
104 } | 104 } |
105 | 105 |
106 bool ImageFrame::setSizeAndColorProfile(int newWidth, | 106 bool ImageFrame::setSizeAndColorSpace(int newWidth, |
107 int newHeight, | 107 int newHeight, |
108 const ICCProfile& newIccProfile) { | 108 sk_sp<SkColorSpace> colorSpace) { |
109 // setSizeAndColorProfile() should only be called once, it leaks memory | 109 // setSizeAndColorProfile() should only be called once, it leaks memory |
110 // otherwise. | 110 // otherwise. |
111 ASSERT(!width() && !height()); | 111 ASSERT(!width() && !height()); |
112 | 112 |
113 sk_sp<SkColorSpace> colorSpace; | |
114 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) { | 113 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) { |
115 if (newIccProfile.isEmpty()) | 114 if (!colorSpace) |
116 colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); | 115 colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); |
117 else | |
118 colorSpace = | |
119 SkColorSpace::NewICC(newIccProfile.data(), newIccProfile.size()); | |
120 DCHECK(colorSpace); | |
msarett
2016/10/27 15:43:22
We lose the debug check for icc profiles that we f
ccameron
2016/10/27 22:36:11
This doesn't worry me ATM -- indeed we may want to
| |
121 } | 116 } |
122 | 117 |
123 m_bitmap.setInfo(SkImageInfo::MakeN32( | 118 m_bitmap.setInfo(SkImageInfo::MakeN32( |
124 newWidth, newHeight, | 119 newWidth, newHeight, |
125 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, | 120 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, |
126 colorSpace)); | 121 std::move(colorSpace))); |
127 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) | 122 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) |
128 return false; | 123 return false; |
129 | 124 |
130 zeroFillPixelData(); | 125 zeroFillPixelData(); |
131 return true; | 126 return true; |
132 } | 127 } |
133 | 128 |
134 bool ImageFrame::hasAlpha() const { | 129 bool ImageFrame::hasAlpha() const { |
135 return m_hasAlpha; | 130 return m_hasAlpha; |
136 } | 131 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 // If the frame is not fully loaded, there will be transparent pixels, | 168 // If the frame is not fully loaded, there will be transparent pixels, |
174 // so we can't tell skia we're opaque, even for image types that logically | 169 // so we can't tell skia we're opaque, even for image types that logically |
175 // always are (e.g. jpeg). | 170 // always are (e.g. jpeg). |
176 if (!m_hasAlpha && m_status == FrameComplete) | 171 if (!m_hasAlpha && m_status == FrameComplete) |
177 return kOpaque_SkAlphaType; | 172 return kOpaque_SkAlphaType; |
178 | 173 |
179 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; | 174 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; |
180 } | 175 } |
181 | 176 |
182 } // namespace blink | 177 } // namespace blink |
OLD | NEW |