gfx/skia/trunk/include/utils/SkCanvasStateUtils.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 SkCanvasStateUtils_DEFINED
michael@0 9 #define SkCanvasStateUtils_DEFINED
michael@0 10
michael@0 11 #include "SkCanvas.h"
michael@0 12
michael@0 13 class SkCanvasState;
michael@0 14
michael@0 15 /**
michael@0 16 * A set of functions that are useful for copying an SkCanvas across a library
michael@0 17 * boundary where the Skia libraries on either side of the boundary may not be
michael@0 18 * version identical. The expected usage is outline below...
michael@0 19 *
michael@0 20 * Lib Boundary
michael@0 21 * CaptureCanvasState(...) |||
michael@0 22 * SkCanvas --> SkCanvasState |||
michael@0 23 * ||| CreateFromCanvasState(...)
michael@0 24 * ||| SkCanvasState --> SkCanvas`
michael@0 25 * ||| Draw into SkCanvas`
michael@0 26 * ||| Unref SkCanvas`
michael@0 27 * ReleaseCanvasState(...) |||
michael@0 28 *
michael@0 29 */
michael@0 30 namespace SkCanvasStateUtils {
michael@0 31 /**
michael@0 32 * Captures the current state of the canvas into an opaque ptr that is safe
michael@0 33 * to pass between different instances of Skia (which may or may not be the
michael@0 34 * same version). The function will return NULL in the event that one of the
michael@0 35 * following conditions are true.
michael@0 36 * 1) the canvas device type is not supported (currently only raster is supported)
michael@0 37 * 2) the canvas clip type is not supported (currently only non-AA clips are supported)
michael@0 38 *
michael@0 39 * It is recommended that the original canvas also not be used until all
michael@0 40 * canvases that have been created using its captured state have been dereferenced.
michael@0 41 *
michael@0 42 * Finally, it is important to note that any draw filters attached to the
michael@0 43 * canvas are NOT currently captured.
michael@0 44 *
michael@0 45 * @param canvas The canvas you wish to capture the current state of.
michael@0 46 * @return NULL or an opaque ptr that can be passed to CreateFromCanvasState
michael@0 47 * to reconstruct the canvas. The caller is responsible for calling
michael@0 48 * ReleaseCanvasState to free the memory associated with this state.
michael@0 49 */
michael@0 50 SK_API SkCanvasState* CaptureCanvasState(SkCanvas* canvas);
michael@0 51
michael@0 52 /**
michael@0 53 * Create a new SkCanvas from the captured state of another SkCanvas. The
michael@0 54 * function will return NULL in the event that one of the
michael@0 55 * following conditions are true.
michael@0 56 * 1) the captured state is in an unrecognized format
michael@0 57 * 2) the captured canvas device type is not supported
michael@0 58 *
michael@0 59 * @param canvas The canvas you wish to capture the current state of.
michael@0 60 * @return NULL or an SkCanvas* whose devices and matrix/clip state are
michael@0 61 * identical to the captured canvas. The caller is responsible for
michael@0 62 * calling unref on the SkCanvas.
michael@0 63 */
michael@0 64 SK_API SkCanvas* CreateFromCanvasState(const SkCanvasState* state);
michael@0 65
michael@0 66 /**
michael@0 67 * Free the memory associated with the captured canvas state. The state
michael@0 68 * should not be released until all SkCanvas objects created using that
michael@0 69 * state have been dereferenced.
michael@0 70 *
michael@0 71 * @param state The captured state you wish to dispose of.
michael@0 72 */
michael@0 73 SK_API void ReleaseCanvasState(SkCanvasState* state);
michael@0 74 };
michael@0 75
michael@0 76 #endif

mercurial