| 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 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 bmp.setConfig(SkBitmap::kARGB_8888_Config, other.width(), | 131 bmp.setConfig(SkBitmap::kARGB_8888_Config, other.width(), |
| 132 other.height(), otherBmp.rowBytes()); | 132 other.height(), otherBmp.rowBytes()); |
| 133 bmp.allocPixels(); | 133 bmp.allocPixels(); |
| 134 if (width() > 0 && height() > 0) { | 134 if (width() > 0 && height() > 0) { |
| 135 memcpy(bmp.getAddr32(0, 0), | 135 memcpy(bmp.getAddr32(0, 0), |
| 136 otherBmp.getAddr32(0, 0), | 136 otherBmp.getAddr32(0, 0), |
| 137 otherBmp.rowBytes() * height()); | 137 otherBmp.rowBytes() * height()); |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 | 140 |
| 141 SkBitmap& bitmap() { return m_bitmapRef->bitmap(); } | 141 NativeImageSkia& bitmap() { return m_bitmapRef->bitmap(); } |
| 142 const SkBitmap& bitmap() const { return m_bitmapRef->bitmap(); } | 142 const NativeImageSkia& bitmap() const { return m_bitmapRef->bitmap(); } |
| 143 | 143 |
| 144 // Must be called before any pixels are written. Will return true on | 144 // Must be called before any pixels are written. Will return true on |
| 145 // success, false if the memory allocation fails. | 145 // success, false if the memory allocation fails. |
| 146 bool setSize(int width, int height) { | 146 bool setSize(int width, int height) { |
| 147 // This function should only be called once, it will leak memory | 147 // This function should only be called once, it will leak memory |
| 148 // otherwise. | 148 // otherwise. |
| 149 SkBitmap& bmp = bitmap(); | 149 SkBitmap& bmp = bitmap(); |
| 150 ASSERT(bmp.width() == 0 && bmp.height() == 0); | 150 ASSERT(bmp.width() == 0 && bmp.height() == 0); |
| 151 bmp.setConfig(SkBitmap::kARGB_8888_Config, width, height); | 151 bmp.setConfig(SkBitmap::kARGB_8888_Config, width, height); |
| 152 if (!bmp.allocPixels()) | 152 if (!bmp.allocPixels()) |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 return false; | 294 return false; |
| 295 } | 295 } |
| 296 | 296 |
| 297 IntSize m_size; | 297 IntSize m_size; |
| 298 bool m_sizeAvailable; | 298 bool m_sizeAvailable; |
| 299 }; | 299 }; |
| 300 | 300 |
| 301 } | 301 } |
| 302 | 302 |
| 303 #endif | 303 #endif |
| OLD | NEW |