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) Research In Motion Limited 2009-2010. All rights reserved. | 3 * Copyright (C) Research In Motion Limited 2009-2010. All rights reserved. |
| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 90 // These do not touch other metadata, only the raw pixel data. | 90 // These do not touch other metadata, only the raw pixel data. |
| 91 void clearPixelData(); | 91 void clearPixelData(); |
| 92 void zeroFillPixelData(); | 92 void zeroFillPixelData(); |
| 93 void zeroFillFrameRect(const IntRect&); | 93 void zeroFillFrameRect(const IntRect&); |
| 94 | 94 |
| 95 // Makes this frame have an independent copy of the provided image's | 95 // Makes this frame have an independent copy of the provided image's |
| 96 // pixel data, so that modifications in one frame are not reflected in | 96 // pixel data, so that modifications in one frame are not reflected in |
| 97 // the other. Returns whether the copy succeeded. | 97 // the other. Returns whether the copy succeeded. |
| 98 bool copyBitmapData(const ImageFrame&); | 98 bool copyBitmapData(const ImageFrame&); |
| 99 | 99 |
| 100 // Moves the bitmap data from the provided frame to this one, leaving the | |
| 101 // provided frame empty. Operation is successful only if bitmap data is not | |
| 102 // marked as done (immutable). Returns whether the move succeeded. | |
| 103 bool takeBitmapDataIfWritable(ImageFrame*); | |
| 104 | |
| 100 // Copies the pixel data at [(startX, startY), (endX, startY)) to the | 105 // Copies the pixel data at [(startX, startY), (endX, startY)) to the |
| 101 // same X-coordinates on each subsequent row up to but not including | 106 // same X-coordinates on each subsequent row up to but not including |
| 102 // endY. | 107 // endY. |
| 103 void copyRowNTimes(int startX, int endX, int startY, int endY) | 108 void copyRowNTimes(int startX, int endX, int startY, int endY) |
| 104 { | 109 { |
| 105 ASSERT(startX < width()); | 110 ASSERT(startX < width()); |
| 106 ASSERT(endX <= width()); | 111 ASSERT(endX <= width()); |
| 107 ASSERT(startY < height()); | 112 ASSERT(startY < height()); |
| 108 ASSERT(endY <= height()); | 113 ASSERT(endY <= height()); |
| 109 const int rowBytes = (endX - startX) * sizeof(PixelData); | 114 const int rowBytes = (endX - startX) * sizeof(PixelData); |
| 110 const PixelData* const startAddr = getAddr(startX, startY); | 115 const PixelData* const startAddr = getAddr(startX, startY); |
| 111 for (int destY = startY + 1; destY < endY; ++destY) | 116 for (int destY = startY + 1; destY < endY; ++destY) |
| 112 memcpy(getAddr(startX, destY), startAddr, rowBytes); | 117 memcpy(getAddr(startX, destY), startAddr, rowBytes); |
| 113 } | 118 } |
| 114 | 119 |
| 115 // Allocates space for the pixel data. Must be called before any pixels | 120 // Allocates space for the pixel data. Must be called before any pixels |
| 116 // are written. Must only be called once. Returns whether allocation | 121 // are written. Must only be called once. Returns whether allocation |
| 117 // succeeded. | 122 // succeeded. |
| 118 bool setSizeAndColorProfile(int newWidth, int newHeight, const ICCProfile& n ewIccProfile); | 123 bool setSizeAndColorProfile(int newWidth, int newHeight, const ICCProfile& n ewIccProfile); |
| 119 | 124 |
| 120 bool hasAlpha() const; | 125 bool hasAlpha() const; |
| 121 const IntRect& originalFrameRect() const { return m_originalFrameRect; } | 126 const IntRect& originalFrameRect() const { return m_originalFrameRect; } |
| 122 Status getStatus() const { return m_status; } | 127 Status getStatus() const { return m_status; } |
| 123 unsigned duration() const { return m_duration; } | 128 unsigned duration() const { return m_duration; } |
| 124 DisposalMethod getDisposalMethod() const { return m_disposalMethod; } | 129 DisposalMethod getDisposalMethod() const { return m_disposalMethod; } |
| 125 AlphaBlendSource getAlphaBlendSource() const { return m_alphaBlendSource; } | 130 AlphaBlendSource getAlphaBlendSource() const { return m_alphaBlendSource; } |
| 126 bool premultiplyAlpha() const { return m_premultiplyAlpha; } | 131 bool premultiplyAlpha() const { return m_premultiplyAlpha; } |
| 127 SkBitmap::Allocator* allocator() const { return m_allocator; } | 132 SkBitmap::Allocator* allocator() const { return m_allocator; } |
| 128 const SkBitmap& bitmap() const { return m_bitmap; } | 133 |
| 134 // Returns the bitmap that is the output of decoding. | |
| 135 // If the decoding is complete, sets the bitmap status to immutable if | |
| 136 // |setImmutableIfDone| is true. | |
| 137 // When |setImmutableIfDone| is false, bitmap is not sealed before returned | |
| 138 // and that enables optimization - saving a bitmap copy per frame when | |
| 139 // decoding animations. See also takeBitmapDataIfWritable. | |
|
Peter Kasting
2016/08/26 19:04:04
As a reader, I'm wondering why we would ever want
aleksandar.stojiljkovic
2016/08/26 21:53:51
It is convenient that bitmap carry information abo
Peter Kasting
2016/08/27 04:19:58
What does "taking it a step back for one of the cl
aleksandar.stojiljkovic
2016/08/28 08:58:31
That sentence could be ignored - it just means tha
| |
| 140 const SkBitmap& bitmap(bool setImmutableIfDone = true); | |
|
Peter Kasting
2016/08/26 19:04:04
Nit: This is named like a simple accessor, but it
aleksandar.stojiljkovic
2016/08/26 21:53:51
It would be clear if we have additional accessor t
Peter Kasting
2016/08/27 04:19:58
That second function still looks like a cheap acce
aleksandar.stojiljkovic
2016/08/28 08:58:31
Done.
bitmap() is back to original "cheap accessor
| |
| 141 | |
| 129 // Returns true if the pixels changed, but the bitmap has not yet been notif ied. | 142 // Returns true if the pixels changed, but the bitmap has not yet been notif ied. |
| 130 bool pixelsChanged() const { return m_pixelsChanged; } | 143 bool pixelsChanged() const { return m_pixelsChanged; } |
| 131 size_t requiredPreviousFrameIndex() const { return m_requiredPreviousFrameIn dex; } | 144 size_t requiredPreviousFrameIndex() const { return m_requiredPreviousFrameIn dex; } |
| 132 void setHasAlpha(bool alpha); | 145 void setHasAlpha(bool alpha); |
| 133 void setOriginalFrameRect(const IntRect& r) { m_originalFrameRect = r; } | 146 void setOriginalFrameRect(const IntRect& r) { m_originalFrameRect = r; } |
| 134 void setStatus(Status); | 147 void setStatus(Status); |
| 135 void setDuration(unsigned duration) { m_duration = duration; } | 148 void setDuration(unsigned duration) { m_duration = duration; } |
| 136 void setDisposalMethod(DisposalMethod disposalMethod) { m_disposalMethod = d isposalMethod; } | 149 void setDisposalMethod(DisposalMethod disposalMethod) { m_disposalMethod = d isposalMethod; } |
| 137 void setAlphaBlendSource(AlphaBlendSource alphaBlendSource) { m_alphaBlendSo urce = alphaBlendSource; } | 150 void setAlphaBlendSource(AlphaBlendSource alphaBlendSource) { m_alphaBlendSo urce = alphaBlendSource; } |
| 138 void setPremultiplyAlpha(bool premultiplyAlpha) { m_premultiplyAlpha = premu ltiplyAlpha; } | 151 void setPremultiplyAlpha(bool premultiplyAlpha) { m_premultiplyAlpha = premu ltiplyAlpha; } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 // The frame that must be decoded before this frame can be decoded. | 230 // The frame that must be decoded before this frame can be decoded. |
| 218 // WTF::kNotFound if this frame doesn't require any previous frame. | 231 // WTF::kNotFound if this frame doesn't require any previous frame. |
| 219 // This is used by ImageDecoder::clearCacheExceptFrame(), and will never | 232 // This is used by ImageDecoder::clearCacheExceptFrame(), and will never |
| 220 // be read for image formats that do not have multiple frames. | 233 // be read for image formats that do not have multiple frames. |
| 221 size_t m_requiredPreviousFrameIndex; | 234 size_t m_requiredPreviousFrameIndex; |
| 222 }; | 235 }; |
| 223 | 236 |
| 224 } // namespace blink | 237 } // namespace blink |
| 225 | 238 |
| 226 #endif | 239 #endif |
| OLD | NEW |