| 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 bool ImageFrame::copyBitmapData(const ImageFrame& other) | 86 bool ImageFrame::copyBitmapData(const ImageFrame& other) |
| 87 { | 87 { |
| 88 if (this == &other) | 88 if (this == &other) |
| 89 return true; | 89 return true; |
| 90 | 90 |
| 91 m_hasAlpha = other.m_hasAlpha; | 91 m_hasAlpha = other.m_hasAlpha; |
| 92 m_bitmap.reset(); | 92 m_bitmap.reset(); |
| 93 return other.m_bitmap.copyTo(&m_bitmap, other.m_bitmap.colorType()); | 93 return other.m_bitmap.copyTo(&m_bitmap, other.m_bitmap.colorType()); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void ImageFrame::takeBitmapData(ImageFrame* other) |
| 97 { |
| 98 DCHECK(other); |
| 99 if (this == other) |
| 100 return; |
| 101 |
| 102 m_hasAlpha = other->m_hasAlpha; |
| 103 m_bitmap.reset(); |
| 104 m_bitmap.swap(other->m_bitmap); |
| 105 other->m_status = FrameEmpty; |
| 106 } |
| 107 |
| 96 bool ImageFrame::setSize(int newWidth, int newHeight) | 108 bool ImageFrame::setSize(int newWidth, int newHeight) |
| 97 { | 109 { |
| 98 // setSize() should only be called once, it leaks memory otherwise. | 110 // setSize() should only be called once, it leaks memory otherwise. |
| 99 ASSERT(!width() && !height()); | 111 ASSERT(!width() && !height()); |
| 100 | 112 |
| 101 m_bitmap.setInfo(SkImageInfo::MakeN32(newWidth, newHeight, | 113 m_bitmap.setInfo(SkImageInfo::MakeN32(newWidth, newHeight, |
| 102 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType)); | 114 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType)); |
| 103 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) | 115 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) |
| 104 return false; | 116 return false; |
| 105 | 117 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // If the frame is not fully loaded, there will be transparent pixels, | 157 // If the frame is not fully loaded, there will be transparent pixels, |
| 146 // so we can't tell skia we're opaque, even for image types that logically | 158 // so we can't tell skia we're opaque, even for image types that logically |
| 147 // always are (e.g. jpeg). | 159 // always are (e.g. jpeg). |
| 148 if (!m_hasAlpha && m_status == FrameComplete) | 160 if (!m_hasAlpha && m_status == FrameComplete) |
| 149 return kOpaque_SkAlphaType; | 161 return kOpaque_SkAlphaType; |
| 150 | 162 |
| 151 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; | 163 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; |
| 152 } | 164 } |
| 153 | 165 |
| 154 } // namespace blink | 166 } // namespace blink |
| OLD | NEW |