| 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 |
| 11 * notice, this list of conditions and the following disclaimer in the | 11 * notice, this list of conditions and the following disclaimer in the |
| 12 * documentation and/or other materials provided with the distribution. | 12 * documentation and/or other materials provided with the distribution. |
| 13 * | 13 * |
| 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY | 14 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
| 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
| 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR | 17 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
| 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, | 18 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
| 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | 19 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | 20 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
| 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY | 21 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
| 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 22 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "platform/image-decoders/ImageFrame.h" |
| 28 |
| 29 #include "platform/RuntimeEnabledFeatures.h" |
| 27 #include "platform/image-decoders/ImageDecoder.h" | 30 #include "platform/image-decoders/ImageDecoder.h" |
| 28 | 31 |
| 29 namespace blink { | 32 namespace blink { |
| 30 | 33 |
| 31 ImageFrame::ImageFrame() | 34 ImageFrame::ImageFrame() |
| 32 : m_allocator(0) | 35 : m_allocator(0) |
| 33 , m_hasAlpha(true) | 36 , m_hasAlpha(true) |
| 34 , m_status(FrameEmpty) | 37 , m_status(FrameEmpty) |
| 35 , m_duration(0) | 38 , m_duration(0) |
| 36 , m_disposalMethod(DisposeNotSpecified) | 39 , m_disposalMethod(DisposeNotSpecified) |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 m_hasAlpha = other.m_hasAlpha; | 94 m_hasAlpha = other.m_hasAlpha; |
| 92 m_bitmap.reset(); | 95 m_bitmap.reset(); |
| 93 return other.m_bitmap.copyTo(&m_bitmap, other.m_bitmap.colorType()); | 96 return other.m_bitmap.copyTo(&m_bitmap, other.m_bitmap.colorType()); |
| 94 } | 97 } |
| 95 | 98 |
| 96 bool ImageFrame::setSizeAndColorProfile(int newWidth, int newHeight, const ICCPr
ofile& newIccProfile) | 99 bool ImageFrame::setSizeAndColorProfile(int newWidth, int newHeight, const ICCPr
ofile& newIccProfile) |
| 97 { | 100 { |
| 98 // setSizeAndColorProfile() should only be called once, it leaks memory othe
rwise. | 101 // setSizeAndColorProfile() should only be called once, it leaks memory othe
rwise. |
| 99 ASSERT(!width() && !height()); | 102 ASSERT(!width() && !height()); |
| 100 | 103 |
| 101 // TODO(ccameron): Populate the color space parameter of the SkImageInfo | 104 sk_sp<SkColorSpace> colorSpace; |
| 102 // with newIccProfile, under a runtime flag. | 105 if (RuntimeEnabledFeatures::colorCorrectRenderingEnabled() && !newIccProfile
.isEmpty()) |
| 106 colorSpace = SkColorSpace::NewICC(newIccProfile.data(), newIccProfile.si
ze()); |
| 103 | 107 |
| 104 m_bitmap.setInfo(SkImageInfo::MakeN32(newWidth, newHeight, | 108 m_bitmap.setInfo(SkImageInfo::MakeN32(newWidth, newHeight, |
| 105 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType)); | 109 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType, colorS
pace)); |
| 106 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) | 110 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) |
| 107 return false; | 111 return false; |
| 108 | 112 |
| 109 zeroFillPixelData(); | 113 zeroFillPixelData(); |
| 110 return true; | 114 return true; |
| 111 } | 115 } |
| 112 | 116 |
| 113 bool ImageFrame::hasAlpha() const | 117 bool ImageFrame::hasAlpha() const |
| 114 { | 118 { |
| 115 return m_hasAlpha; | 119 return m_hasAlpha; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 // If the frame is not fully loaded, there will be transparent pixels, | 152 // If the frame is not fully loaded, there will be transparent pixels, |
| 149 // so we can't tell skia we're opaque, even for image types that logically | 153 // so we can't tell skia we're opaque, even for image types that logically |
| 150 // always are (e.g. jpeg). | 154 // always are (e.g. jpeg). |
| 151 if (!m_hasAlpha && m_status == FrameComplete) | 155 if (!m_hasAlpha && m_status == FrameComplete) |
| 152 return kOpaque_SkAlphaType; | 156 return kOpaque_SkAlphaType; |
| 153 | 157 |
| 154 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; | 158 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; |
| 155 } | 159 } |
| 156 | 160 |
| 157 } // namespace blink | 161 } // namespace blink |
| OLD | NEW |