Chromium Code Reviews| 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 28 matching lines...) Expand all Loading... | |
| 39 , m_premultiplyAlpha(true) | 39 , m_premultiplyAlpha(true) |
| 40 , m_pixelsChanged(false) | 40 , m_pixelsChanged(false) |
| 41 , m_requiredPreviousFrameIndex(kNotFound) | 41 , m_requiredPreviousFrameIndex(kNotFound) |
| 42 { | 42 { |
| 43 } | 43 } |
| 44 | 44 |
| 45 ImageFrame& ImageFrame::operator=(const ImageFrame& other) | 45 ImageFrame& ImageFrame::operator=(const ImageFrame& other) |
| 46 { | 46 { |
| 47 if (this == &other) | 47 if (this == &other) |
| 48 return *this; | 48 return *this; |
| 49 | |
|
scroggo_chromium
2015/10/19 20:41:36
nit: Why did this line get removed?
| |
| 50 m_bitmap = other.m_bitmap; | 49 m_bitmap = other.m_bitmap; |
| 51 // Keep the pixels locked since we will be writing directly into the | 50 // Keep the pixels locked since we will be writing directly into the |
| 52 // bitmap throughout this object's lifetime. | 51 // bitmap throughout this object's lifetime. |
| 53 m_bitmap.lockPixels(); | 52 m_bitmap.lockPixels(); |
| 54 // Be sure to assign this before calling setStatus(), since setStatus() may | 53 // Be sure to assign this before calling setStatus(), since setStatus() may |
| 55 // call notifyBitmapIfPixelsChanged(). | 54 // call notifyBitmapIfPixelsChanged(). |
| 56 m_pixelsChanged = other.m_pixelsChanged; | 55 m_pixelsChanged = other.m_pixelsChanged; |
| 57 setMemoryAllocator(other.allocator()); | 56 setMemoryAllocator(other.allocator()); |
| 58 setOriginalFrameRect(other.originalFrameRect()); | 57 setOriginalFrameRect(other.originalFrameRect()); |
| 59 setStatus(other.status()); | 58 setStatus(other.status()); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 87 bool ImageFrame::copyBitmapData(const ImageFrame& other) | 86 bool ImageFrame::copyBitmapData(const ImageFrame& other) |
| 88 { | 87 { |
| 89 if (this == &other) | 88 if (this == &other) |
| 90 return true; | 89 return true; |
| 91 | 90 |
| 92 m_hasAlpha = other.m_hasAlpha; | 91 m_hasAlpha = other.m_hasAlpha; |
| 93 m_bitmap.reset(); | 92 m_bitmap.reset(); |
| 94 return other.m_bitmap.copyTo(&m_bitmap, other.m_bitmap.colorType()); | 93 return other.m_bitmap.copyTo(&m_bitmap, other.m_bitmap.colorType()); |
| 95 } | 94 } |
| 96 | 95 |
| 97 bool ImageFrame::setSize(int newWidth, int newHeight) | 96 bool ImageFrame::setSize(int newWidth, int newHeight, ColorType bitmapType) |
| 98 { | 97 { |
| 99 // setSize() should only be called once, it leaks memory otherwise. | 98 if (bitmapType == RGBA8888) { |
|
scroggo_chromium
2015/10/19 20:41:36
Was this removed because you intend to call it mor
aleksandar.stojiljkovic
2015/10/20 09:51:12
In current usage, allocation happens in Skia on Sk
| |
| 100 ASSERT(!width() && !height()); | 99 m_bitmap.setInfo(SkImageInfo::MakeN32Premul(newWidth, newHeight)); |
| 100 } else if (bitmapType == RGB565) { | |
| 101 m_bitmap.setInfo(SkImageInfo::Make(newWidth, newHeight, kRGB_565_SkColor Type, kOpaque_SkAlphaType)); | |
| 102 } else { | |
| 103 ASSERT(false); | |
| 104 } | |
| 101 | 105 |
| 102 m_bitmap.setInfo(SkImageInfo::MakeN32Premul(newWidth, newHeight)); | 106 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) { |
|
scroggo_chromium
2015/10/19 20:41:36
I prefer this style personally, but AFAIK braces a
aleksandar.stojiljkovic
2015/10/20 09:51:12
Done.
| |
| 103 if (!m_bitmap.tryAllocPixels(m_allocator, 0)) | |
| 104 return false; | 107 return false; |
| 108 } | |
| 105 | 109 |
| 106 zeroFillPixelData(); | 110 zeroFillPixelData(); |
| 107 return true; | 111 return true; |
| 108 } | 112 } |
| 109 | 113 |
| 110 const SkBitmap& ImageFrame::bitmap() const | 114 const SkBitmap& ImageFrame::bitmap() const |
| 111 { | 115 { |
| 112 return m_bitmap; | 116 return m_bitmap; |
| 113 } | 117 } |
| 114 | 118 |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 144 void ImageFrame::zeroFillFrameRect(const IntRect& rect) | 148 void ImageFrame::zeroFillFrameRect(const IntRect& rect) |
| 145 { | 149 { |
| 146 if (rect.isEmpty()) | 150 if (rect.isEmpty()) |
| 147 return; | 151 return; |
| 148 | 152 |
| 149 m_bitmap.eraseArea(rect, SkColorSetARGB(0, 0, 0, 0)); | 153 m_bitmap.eraseArea(rect, SkColorSetARGB(0, 0, 0, 0)); |
| 150 setHasAlpha(true); | 154 setHasAlpha(true); |
| 151 } | 155 } |
| 152 | 156 |
| 153 } // namespace blink | 157 } // namespace blink |
| OLD | NEW |