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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 m_bitmap.reset(); | 100 m_bitmap.reset(); |
101 return other.m_bitmap.copyTo(&m_bitmap, other.m_bitmap.colorType()); | 101 return other.m_bitmap.copyTo(&m_bitmap, other.m_bitmap.colorType()); |
102 } | 102 } |
103 | 103 |
104 bool ImageFrame::setSize(int newWidth, int newHeight) | 104 bool ImageFrame::setSize(int newWidth, int newHeight) |
105 { | 105 { |
106 // setSize() should only be called once, it leaks memory otherwise. | 106 // setSize() should only be called once, it leaks memory otherwise. |
107 ASSERT(!width() && !height()); | 107 ASSERT(!width() && !height()); |
108 | 108 |
109 m_bitmap.setInfo(SkImageInfo::MakeN32Premul(newWidth, newHeight)); | 109 m_bitmap.setInfo(SkImageInfo::MakeN32Premul(newWidth, newHeight)); |
110 if (!m_bitmap.allocPixels(m_allocator, 0)) | 110 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) |
111 return false; | 111 return false; |
112 | 112 |
113 zeroFillPixelData(); | 113 zeroFillPixelData(); |
114 return true; | 114 return true; |
115 } | 115 } |
116 | 116 |
117 PassRefPtr<NativeImageSkia> ImageFrame::asNewNativeImage() const | 117 PassRefPtr<NativeImageSkia> ImageFrame::asNewNativeImage() const |
118 { | 118 { |
119 return NativeImageSkia::create(m_bitmap); | 119 return NativeImageSkia::create(m_bitmap); |
120 } | 120 } |
(...skipping 30 matching lines...) Expand all Loading... |
151 void ImageFrame::zeroFillFrameRect(const IntRect& rect) | 151 void ImageFrame::zeroFillFrameRect(const IntRect& rect) |
152 { | 152 { |
153 if (rect.isEmpty()) | 153 if (rect.isEmpty()) |
154 return; | 154 return; |
155 | 155 |
156 m_bitmap.eraseArea(rect, SkColorSetARGB(0, 0, 0, 0)); | 156 m_bitmap.eraseArea(rect, SkColorSetARGB(0, 0, 0, 0)); |
157 setHasAlpha(true); | 157 setHasAlpha(true); |
158 } | 158 } |
159 | 159 |
160 } // namespace blink | 160 } // namespace blink |
OLD | NEW |