gfx/skia/trunk/src/animator/SkDisplayRandom.cpp

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 /*
michael@0 3 * Copyright 2006 The Android Open Source Project
michael@0 4 *
michael@0 5 * Use of this source code is governed by a BSD-style license that can be
michael@0 6 * found in the LICENSE file.
michael@0 7 */
michael@0 8
michael@0 9
michael@0 10 #include "SkDisplayRandom.h"
michael@0 11 #include "SkInterpolator.h"
michael@0 12
michael@0 13 enum SkDisplayRandom_Properties {
michael@0 14 SK_PROPERTY(random),
michael@0 15 SK_PROPERTY(seed)
michael@0 16 };
michael@0 17
michael@0 18 #if SK_USE_CONDENSED_INFO == 0
michael@0 19
michael@0 20 const SkMemberInfo SkDisplayRandom::fInfo[] = {
michael@0 21 SK_MEMBER(blend, Float),
michael@0 22 SK_MEMBER(max, Float),
michael@0 23 SK_MEMBER(min, Float),
michael@0 24 SK_MEMBER_DYNAMIC_PROPERTY(random, Float),
michael@0 25 SK_MEMBER_PROPERTY(seed, Int)
michael@0 26 };
michael@0 27
michael@0 28 #endif
michael@0 29
michael@0 30 DEFINE_GET_MEMBER(SkDisplayRandom);
michael@0 31
michael@0 32 SkDisplayRandom::SkDisplayRandom() : blend(0), min(0), max(SK_Scalar1) {
michael@0 33 }
michael@0 34
michael@0 35 #ifdef SK_DUMP_ENABLED
michael@0 36 void SkDisplayRandom::dump(SkAnimateMaker* maker) {
michael@0 37 dumpBase(maker);
michael@0 38 SkDebugf("min=\"%g\" ", SkScalarToFloat(min));
michael@0 39 SkDebugf("max=\"%g\" ", SkScalarToFloat(max));
michael@0 40 SkDebugf("blend=\"%g\" ", SkScalarToFloat(blend));
michael@0 41 SkDebugf("/>\n");
michael@0 42 }
michael@0 43 #endif
michael@0 44
michael@0 45 bool SkDisplayRandom::getProperty(int index, SkScriptValue* value) const {
michael@0 46 switch(index) {
michael@0 47 case SK_PROPERTY(random): {
michael@0 48 SkScalar random = fRandom.nextUScalar1();
michael@0 49 SkScalar relativeT = SkUnitCubicInterp(random, SK_Scalar1 - blend, 0, 0, SK_Scalar1 - blend);
michael@0 50 value->fOperand.fScalar = min + SkScalarMul(max - min, relativeT);
michael@0 51 value->fType = SkType_Float;
michael@0 52 return true;
michael@0 53 }
michael@0 54 default:
michael@0 55 SkASSERT(0);
michael@0 56 }
michael@0 57 return false;
michael@0 58 }
michael@0 59
michael@0 60 bool SkDisplayRandom::setProperty(int index, SkScriptValue& value) {
michael@0 61 SkASSERT(index == SK_PROPERTY(seed));
michael@0 62 SkASSERT(value.fType == SkType_Int);
michael@0 63 fRandom.setSeed(value.fOperand.fS32);
michael@0 64 return true;
michael@0 65 }

mercurial