Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | |
michael@0 | 2 | /* |
michael@0 | 3 | * Copyright 2011 Google Inc. |
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 | #ifndef SkCGUtils_DEFINED |
michael@0 | 9 | #define SkCGUtils_DEFINED |
michael@0 | 10 | |
michael@0 | 11 | #include "SkTypes.h" |
michael@0 | 12 | |
michael@0 | 13 | #ifdef SK_BUILD_FOR_MAC |
michael@0 | 14 | #include <ApplicationServices/ApplicationServices.h> |
michael@0 | 15 | #endif |
michael@0 | 16 | |
michael@0 | 17 | #ifdef SK_BUILD_FOR_IOS |
michael@0 | 18 | #include <CoreGraphics/CoreGraphics.h> |
michael@0 | 19 | #endif |
michael@0 | 20 | |
michael@0 | 21 | class SkBitmap; |
michael@0 | 22 | class SkData; |
michael@0 | 23 | class SkStream; |
michael@0 | 24 | |
michael@0 | 25 | /** |
michael@0 | 26 | * Create an imageref from the specified bitmap using the specified colorspace. |
michael@0 | 27 | * If space is NULL, then CGColorSpaceCreateDeviceRGB() is used. |
michael@0 | 28 | */ |
michael@0 | 29 | SK_API CGImageRef SkCreateCGImageRefWithColorspace(const SkBitmap& bm, |
michael@0 | 30 | CGColorSpaceRef space); |
michael@0 | 31 | |
michael@0 | 32 | /** |
michael@0 | 33 | * Create an imageref from the specified bitmap using the colorspace returned |
michael@0 | 34 | * by CGColorSpaceCreateDeviceRGB() |
michael@0 | 35 | */ |
michael@0 | 36 | static inline CGImageRef SkCreateCGImageRef(const SkBitmap& bm) { |
michael@0 | 37 | return SkCreateCGImageRefWithColorspace(bm, NULL); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | /** |
michael@0 | 41 | * Draw the bitmap into the specified CG context. The bitmap will be converted |
michael@0 | 42 | * to a CGImage using the generic RGB colorspace. (x,y) specifies the position |
michael@0 | 43 | * of the top-left corner of the bitmap. The bitmap is converted using the |
michael@0 | 44 | * colorspace returned by CGColorSpaceCreateDeviceRGB() |
michael@0 | 45 | */ |
michael@0 | 46 | void SkCGDrawBitmap(CGContextRef, const SkBitmap&, float x, float y); |
michael@0 | 47 | |
michael@0 | 48 | bool SkPDFDocumentToBitmap(SkStream* stream, SkBitmap* output); |
michael@0 | 49 | |
michael@0 | 50 | /** |
michael@0 | 51 | * Return a provider that wraps the specified stream. It will become an |
michael@0 | 52 | * owner of the stream, so the caller must still manage its ownership. |
michael@0 | 53 | * |
michael@0 | 54 | * To hand-off ownership of the stream to the provider, the caller must do |
michael@0 | 55 | * something like the following: |
michael@0 | 56 | * |
michael@0 | 57 | * SkStream* stream = new ...; |
michael@0 | 58 | * CGDataProviderRef provider = SkStreamToDataProvider(stream); |
michael@0 | 59 | * stream->unref(); |
michael@0 | 60 | * |
michael@0 | 61 | * Now when the provider is finally deleted, it will delete the stream. |
michael@0 | 62 | */ |
michael@0 | 63 | CGDataProviderRef SkCreateDataProviderFromStream(SkStream*); |
michael@0 | 64 | |
michael@0 | 65 | CGDataProviderRef SkCreateDataProviderFromData(SkData*); |
michael@0 | 66 | |
michael@0 | 67 | #endif |