| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google 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 * | 7 * |
| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #ifndef LazyDecodingPixelRef_h | 26 #ifndef LazyDecodingPixelRef_h |
| 27 #define LazyDecodingPixelRef_h | 27 #define LazyDecodingPixelRef_h |
| 28 | 28 |
| 29 #include "SkFlattenableBuffers.h" | 29 #include "SkFlattenableBuffers.h" |
| 30 #include "SkPixelRef.h" | 30 #include "SkPixelRef.h" |
| 31 #include "SkRect.h" | 31 #include "SkRect.h" |
| 32 #include "SkSize.h" | 32 #include "SkSize.h" |
| 33 #include "SkTypes.h" | 33 #include "SkTypes.h" |
| 34 #include "skia/ext/lazy_pixel_ref.h" | 34 #include "skia/ext/lazy_pixel_ref.h" |
| 35 |
| 35 #include "wtf/RefPtr.h" | 36 #include "wtf/RefPtr.h" |
| 36 #include "wtf/ThreadingPrimitives.h" | |
| 37 | 37 |
| 38 using skia::LazyPixelRef; | 38 using skia::LazyPixelRef; |
| 39 | 39 |
| 40 class SkData; | 40 class SkData; |
| 41 | 41 |
| 42 namespace WebCore { | 42 namespace WebCore { |
| 43 | 43 |
| 44 class ImageFrameGenerator; | 44 class ImageFrameGenerator; |
| 45 class ScaledImageFragment; | 45 class ScaledImageFragment; |
| 46 | 46 |
| 47 class LazyDecodingPixelRef : public LazyPixelRef { | 47 class LazyDecodingPixelRef : public LazyPixelRef { |
| 48 public: | 48 public: |
| 49 LazyDecodingPixelRef(PassRefPtr<ImageFrameGenerator>, const SkISize& scaledS
ize, const SkIRect& scaledSubset); | 49 LazyDecodingPixelRef(PassRefPtr<ImageFrameGenerator>, const SkISize& scaledS
ize, size_t index, const SkIRect& scaledSubset); |
| 50 virtual ~LazyDecodingPixelRef(); | 50 virtual ~LazyDecodingPixelRef(); |
| 51 | 51 |
| 52 SK_DECLARE_UNFLATTENABLE_OBJECT() | 52 SK_DECLARE_UNFLATTENABLE_OBJECT() |
| 53 | 53 |
| 54 PassRefPtr<ImageFrameGenerator> frameGenerator() const { return m_frameGener
ator; } | 54 PassRefPtr<ImageFrameGenerator> frameGenerator() const { return m_frameGener
ator; } |
| 55 size_t frameIndex() const { return m_frameIndex; } |
| 55 bool isScaled(const SkISize& fullSize) const; | 56 bool isScaled(const SkISize& fullSize) const; |
| 56 bool isClipped() const; | 57 bool isClipped() const; |
| 57 | 58 |
| 58 // Returns true if the image might already be decoded in the cache. | 59 // Returns true if the image might already be decoded in the cache. |
| 59 // Optimistic version of PrepareToDecode; requires less locking. | 60 // Optimistic version of PrepareToDecode; requires less locking. |
| 60 virtual bool MaybeDecoded(); | 61 virtual bool MaybeDecoded(); |
| 61 virtual bool PrepareToDecode(const LazyPixelRef::PrepareParams&); | 62 virtual bool PrepareToDecode(const LazyPixelRef::PrepareParams&); |
| 62 virtual void Decode(); | 63 virtual void Decode(); |
| 63 | 64 |
| 64 protected: | 65 protected: |
| 65 // SkPixelRef implementation. | 66 // SkPixelRef implementation. |
| 66 virtual void* onLockPixels(SkColorTable**); | 67 virtual void* onLockPixels(SkColorTable**); |
| 67 virtual void onUnlockPixels(); | 68 virtual void onUnlockPixels(); |
| 68 virtual bool onLockPixelsAreWritable() const; | 69 virtual bool onLockPixelsAreWritable() const; |
| 69 | 70 |
| 70 virtual SkData* onRefEncodedData() SK_OVERRIDE; | 71 virtual SkData* onRefEncodedData() SK_OVERRIDE; |
| 71 | 72 |
| 72 private: | 73 private: |
| 73 RefPtr<ImageFrameGenerator> m_frameGenerator; | 74 RefPtr<ImageFrameGenerator> m_frameGenerator; |
| 75 size_t m_frameIndex; |
| 74 SkISize m_scaledSize; | 76 SkISize m_scaledSize; |
| 75 SkIRect m_scaledSubset; | 77 SkIRect m_scaledSubset; |
| 76 | 78 |
| 77 const ScaledImageFragment* m_lockedCachedImage; | 79 const ScaledImageFragment* m_lockedCachedImage; |
| 78 Mutex m_mutex; | |
| 79 }; | 80 }; |
| 80 | 81 |
| 81 } // namespace WebCore | 82 } // namespace WebCore |
| 82 | 83 |
| 83 #endif // LazyDecodingPixelRef_h_ | 84 #endif // LazyDecodingPixelRef_h_ |
| OLD | NEW |