| 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 // setSizeAndColorSpace() should only be called once, it leaks memory | 109 // setSizeAndColorSpace() should only be called once, it leaks memory |
| 110 // otherwise. | 110 // otherwise. |
| 111 DCHECK(!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 | |
| 117 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled()) { | |
| 118 DCHECK(colorSpace); | |
| 119 m_colorSpace = std::move(colorSpace); | |
| 120 } else { | |
| 121 DCHECK(!colorSpace); | |
| 122 } | |
| 123 | |
| 124 m_bitmap.setInfo(SkImageInfo::MakeN32( | 113 m_bitmap.setInfo(SkImageInfo::MakeN32( |
| 125 newWidth, newHeight, | 114 newWidth, newHeight, |
| 126 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, | 115 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, |
| 127 m_colorSpace)); | 116 std::move(colorSpace))); |
| 128 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) | 117 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) |
| 129 return false; | 118 return false; |
| 130 | 119 |
| 131 zeroFillPixelData(); | 120 zeroFillPixelData(); |
| 132 return true; | 121 return true; |
| 133 } | 122 } |
| 134 | 123 |
| 135 bool ImageFrame::hasAlpha() const { | 124 bool ImageFrame::hasAlpha() const { |
| 136 return m_hasAlpha; | 125 return m_hasAlpha; |
| 137 } | 126 } |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 // If the frame is not fully loaded, there will be transparent pixels, | 198 // If the frame is not fully loaded, there will be transparent pixels, |
| 210 // so we can't tell skia we're opaque, even for image types that logically | 199 // so we can't tell skia we're opaque, even for image types that logically |
| 211 // always are (e.g. jpeg). | 200 // always are (e.g. jpeg). |
| 212 if (!m_hasAlpha && m_status == FrameComplete) | 201 if (!m_hasAlpha && m_status == FrameComplete) |
| 213 return kOpaque_SkAlphaType; | 202 return kOpaque_SkAlphaType; |
| 214 | 203 |
| 215 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; | 204 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; |
| 216 } | 205 } |
| 217 | 206 |
| 218 } // namespace blink | 207 } // namespace blink |
| OLD | NEW |