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 if (this == &other) |
| 99 return; |
| 100 |
| 101 m_hasAlpha = other.m_hasAlpha; |
| 102 m_bitmap.reset(); |
| 103 m_bitmap.swap(other.m_bitmap); |
| 104 other.m_status = FrameEmpty; |
| 105 } |
| 106 |
96 bool ImageFrame::setSize(int newWidth, int newHeight) | 107 bool ImageFrame::setSize(int newWidth, int newHeight) |
97 { | 108 { |
98 // setSize() should only be called once, it leaks memory otherwise. | 109 // setSize() should only be called once, it leaks memory otherwise. |
99 ASSERT(!width() && !height()); | 110 ASSERT(!width() && !height()); |
100 | 111 |
101 m_bitmap.setInfo(SkImageInfo::MakeN32(newWidth, newHeight, | 112 m_bitmap.setInfo(SkImageInfo::MakeN32(newWidth, newHeight, |
102 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType)); | 113 m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType)); |
103 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) | 114 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) |
104 return false; | 115 return false; |
105 | 116 |
(...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, | 156 // 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 | 157 // so we can't tell skia we're opaque, even for image types that logically |
147 // always are (e.g. jpeg). | 158 // always are (e.g. jpeg). |
148 if (!m_hasAlpha && m_status == FrameComplete) | 159 if (!m_hasAlpha && m_status == FrameComplete) |
149 return kOpaque_SkAlphaType; | 160 return kOpaque_SkAlphaType; |
150 | 161 |
151 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; | 162 return m_premultiplyAlpha ? kPremul_SkAlphaType : kUnpremul_SkAlphaType; |
152 } | 163 } |
153 | 164 |
154 } // namespace blink | 165 } // namespace blink |
OLD | NEW |