Chromium Code Reviews| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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()); | |
|
msarett
2016/09/21 12:06:40
NewICC() might fail (return nullptr) - if the inp
ccameron
2016/09/21 18:23:02
I was considering to add an ASSERT for that, rathe
msarett
2016/09/21 18:28:42
ASSERT seems good for now - especially if it helps
| |
| 110 } | |
| 107 | 111 |
| 108 m_bitmap.setInfo(SkImageInfo::MakeN32(newWidth, newHeight, | 112 m_bitmap.setInfo(SkImageInfo::MakeN32(newWidth, newHeight, |
| 109 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, colorS pace)); | 113 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, colorS pace)); |
| 110 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) | 114 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) |
| 111 return false; | 115 return false; |
| 112 | 116 |
| 113 zeroFillPixelData(); | 117 zeroFillPixelData(); |
| 114 return true; | 118 return true; |
| 115 } | 119 } |
| 116 | 120 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 // If the frame is not fully loaded, there will be transparent pixels, | 156 // 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 | 157 // so we can't tell skia we're opaque, even for image types that logically |
| 154 // always are (e.g. jpeg). | 158 // always are (e.g. jpeg). |
| 155 if (!m_hasAlpha && m_status == FrameComplete) | 159 if (!m_hasAlpha && m_status == FrameComplete) |
| 156 return kOpaque_SkAlphaType; | 160 return kOpaque_SkAlphaType; |
| 157 | 161 |
| 158 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; | 162 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; |
| 159 } | 163 } |
| 160 | 164 |
| 161 } // namespace blink | 165 } // namespace blink |
| OLD | NEW |