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.

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

mercurial