1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/skia/trunk/include/utils/mac/SkCGUtils.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,67 @@ 1.4 + 1.5 +/* 1.6 + * Copyright 2011 Google Inc. 1.7 + * 1.8 + * Use of this source code is governed by a BSD-style license that can be 1.9 + * found in the LICENSE file. 1.10 + */ 1.11 +#ifndef SkCGUtils_DEFINED 1.12 +#define SkCGUtils_DEFINED 1.13 + 1.14 +#include "SkTypes.h" 1.15 + 1.16 +#ifdef SK_BUILD_FOR_MAC 1.17 +#include <ApplicationServices/ApplicationServices.h> 1.18 +#endif 1.19 + 1.20 +#ifdef SK_BUILD_FOR_IOS 1.21 +#include <CoreGraphics/CoreGraphics.h> 1.22 +#endif 1.23 + 1.24 +class SkBitmap; 1.25 +class SkData; 1.26 +class SkStream; 1.27 + 1.28 +/** 1.29 + * Create an imageref from the specified bitmap using the specified colorspace. 1.30 + * If space is NULL, then CGColorSpaceCreateDeviceRGB() is used. 1.31 + */ 1.32 +SK_API CGImageRef SkCreateCGImageRefWithColorspace(const SkBitmap& bm, 1.33 + CGColorSpaceRef space); 1.34 + 1.35 +/** 1.36 + * Create an imageref from the specified bitmap using the colorspace returned 1.37 + * by CGColorSpaceCreateDeviceRGB() 1.38 + */ 1.39 +static inline CGImageRef SkCreateCGImageRef(const SkBitmap& bm) { 1.40 + return SkCreateCGImageRefWithColorspace(bm, NULL); 1.41 +} 1.42 + 1.43 +/** 1.44 + * Draw the bitmap into the specified CG context. The bitmap will be converted 1.45 + * to a CGImage using the generic RGB colorspace. (x,y) specifies the position 1.46 + * of the top-left corner of the bitmap. The bitmap is converted using the 1.47 + * colorspace returned by CGColorSpaceCreateDeviceRGB() 1.48 + */ 1.49 +void SkCGDrawBitmap(CGContextRef, const SkBitmap&, float x, float y); 1.50 + 1.51 +bool SkPDFDocumentToBitmap(SkStream* stream, SkBitmap* output); 1.52 + 1.53 +/** 1.54 + * Return a provider that wraps the specified stream. It will become an 1.55 + * owner of the stream, so the caller must still manage its ownership. 1.56 + * 1.57 + * To hand-off ownership of the stream to the provider, the caller must do 1.58 + * something like the following: 1.59 + * 1.60 + * SkStream* stream = new ...; 1.61 + * CGDataProviderRef provider = SkStreamToDataProvider(stream); 1.62 + * stream->unref(); 1.63 + * 1.64 + * Now when the provider is finally deleted, it will delete the stream. 1.65 + */ 1.66 +CGDataProviderRef SkCreateDataProviderFromStream(SkStream*); 1.67 + 1.68 +CGDataProviderRef SkCreateDataProviderFromData(SkData*); 1.69 + 1.70 +#endif