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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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::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 // setSizeAndColorSpace() 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. |
| 114 // TODO(ccameron): This should be set unconditionally, but specifying a |
| 115 // non-renderable SkColorSpace results in errors. |
| 116 // https://bugs.chromium.org/p/skia/issues/detail?id=5907 |
113 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) { | 117 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) { |
114 if (!colorSpace) | 118 DCHECK(colorSpace); |
115 colorSpace = SkColorSpace::NewNamed(SkColorSpace::kSRGB_Named); | 119 m_colorSpace = std::move(colorSpace); |
116 } else { | 120 } else { |
117 colorSpace = nullptr; | 121 DCHECK(!colorSpace); |
118 } | 122 } |
119 | 123 |
120 m_bitmap.setInfo(SkImageInfo::MakeN32( | 124 m_bitmap.setInfo(SkImageInfo::MakeN32( |
121 newWidth, newHeight, | 125 newWidth, newHeight, |
122 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, | 126 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, |
123 std::move(colorSpace))); | 127 std::move(colorSpace))); |
124 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) | 128 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) |
125 return false; | 129 return false; |
126 | 130 |
127 zeroFillPixelData(); | 131 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, | 174 // 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 | 175 // so we can't tell skia we're opaque, even for image types that logically |
172 // always are (e.g. jpeg). | 176 // always are (e.g. jpeg). |
173 if (!m_hasAlpha && m_status == FrameComplete) | 177 if (!m_hasAlpha && m_status == FrameComplete) |
174 return kOpaque_SkAlphaType; | 178 return kOpaque_SkAlphaType; |
175 | 179 |
176 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; | 180 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; |
177 } | 181 } |
178 | 182 |
179 } // namespace blink | 183 } // namespace blink |
OLD | NEW |