gfx/skia/trunk/include/core/SkImageGenerator.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 SkImageGenerator_DEFINED
     9 #define SkImageGenerator_DEFINED
    11 #include "SkDiscardableMemory.h"
    12 #include "SkImageInfo.h"
    14 class SkBitmap;
    15 class SkData;
    16 class SkImageGenerator;
    18 /**
    19  *  Takes ownership of SkImageGenerator.  If this method fails for
    20  *  whatever reason, it will return false and immediatetely delete
    21  *  the generator.  If it succeeds, it will modify destination
    22  *  bitmap.
    23  *
    24  *  If generator is NULL, will safely return false.
    25  *
    26  *  If this fails or when the SkDiscardablePixelRef that is
    27  *  installed into destination is destroyed, it will call
    28  *  SkDELETE() on the generator.  Therefore, generator should be
    29  *  allocated with SkNEW() or SkNEW_ARGS().
    30  *
    31  *  @param destination Upon success, this bitmap will be
    32  *  configured and have a pixelref installed.
    33  *
    34  *  @param factory If not NULL, this object will be used as a
    35  *  source of discardable memory when decoding.  If NULL, then
    36  *  SkDiscardableMemory::Create() will be called.
    37  *
    38  *  @return true iff successful.
    39  */
    40 SK_API bool SkInstallDiscardablePixelRef(SkImageGenerator* generator,
    41                                          SkBitmap* destination,
    42                                          SkDiscardableMemory::Factory* factory = NULL);
    45 /**
    46  *  An interface that allows a purgeable PixelRef (such as a
    47  *  SkDiscardablePixelRef) to decode and re-decode an image as needed.
    48  */
    49 class SK_API SkImageGenerator {
    50 public:
    51     /**
    52      *  The PixelRef which takes ownership of this SkImageGenerator
    53      *  will call the image generator's destructor.
    54      */
    55     virtual ~SkImageGenerator() { }
    57     /**
    58      *  Return a ref to the encoded (i.e. compressed) representation,
    59      *  of this data.
    60      *
    61      *  If non-NULL is returned, the caller is responsible for calling
    62      *  unref() on the data when it is finished.
    63      */
    64     virtual SkData* refEncodedData() { return NULL; }
    66     /**
    67      *  Return some information about the image, allowing the owner of
    68      *  this object to allocate pixels.
    69      *
    70      *  Repeated calls to this function should give the same results,
    71      *  allowing the PixelRef to be immutable.
    72      *
    73      *  @return false if anything goes wrong.
    74      */
    75     virtual bool getInfo(SkImageInfo* info) = 0;
    77     /**
    78      *  Decode into the given pixels, a block of memory of size at
    79      *  least (info.fHeight - 1) * rowBytes + (info.fWidth *
    80      *  bytesPerPixel)
    81      *
    82      *  Repeated calls to this function should give the same results,
    83      *  allowing the PixelRef to be immutable.
    84      *
    85      *  @param info A description of the format (config, size)
    86      *         expected by the caller.  This can simply be identical
    87      *         to the info returned by getInfo().
    88      *
    89      *         This contract also allows the caller to specify
    90      *         different output-configs, which the implementation can
    91      *         decide to support or not.
    92      *
    93      *  @return false if anything goes wrong or if the image info is
    94      *          unsupported.
    95      */
    96     virtual bool getPixels(const SkImageInfo& info,
    97                            void* pixels,
    98                            size_t rowBytes) = 0;
    99 };
   101 #endif  // SkImageGenerator_DEFINED

mercurial