gfx/skia/trunk/src/animator/SkSnapshot.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 "SkTypes.h"
michael@0 11
michael@0 12 #include "SkSnapshot.h"
michael@0 13 #include "SkAnimateMaker.h"
michael@0 14 #include "SkCanvas.h"
michael@0 15 #include "SkImageEncoder.h"
michael@0 16
michael@0 17 #if SK_USE_CONDENSED_INFO == 0
michael@0 18
michael@0 19 const SkMemberInfo SkSnapshot::fInfo[] = {
michael@0 20 SK_MEMBER(filename, String),
michael@0 21 SK_MEMBER(quality, Float),
michael@0 22 SK_MEMBER(sequence, Boolean),
michael@0 23 SK_MEMBER(type, BitmapEncoding)
michael@0 24 };
michael@0 25
michael@0 26 #endif
michael@0 27
michael@0 28 DEFINE_GET_MEMBER(SkSnapshot);
michael@0 29
michael@0 30 SkSnapshot::SkSnapshot()
michael@0 31 {
michael@0 32 quality = 100 * SK_Scalar1;
michael@0 33 type = (SkImageEncoder::Type) -1;
michael@0 34 sequence = false;
michael@0 35 fSeqVal = 0;
michael@0 36 }
michael@0 37
michael@0 38 #include "SkDevice.h"
michael@0 39
michael@0 40 bool SkSnapshot::draw(SkAnimateMaker& maker) {
michael@0 41 SkASSERT(type >= 0);
michael@0 42 SkASSERT(filename.size() > 0);
michael@0 43 SkImageEncoder* encoder = SkImageEncoder::Create((SkImageEncoder::Type) type);
michael@0 44 if (!encoder) {
michael@0 45 return false;
michael@0 46 }
michael@0 47 SkAutoTDelete<SkImageEncoder> ad(encoder);
michael@0 48
michael@0 49 SkString name(filename);
michael@0 50 if (sequence) {
michael@0 51 char num[4] = "000";
michael@0 52 num[0] = (char) (num[0] + fSeqVal / 100);
michael@0 53 num[1] = (char) (num[1] + fSeqVal / 10 % 10);
michael@0 54 num[2] = (char) (num[2] + fSeqVal % 10);
michael@0 55 name.append(num);
michael@0 56 if (++fSeqVal > 999)
michael@0 57 sequence = false;
michael@0 58 }
michael@0 59 if (type == SkImageEncoder::kJPEG_Type)
michael@0 60 name.append(".jpg");
michael@0 61 else if (type == SkImageEncoder::kPNG_Type)
michael@0 62 name.append(".png");
michael@0 63 encoder->encodeFile(name.c_str(),
michael@0 64 maker.fCanvas->getDevice()->accessBitmap(false),
michael@0 65 SkScalarFloorToInt(quality));
michael@0 66 return false;
michael@0 67 }

mercurial