gfx/skia/trunk/src/core/SkConfig8888.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 2011 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 SkConfig8888_DEFINED
     9 #define SkConfig8888_DEFINED
    11 #include "SkCanvas.h"
    12 #include "SkColorPriv.h"
    14 /**
    15  * Converts pixels from one Config8888 to another Config8888
    16  */
    17 void SkConvertConfig8888Pixels(uint32_t* dstPixels,
    18                                size_t dstRowBytes,
    19                                SkCanvas::Config8888 dstConfig,
    20                                const uint32_t* srcPixels,
    21                                size_t srcRowBytes,
    22                                SkCanvas::Config8888 srcConfig,
    23                                int width,
    24                                int height);
    26 /**
    27  * Packs a, r, g, b, values into byte order specified by config.
    28  */
    29 uint32_t SkPackConfig8888(SkCanvas::Config8888 config,
    30                           uint32_t a,
    31                           uint32_t r,
    32                           uint32_t g,
    33                           uint32_t b);
    35 ///////////////////////////////////////////////////////////////////////////////
    36 // Implementation
    38 namespace {
    40 /**
    41   Copies all pixels from a bitmap to a dst ptr with a given rowBytes and
    42   Config8888. The bitmap must have kARGB_8888_Config.
    43  */
    45 static inline void SkCopyBitmapToConfig8888(uint32_t* dstPixels,
    46                                      size_t dstRowBytes,
    47                                      SkCanvas::Config8888 dstConfig8888,
    48                                      const SkBitmap& srcBmp) {
    49     SkASSERT(SkBitmap::kARGB_8888_Config == srcBmp.config());
    50     SkAutoLockPixels alp(srcBmp);
    51     int w = srcBmp.width();
    52     int h = srcBmp.height();
    53     size_t srcRowBytes = srcBmp.rowBytes();
    54     const uint32_t* srcPixels = reinterpret_cast<uint32_t*>(srcBmp.getPixels());
    56     SkConvertConfig8888Pixels(dstPixels, dstRowBytes, dstConfig8888, srcPixels, srcRowBytes, SkCanvas::kNative_Premul_Config8888, w, h);
    57 }
    59 /**
    60   Copies over all pixels in a bitmap from a src ptr with a given rowBytes and
    61   Config8888. The bitmap must have pixels and be kARGB_8888_Config.
    62  */
    63 static inline void SkCopyConfig8888ToBitmap(const SkBitmap& dstBmp,
    64                                      const uint32_t* srcPixels,
    65                                      size_t srcRowBytes,
    66                                      SkCanvas::Config8888 srcConfig8888) {
    67     SkASSERT(SkBitmap::kARGB_8888_Config == dstBmp.config());
    68     SkAutoLockPixels alp(dstBmp);
    69     int w = dstBmp.width();
    70     int h = dstBmp.height();
    71     size_t dstRowBytes = dstBmp.rowBytes();
    72     uint32_t* dstPixels = reinterpret_cast<uint32_t*>(dstBmp.getPixels());
    74     SkConvertConfig8888Pixels(dstPixels, dstRowBytes, SkCanvas::kNative_Premul_Config8888, srcPixels, srcRowBytes, srcConfig8888, w, h);
    75 }
    77 }
    79 #endif

mercurial