gfx/skia/trunk/src/gpu/GrSurface.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 * Copyright 2012 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 #include "GrSurface.h"
michael@0 9
michael@0 10 #include "SkBitmap.h"
michael@0 11 #include "SkGr.h"
michael@0 12 #include "SkImageEncoder.h"
michael@0 13 #include <stdio.h>
michael@0 14
michael@0 15 void GrSurface::asImageInfo(SkImageInfo* info) const {
michael@0 16 if (!GrPixelConfig2ColorType(this->config(), &info->fColorType)) {
michael@0 17 sk_throw();
michael@0 18 }
michael@0 19 info->fWidth = this->width();
michael@0 20 info->fHeight = this->height();
michael@0 21 info->fAlphaType = kPremul_SkAlphaType;
michael@0 22 }
michael@0 23
michael@0 24 bool GrSurface::savePixels(const char* filename) {
michael@0 25 SkBitmap bm;
michael@0 26 if (!bm.allocPixels(SkImageInfo::MakeN32Premul(this->width(),
michael@0 27 this->height()))) {
michael@0 28 return false;
michael@0 29 }
michael@0 30
michael@0 31 bool result = readPixels(0, 0, this->width(), this->height(), kSkia8888_GrPixelConfig,
michael@0 32 bm.getPixels());
michael@0 33 if (!result) {
michael@0 34 SkDebugf("------ failed to read pixels for %s\n", filename);
michael@0 35 return false;
michael@0 36 }
michael@0 37
michael@0 38 // remove any previous version of this file
michael@0 39 remove(filename);
michael@0 40
michael@0 41 if (!SkImageEncoder::EncodeFile(filename, bm, SkImageEncoder::kPNG_Type, 100)) {
michael@0 42 SkDebugf("------ failed to encode %s\n", filename);
michael@0 43 remove(filename); // remove any partial file
michael@0 44 return false;
michael@0 45 }
michael@0 46
michael@0 47 return true;
michael@0 48 }

mercurial