1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef SKIA_EXT_LAZY_PIXEL_REF_H_ 6 #define SKIA_EXT_LAZY_PIXEL_REF_H_ 7 8 #include "third_party/skia/include/core/SkPixelRef.h" 9 #include "third_party/skia/include/core/SkRect.h" 10 11 namespace skia { 12 13 // This class extends SkPixelRef to facilitate lazy image decoding on the impl 14 // thread. 15 class SK_API LazyPixelRef : public SkPixelRef { 16 public: 17 #ifdef SK_SUPPORT_LEGACY_PIXELREF_CONSTRUCTOR 18 // DEPRECATED -- will remove once blink updates to pass info 19 LazyPixelRef(); 20 #endif 21 22 explicit LazyPixelRef(const SkImageInfo& info); 23 virtual ~LazyPixelRef(); 24 25 struct PrepareParams { 26 // Clipping rect for this pixel ref. 27 SkIRect clip_rect; 28 }; 29 30 // Request the ImageDecodingStore to prepare image decoding for the 31 // given clipping rect. Returns true is succeeded, or false otherwise. 32 virtual bool PrepareToDecode(const PrepareParams& params) = 0; 33 34 // Returns true if this pixel ref is already in the ImageDecodingStore's 35 // cache, false otherwise. Much cheaper than PrepareToDecode(). 36 virtual bool MaybeDecoded() = 0; 37 38 // Start decoding the image. 39 virtual void Decode() = 0; 40 }; 41 42 } // namespace skia 43 44 #endif // SKIA_EXT_LAZY_PIXEL_REF_H_ 45