| 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 16 matching lines...) Expand all Loading... |
| 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 |
| 36 #include <wtf/RefPtr.h> | 36 #include <wtf/RefPtr.h> |
| 37 #include <wtf/ThreadingPrimitives.h> | |
| 38 | 37 |
| 39 using skia::LazyPixelRef; | 38 using skia::LazyPixelRef; |
| 40 | 39 |
| 41 class SkData; | 40 class SkData; |
| 42 | 41 |
| 43 namespace WebCore { | 42 namespace WebCore { |
| 44 | 43 |
| 45 class ImageFrameGenerator; | 44 class ImageFrameGenerator; |
| 46 class ScaledImageFragment; | 45 class ScaledImageFragment; |
| 47 | 46 |
| 48 class LazyDecodingPixelRef : public LazyPixelRef { | 47 class LazyDecodingPixelRef : public LazyPixelRef { |
| 49 public: | 48 public: |
| 50 LazyDecodingPixelRef(PassRefPtr<ImageFrameGenerator>, const SkISize& scaledS
ize, const SkIRect& scaledSubset); | 49 LazyDecodingPixelRef(PassRefPtr<ImageFrameGenerator>, const SkISize& scaledS
ize, size_t index, const SkIRect& scaledSubset); |
| 51 virtual ~LazyDecodingPixelRef(); | 50 virtual ~LazyDecodingPixelRef(); |
| 52 | 51 |
| 53 SK_DECLARE_UNFLATTENABLE_OBJECT() | 52 SK_DECLARE_UNFLATTENABLE_OBJECT() |
| 54 | 53 |
| 55 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; } |
| 56 bool isScaled(const SkISize& fullSize) const; | 56 bool isScaled(const SkISize& fullSize) const; |
| 57 bool isClipped() const; | 57 bool isClipped() const; |
| 58 | 58 |
| 59 // 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. |
| 60 // Optimistic version of PrepareToDecode; requires less locking. | 60 // Optimistic version of PrepareToDecode; requires less locking. |
| 61 virtual bool MaybeDecoded(); | 61 virtual bool MaybeDecoded(); |
| 62 virtual bool PrepareToDecode(const LazyPixelRef::PrepareParams&); | 62 virtual bool PrepareToDecode(const LazyPixelRef::PrepareParams&); |
| 63 virtual void Decode(); | 63 virtual void Decode(); |
| 64 | 64 |
| 65 protected: | 65 protected: |
| 66 // SkPixelRef implementation. | 66 // SkPixelRef implementation. |
| 67 virtual void* onLockPixels(SkColorTable**); | 67 virtual void* onLockPixels(SkColorTable**); |
| 68 virtual void onUnlockPixels(); | 68 virtual void onUnlockPixels(); |
| 69 virtual bool onLockPixelsAreWritable() const; | 69 virtual bool onLockPixelsAreWritable() const; |
| 70 | 70 |
| 71 virtual SkData* onRefEncodedData() SK_OVERRIDE; | 71 virtual SkData* onRefEncodedData() SK_OVERRIDE; |
| 72 | 72 |
| 73 private: | 73 private: |
| 74 RefPtr<ImageFrameGenerator> m_frameGenerator; | 74 RefPtr<ImageFrameGenerator> m_frameGenerator; |
| 75 size_t m_frameIndex; |
| 75 SkISize m_scaledSize; | 76 SkISize m_scaledSize; |
| 76 SkIRect m_scaledSubset; | 77 SkIRect m_scaledSubset; |
| 77 | 78 |
| 78 const ScaledImageFragment* m_lockedCachedImage; | 79 const ScaledImageFragment* m_lockedCachedImage; |
| 79 Mutex m_mutex; | |
| 80 }; | 80 }; |
| 81 | 81 |
| 82 } // namespace WebCore | 82 } // namespace WebCore |
| 83 | 83 |
| 84 #endif // LazyDecodingPixelRef_h_ | 84 #endif // LazyDecodingPixelRef_h_ |
| OLD | NEW |