gfx/skia/trunk/src/lazy/SkDiscardablePixelRef.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.

     1 /*
     2  * Copyright 2013 Google Inc.
     3  *
     4  * Use of this source code is governed by a BSD-style license that can be
     5  * found in the LICENSE file.
     6  */
     8 #ifndef SkDiscardablePixelRef_DEFINED
     9 #define SkDiscardablePixelRef_DEFINED
    11 #include "SkDiscardableMemory.h"
    12 #include "SkImageGenerator.h"
    13 #include "SkImageInfo.h"
    14 #include "SkPixelRef.h"
    16 /**
    17  *  A PixelRef backed by SkDiscardableMemory, with the ability to
    18  *  re-generate the pixels (via a SkImageGenerator) if the DM is
    19  *  purged.
    20  *
    21  *  Since SkColorTable is reference-counted, we do not support indexed
    22  *  color with this class; there would be no way for the discardable
    23  *  memory system to unref the color table.
    24  */
    25 class SkDiscardablePixelRef : public SkPixelRef {
    26 public:
    27     SK_DECLARE_INST_COUNT(SkDiscardablePixelRef)
    28     SK_DECLARE_UNFLATTENABLE_OBJECT()
    30 protected:
    31     ~SkDiscardablePixelRef();
    33     virtual bool onNewLockPixels(LockRec*) SK_OVERRIDE;
    34     virtual void onUnlockPixels() SK_OVERRIDE;
    35     virtual bool onLockPixelsAreWritable() const SK_OVERRIDE { return false; }
    37     virtual SkData* onRefEncodedData() SK_OVERRIDE {
    38         return fGenerator->refEncodedData();
    39     }
    41 private:
    42     SkImageGenerator* const fGenerator;
    43     SkDiscardableMemory::Factory* const fDMFactory;
    44     const size_t fRowBytes;
    45     // These const members should not change over the life of the
    46     // PixelRef, since the SkBitmap doesn't expect them to change.
    48     SkDiscardableMemory* fDiscardableMemory;
    50     /* Takes ownership of SkImageGenerator. */
    51     SkDiscardablePixelRef(const SkImageInfo&, SkImageGenerator*,
    52                           size_t rowBytes,
    53                           SkDiscardableMemory::Factory* factory);
    55     friend bool SkInstallDiscardablePixelRef(SkImageGenerator*,
    56                                              SkBitmap*,
    57                                              SkDiscardableMemory::Factory*);
    59     typedef SkPixelRef INHERITED;
    60 };
    62 #endif  // SkDiscardablePixelRef_DEFINED

mercurial