gfx/skia/trunk/src/lazy/SkCachingPixelRef.h

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 /*
michael@0 2 * Copyright 2013 Google Inc.
michael@0 3 *
michael@0 4 * Use of this source code is governed by a BSD-style license that can be
michael@0 5 * found in the LICENSE file.
michael@0 6 */
michael@0 7
michael@0 8 #ifndef SkCachingPixelRef_DEFINED
michael@0 9 #define SkCachingPixelRef_DEFINED
michael@0 10
michael@0 11 #include "SkImageInfo.h"
michael@0 12 #include "SkImageGenerator.h"
michael@0 13 #include "SkPixelRef.h"
michael@0 14
michael@0 15 class SkColorTable;
michael@0 16
michael@0 17 /**
michael@0 18 * PixelRef which defers decoding until SkBitmap::lockPixels() is
michael@0 19 * called. Caches the decoded images in the global
michael@0 20 * SkScaledImageCache. When the pixels are unlocked, this cache may
michael@0 21 * or be destroyed before the next lock. If so, onLockPixels will
michael@0 22 * attempt to re-decode.
michael@0 23 *
michael@0 24 * Decoding is handled by the SkImageGenerator
michael@0 25 */
michael@0 26 class SkCachingPixelRef : public SkPixelRef {
michael@0 27 public:
michael@0 28 SK_DECLARE_INST_COUNT(SkCachingPixelRef)
michael@0 29 /**
michael@0 30 * Takes ownership of SkImageGenerator. If this method fails for
michael@0 31 * whatever reason, it will return false and immediatetely delete
michael@0 32 * the generator. If it succeeds, it will modify destination
michael@0 33 * bitmap.
michael@0 34 *
michael@0 35 * If Install fails or when the SkCachingPixelRef that is
michael@0 36 * installed into destination is destroyed, it will call
michael@0 37 * SkDELETE() on the generator. Therefore, generator should be
michael@0 38 * allocated with SkNEW() or SkNEW_ARGS().
michael@0 39 */
michael@0 40 static bool Install(SkImageGenerator* gen, SkBitmap* dst);
michael@0 41
michael@0 42 protected:
michael@0 43 virtual ~SkCachingPixelRef();
michael@0 44 virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE;
michael@0 45 virtual void onUnlockPixels() SK_OVERRIDE;
michael@0 46 virtual bool onLockPixelsAreWritable() const SK_OVERRIDE { return false; }
michael@0 47
michael@0 48 virtual SkData* onRefEncodedData() SK_OVERRIDE {
michael@0 49 return fImageGenerator->refEncodedData();
michael@0 50 }
michael@0 51 // No need to flatten this object. When flattening an SkBitmap,
michael@0 52 // SkWriteBuffer will check the encoded data and write that
michael@0 53 // instead.
michael@0 54 // Future implementations of SkWriteBuffer will need to
michael@0 55 // special case for onRefEncodedData as well.
michael@0 56 SK_DECLARE_UNFLATTENABLE_OBJECT()
michael@0 57
michael@0 58 private:
michael@0 59 SkImageGenerator* const fImageGenerator;
michael@0 60 bool fErrorInDecoding;
michael@0 61 void* fScaledCacheId;
michael@0 62 const size_t fRowBytes;
michael@0 63
michael@0 64 SkCachingPixelRef(const SkImageInfo&, SkImageGenerator*, size_t rowBytes);
michael@0 65
michael@0 66 typedef SkPixelRef INHERITED;
michael@0 67 };
michael@0 68
michael@0 69 #endif // SkCachingPixelRef_DEFINED

mercurial