gfx/skia/trunk/src/utils/ios/SkImageDecoder_iOS.mm

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
-rwxr-xr-x

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.

     1 /*
     2  * Copyright 2010 Google Inc.
     3  *
     4  * Use of this source code is governed by a BSD-style license that can be
     5  * found in the LICENSE file.
     6  */
     8 #import <CoreGraphics/CoreGraphics.h>
     9 #include <CoreGraphics/CGColorSpace.h>
    10 #import <UIKit/UIKit.h>
    12 #include "SkImageDecoder.h"
    13 #include "SkImageEncoder.h"
    14 #include "SkMovie.h"
    15 #include "SkStream_NSData.h"
    17 class SkImageDecoder_iOS : public SkImageDecoder {
    18 protected:
    19     virtual bool onDecode(SkStream* stream, SkBitmap* bm, Mode);
    20 };
    22 #define BITMAP_INFO (kCGBitmapByteOrder32Big | kCGImageAlphaPremultipliedLast)
    24 bool SkImageDecoder_iOS::onDecode(SkStream* stream, SkBitmap* bm, Mode mode) {
    26     NSData* data = NSData_dataWithStream(stream);
    28     UIImage* uimage = [UIImage imageWithData:data];
    30     const int width = uimage.size.width;
    31     const int height = uimage.size.height;
    32     bm->setConfig(SkBitmap::kARGB_8888_Config, width, height);
    33     if (SkImageDecoder::kDecodeBounds_Mode == mode) {
    34         return true;
    35     }
    37     if (!this->allocPixelRef(bm, NULL)) {
    38         return false;
    39     }
    41     bm->lockPixels();
    42     bm->eraseColor(0);
    44     CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
    45     CGContextRef cg = CGBitmapContextCreate(bm->getPixels(), width, height,
    46                                             8, bm->rowBytes(), cs, BITMAP_INFO);
    47     CGContextDrawImage(cg, CGRectMake(0, 0, width, height), uimage.CGImage);
    48     CGContextRelease(cg);
    49     CGColorSpaceRelease(cs);
    51     bm->unlockPixels();
    52     return true;
    53 }
    55 /////////////////////////////////////////////////////////////////////////
    57 SkImageDecoder* SkImageDecoder::Factory(SkStreamRewindable* stream) {
    58     return new SkImageDecoder_iOS;
    59 }
    61 SkMovie* SkMovie::DecodeStream(SkStreamRewindable* stream) {
    62     return NULL;
    63 }
    65 SkImageEncoder* SkImageEncoder::Create(Type t) {
    66     return NULL;
    67 }

mercurial