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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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::setSizeAndColorSpace(int newWidth, | 106 bool ImageFrame::setSizeAndColorSpace(int newWidth, |
107 int newHeight, | 107 int newHeight, |
108 sk_sp<SkColorSpace> colorSpace) { | 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 DCHECK(!width() && !height()); |
112 | 112 |
113 // The image must specify a color space. | |
113 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) { | 114 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) { |
114 if (!colorSpace) | 115 DCHECK(colorSpace); |
115 colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); | 116 m_colorSpace = colorSpace; |
Justin Novosad
2016/10/31 14:55:13
std::move
ccameron
2016/10/31 18:10:18
Done.
I also added a comment clarifying the plan
| |
116 } else { | 117 } else { |
117 colorSpace = nullptr; | 118 DCHECK(!colorSpace); |
118 } | 119 } |
119 | 120 |
120 m_bitmap.setInfo(SkImageInfo::MakeN32( | 121 m_bitmap.setInfo(SkImageInfo::MakeN32( |
121 newWidth, newHeight, | 122 newWidth, newHeight, |
122 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, | 123 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, |
123 std::move(colorSpace))); | 124 std::move(colorSpace))); |
124 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) | 125 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) |
125 return false; | 126 return false; |
126 | 127 |
127 zeroFillPixelData(); | 128 zeroFillPixelData(); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
170 // If the frame is not fully loaded, there will be transparent pixels, | 171 // If the frame is not fully loaded, there will be transparent pixels, |
171 // so we can't tell skia we're opaque, even for image types that logically | 172 // so we can't tell skia we're opaque, even for image types that logically |
172 // always are (e.g. jpeg). | 173 // always are (e.g. jpeg). |
173 if (!m_hasAlpha && m_status == FrameComplete) | 174 if (!m_hasAlpha && m_status == FrameComplete) |
174 return kOpaque_SkAlphaType; | 175 return kOpaque_SkAlphaType; |
175 | 176 |
176 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; | 177 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; |
177 } | 178 } |
178 | 179 |
179 } // namespace blink | 180 } // namespace blink |
OLD | NEW |