Add xps device to skia.

http://codereview.appspot.com/5076041/


git-svn-id: http://skia.googlecode.com/svn/trunk@2437 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
bungeman@google.com 2011-10-10 13:19:10 +00:00
parent 1c04bf97b6
commit b29c883fb4
13 changed files with 3042 additions and 44 deletions

View File

@ -1,12 +1,11 @@
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "gm.h"
#include "gm.h"
#include "GrContext.h"
#include "GrRenderTarget.h"
@ -28,6 +27,10 @@
#include "SkPDFDocument.h"
#endif
#ifdef SK_SUPPORT_XPS
#include "SkXPSDevice.h"
#endif
#ifdef SK_BUILD_FOR_MAC
#include "SkCGUtils.h"
#define CAN_IMAGE_PDF 1
@ -195,9 +198,10 @@ static bool compare(const SkBitmap& target, const SkBitmap& base,
return true;
}
static bool write_pdf(const SkString& path, const SkDynamicMemoryWStream& pdf) {
static bool write_document(const SkString& path,
const SkDynamicMemoryWStream& document) {
SkFILEWStream stream(path.c_str());
SkAutoDataUnref data(pdf.copyToData());
SkAutoDataUnref data(document.copyToData());
return stream.writeData(data.get());
}
@ -205,6 +209,7 @@ enum Backend {
kRaster_Backend,
kGPU_Backend,
kPDF_Backend,
kXPS_Backend,
};
struct ConfigData {
@ -278,21 +283,55 @@ static void generate_pdf(GM* gm, SkDynamicMemoryWStream& pdf) {
#endif
}
static void generate_xps(GM* gm, SkDynamicMemoryWStream& xps) {
#ifdef SK_SUPPORT_XPS
SkISize size = gm->getISize();
SkSize trimSize = SkSize::Make(SkIntToScalar(size.width()),
SkIntToScalar(size.height()));
static const double inchesPerMeter = 10000.0 / 254.0;
static const double upm = 72 * inchesPerMeter;
SkVector unitsPerMeter = SkPoint::Make(SkDoubleToScalar(upm),
SkDoubleToScalar(upm));
static const double ppm = 200 * inchesPerMeter;
SkVector pixelsPerMeter = SkPoint::Make(SkDoubleToScalar(ppm),
SkDoubleToScalar(ppm));
SkXPSDevice* dev = new SkXPSDevice();
SkAutoUnref aur(dev);
SkCanvas c(dev);
dev->beginPortfolio(&xps);
dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize);
gm->draw(&c);
dev->endSheet();
dev->endPortfolio();
#endif
}
static bool write_reference_image(const ConfigData& gRec,
const char writePath [],
const char renderModeDescriptor [],
const SkString& name,
SkBitmap& bitmap,
SkDynamicMemoryWStream* pdf) {
SkDynamicMemoryWStream* document) {
SkString path;
bool success = false;
if (gRec.fBackend != kPDF_Backend || CAN_IMAGE_PDF) {
if (gRec.fBackend == kRaster_Backend ||
gRec.fBackend == kGPU_Backend ||
(gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) {
path = make_filename(writePath, renderModeDescriptor, name, "png");
success = write_bitmap(path, bitmap);
}
if (kPDF_Backend == gRec.fBackend) {
path = make_filename(writePath, renderModeDescriptor, name, "pdf");
success = write_pdf(path, *pdf);
success = write_document(path, *document);
}
if (kXPS_Backend == gRec.fBackend) {
path = make_filename(writePath, renderModeDescriptor, name, "xps");
success = write_document(path, *document);
}
if (!success) {
fprintf(stderr, "FAILED to write %s\n", path.c_str());
@ -355,7 +394,10 @@ static bool handle_test_results(GM* gm,
if (writePath) {
write_reference_image(gRec, writePath, renderModeDescriptor,
name, bitmap, pdf);
} else if (readPath && (gRec.fBackend != kPDF_Backend || CAN_IMAGE_PDF)) {
} else if (readPath && (
gRec.fBackend == kRaster_Backend ||
gRec.fBackend == kGPU_Backend ||
(gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF))) {
return compare_to_reference_image(readPath, name, bitmap,
diffPath, renderModeDescriptor);
} else if (comparisonBitmap) {
@ -409,7 +451,7 @@ static bool test_drawing(GM* gm,
GrContext* context,
GrRenderTarget* rt,
SkBitmap* bitmap) {
SkDynamicMemoryWStream pdf;
SkDynamicMemoryWStream document;
if (gRec.fBackend == kRaster_Backend ||
gRec.fBackend == kGPU_Backend) {
@ -419,15 +461,17 @@ static bool test_drawing(GM* gm,
return true;
}
} else if (gRec.fBackend == kPDF_Backend) {
generate_pdf(gm, pdf);
generate_pdf(gm, document);
#if CAN_IMAGE_PDF
SkAutoDataUnref data(pdf.copyToData());
SkMemoryStream stream(data.data(), data.size());
SkPDFDocumentToBitmap(&stream, bitmap);
#endif
} else if (gRec.fBackend == kXPS_Backend) {
generate_xps(gm, document);
}
return handle_test_results(gm, gRec, writePath, readPath, diffPath,
"", *bitmap, &pdf, NULL);
"", *bitmap, &document, NULL);
}
static bool test_picture_playback(GM* gm,
@ -490,6 +534,9 @@ static const ConfigData gRec[] = {
#ifdef SK_SUPPORT_PDF
{ SkBitmap::kARGB_8888_Config, kPDF_Backend, "pdf" },
#endif
#ifdef SK_SUPPORT_XPS
{ SkBitmap::kARGB_8888_Config, kXPS_Backend, "xps" },
#endif
};
namespace skiagm {

View File

@ -44,6 +44,7 @@
'images.gyp:images',
'pdf.gyp:pdf',
'utils.gyp:utils',
'xps.gyp:xps',
],
},
],

View File

@ -78,11 +78,13 @@
#windows
'../include/utils/win/SkAutoCoInitialize.h',
'../include/utils/win/SkHRESULT.h',
'../include/utils/win/SkIStream.h',
'../include/utils/win/SkTScopedComPtr.h',
'../src/utils/win/SkAutoCoInitialize.cpp',
'../src/utils/win/skia_win.cpp',
'../src/utils/win/SkEGLContext_Win.cpp',
'../src/utils/win/SkHRESULT.cpp',
'../src/utils/win/SkIStream.cpp',
'../src/utils/win/SkOSWindow_Win.cpp',
],
@ -152,11 +154,13 @@
],
'sources!': [
'../include/utils/win/SkAutoCoInitialize.h',
'../include/utils/win/SkHRESULT.h',
'../include/utils/win/SkIStream.h',
'../include/utils/win/SkTScopedComPtr.h',
'../src/utils/win/SkAutoCoInitialize.cpp',
'../src/utils/win/skia_win.cpp',
'../src/utils/win/SkEGLContext_Win.cpp',
'../src/utils/win/SkHRESULT.cpp',
'../src/utils/win/SkIStream.cpp',
'../src/utils/win/SkOSWindow_Win.cpp',
],

67
gyp/xps.gyp Normal file
View File

@ -0,0 +1,67 @@
{
'includes': [
'common.gypi',
],
'targets': [
{
'target_name': 'xps',
'type': 'static_library',
'dependencies': [
'core.gyp:core',
'images.gyp:images',
'utils.gyp:utils',
'pdf.gyp:pdf', # needed to get SkBitSet
],
'include_dirs': [
'../include/device/xps',
'../include/utils/win',
'../src/core', # needed to get SkGlyphCache.h
],
'sources': [
'../include/device/xps/SkConstexprMath.h',
'../include/device/xps/SkXPSDevice.h',
'../src/device/xps/SkXPSDevice.cpp',
],
'conditions': [
[ 'skia_os == "win"', {
'link_settings': {
'libraries': [
'T2Embed.lib',
'FontSub.lib',
],
},
},{ #else if 'skia_os != "win"'
'include_dirs!': [
'../include/utils/win',
],
'sources!': [
'../include/device/xps/SkXPSDevice.h',
'../src/device/xps/SkXPSDevice.cpp',
],
}],
],
# This section makes all targets that depend on this target
# #define SK_SUPPORT_XPS and have access to the xps header files.
'direct_dependent_settings': {
'conditions': [
[ 'skia_os == "win"', {
'defines': [
'SK_SUPPORT_XPS',
],
}],
],
'include_dirs': [
'../include/device/xps',
],
},
},
],
}
# Local Variables:
# tab-width:2
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=2 shiftwidth=2:

View File

@ -5,16 +5,19 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef sk_stdint_DEFINED
#define sk_stdint_DEFINED
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned uint32_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;
#endif
#ifndef sk_stdint_DEFINED
#define sk_stdint_DEFINED
typedef signed char int8_t;
typedef unsigned char uint8_t;
typedef short int16_t;
typedef unsigned short uint16_t;
typedef int int32_t;
typedef unsigned uint32_t;
typedef long long int64_t;
typedef unsigned long long uint64_t;
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
#endif

View File

@ -0,0 +1,52 @@
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkConstexprMath_DEFINED
#define SkConstexprMath_DEFINED
#include "SkTypes.h"
#include <limits.h>
template <uintmax_t N, uintmax_t B>
struct SK_LOG {
//! Compile-time constant ceiling(logB(N)).
static const uintmax_t value = 1 + SK_LOG<N/B, B>::value;
};
template <uintmax_t B>
struct SK_LOG<1, B> {
static const uintmax_t value = 0;
};
template <uintmax_t B>
struct SK_LOG<0, B> {
static const uintmax_t value = 0;
};
template<uintmax_t N>
struct SK_2N1 {
//! Compile-time constant (2^N)-1.
static const uintmax_t value = (SK_2N1<N-1>::value << 1) + 1;
};
template<>
struct SK_2N1<1> {
static const uintmax_t value = 1;
};
/** Compile-time constant number of base n digits in type t
if the bits of type t are considered as unsigned base two.
*/
#define SK_BASE_N_DIGITS_IN(n, t) (\
SK_LOG<SK_2N1<(sizeof(t) * CHAR_BIT)>::value, n>::value\
)
/** Compile-time constant number of base 10 digits in type t
if the bits of type t are considered as unsigned base two.
*/
#define SK_DIGITS_IN(t) SK_BASE_N_DIGITS_IN(10, (t))
//! a > b ? a : b
#define SK_MAX(a,b) (((a) > (b)) ? (a) : (b))
#endif

View File

@ -0,0 +1,324 @@
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkXPSDevice_DEFINED
#define SkXPSDevice_DEFINED
#include "SkTypes.h"
#include <ObjBase.h>
#include <XpsObjectModel.h>
#include "SkAutoCoInitialize.h"
#include "SkBitSet.h"
#include "SkCanvas.h"
#include "SkColor.h"
#include "SkDevice.h"
#include "SkPaint.h"
#include "SkPath.h"
#include "SkPoint.h"
#include "SkShader.h"
#include "SkSize.h"
#include "SkTArray.h"
#include "SkTScopedComPtr.h"
#include "SkTypeface.h"
/** \class SkXPSDevice
The drawing context for the XPS backend.
*/
class SkXPSDevice : public SkDevice {
public:
SK_API SkXPSDevice();
SK_API virtual ~SkXPSDevice();
virtual bool beginPortfolio(SkWStream* outputStream);
/**
@param unitsPerMeter converts geometry units into physical units.
@param pixelsPerMeter resolution to use when geometry must be rasterized.
@param trimSize final page size in physical units.
The top left of the trim is the origin of physical space.
@param mediaBox The size of the physical media in physical units.
The top and left must be less than zero.
The bottom and right must be greater than the trimSize.
The default is to coincide with the trimSize.
@param bleedBox The size of the bleed box in physical units.
Must be contained within the mediaBox.
The default is to coincide with the mediaBox.
@param artBox The size of the content box in physical units.
Must be contained within the trimSize.
The default is to coincide with the trimSize.
@param cropBox The size of the recommended view port in physical units.
Must be contained within the mediaBox.
The default is to coincide with the mediaBox.
*/
virtual bool beginSheet(
const SkVector& unitsPerMeter,
const SkVector& pixelsPerMeter,
const SkSize& trimSize,
const SkRect* mediaBox = NULL,
const SkRect* bleedBox = NULL,
const SkRect* artBox = NULL,
const SkRect* cropBox = NULL);
virtual bool endSheet();
virtual bool endPortfolio();
virtual uint32_t getDeviceCapabilities() SK_OVERRIDE {
return kVector_Capability;
}
virtual bool readPixels(const SkIRect& srcRect,
SkBitmap* bitmap) SK_OVERRIDE {
return false;
}
protected:
virtual void clear(SkColor color) SK_OVERRIDE;
virtual void drawPaint(const SkDraw&, const SkPaint& paint) SK_OVERRIDE;
virtual void drawPoints(
const SkDraw&,
SkCanvas::PointMode mode,
size_t count, const SkPoint[],
const SkPaint& paint) SK_OVERRIDE;
virtual void drawRect(
const SkDraw&,
const SkRect& r,
const SkPaint& paint) SK_OVERRIDE;
virtual void drawPath(
const SkDraw&,
const SkPath& platonicPath,
const SkPaint& paint,
const SkMatrix* prePathMatrix,
bool pathIsMutable) SK_OVERRIDE;
virtual void drawBitmap(
const SkDraw&,
const SkBitmap& bitmap,
const SkIRect* srcRectOrNull,
const SkMatrix& matrix,
const SkPaint& paint) SK_OVERRIDE;
virtual void drawSprite(
const SkDraw&,
const SkBitmap& bitmap,
int x, int y,
const SkPaint& paint) SK_OVERRIDE;
virtual void drawText(
const SkDraw&,
const void* text, size_t len,
SkScalar x, SkScalar y,
const SkPaint& paint) SK_OVERRIDE;
virtual void drawPosText(
const SkDraw&,
const void* text, size_t len,
const SkScalar pos[], SkScalar constY, int scalarsPerPos,
const SkPaint& paint) SK_OVERRIDE;
virtual void drawTextOnPath(
const SkDraw&,
const void* text, size_t len,
const SkPath& path,
const SkMatrix* matrix,
const SkPaint& paint) SK_OVERRIDE;
virtual void drawVertices(
const SkDraw&,
SkCanvas::VertexMode,
int vertexCount, const SkPoint verts[],
const SkPoint texs[], const SkColor colors[],
SkXfermode* xmode,
const uint16_t indices[], int indexCount,
const SkPaint& paint) SK_OVERRIDE;
virtual void drawDevice(
const SkDraw&,
SkDevice* device,
int x, int y,
const SkPaint& paint) SK_OVERRIDE;
private:
class TypefaceUse : ::SkNoncopyable {
public:
SkFontID typefaceId;
SkStream* fontData;
IXpsOMFontResource* xpsFont;
SkBitSet* glyphsUsed;
explicit TypefaceUse();
~TypefaceUse();
};
friend static HRESULT subset_typeface(TypefaceUse* current);
SkXPSDevice(IXpsOMObjectFactory* xpsFactory);
SkAutoCoInitialize fAutoCo;
SkTScopedComPtr<IXpsOMObjectFactory> fXpsFactory;
SkTScopedComPtr<IStream> fOutputStream;
SkTScopedComPtr<IXpsOMPackageWriter> fPackageWriter;
unsigned int fCurrentPage;
SkTScopedComPtr<IXpsOMCanvas> fCurrentXpsCanvas;
SkSize fCurrentCanvasSize;
SkVector fCurrentUnitsPerMeter;
SkVector fCurrentPixelsPerMeter;
SkTArray<TypefaceUse, true> fTypefaces;
HRESULT initXpsDocumentWriter(IXpsOMImageResource* image);
HRESULT createXpsPage(
const XPS_SIZE& pageSize,
IXpsOMPage** page);
HRESULT createXpsThumbnail(
IXpsOMPage* page, const unsigned int pageNumber,
IXpsOMImageResource** image);
void internalDrawRect(
const SkDraw&,
const SkRect& r,
bool transformRect,
const SkPaint& paint);
HRESULT createXpsBrush(
const SkPaint& skPaint,
IXpsOMBrush** xpsBrush,
const SkMatrix* parentTransform = NULL);
HRESULT createXpsSolidColorBrush(
const SkColor skColor, const SkAlpha alpha,
IXpsOMBrush** xpsBrush);
HRESULT createXpsImageBrush(
const SkBitmap& bitmap,
const SkMatrix& localMatrix,
const SkShader::TileMode (&xy)[2],
const SkAlpha alpha,
IXpsOMTileBrush** xpsBrush);
HRESULT createXpsLinearGradient(
SkShader::GradientInfo info,
const SkAlpha alpha,
const SkMatrix& localMatrix,
IXpsOMMatrixTransform* xpsMatrixToUse,
IXpsOMBrush** xpsBrush);
HRESULT createXpsRadialGradient(
SkShader::GradientInfo info,
const SkAlpha alpha,
const SkMatrix& localMatrix,
IXpsOMMatrixTransform* xpsMatrixToUse,
IXpsOMBrush** xpsBrush);
HRESULT createXpsGradientStop(
const SkColor skColor,
const SkScalar offset,
IXpsOMGradientStop** xpsGradStop);
HRESULT createXpsTransform(
const SkMatrix& matrix,
IXpsOMMatrixTransform ** xpsTransform);
HRESULT createXpsRect(
const SkRect& rect,
BOOL stroke, BOOL fill,
IXpsOMGeometryFigure** xpsRect);
HRESULT createXpsQuad(
const SkPoint (&points)[4],
BOOL stroke, BOOL fill,
IXpsOMGeometryFigure** xpsQuad);
HRESULT CreateTypefaceUse(
const SkPaint& paint,
TypefaceUse** fontResource);
HRESULT AddGlyphs(
const SkDraw& d,
IXpsOMObjectFactory* xpsFactory,
IXpsOMCanvas* canvas,
IXpsOMFontResource* font,
LPCWSTR text,
XPS_GLYPH_INDEX* xpsGlyphs,
UINT32 xpsGlyphsLen,
XPS_POINT *origin,
FLOAT fontSize,
XPS_STYLE_SIMULATION sims,
const SkMatrix& transform,
const SkPaint& paint);
HRESULT addXpsPathGeometry(
IXpsOMGeometryFigureCollection* figures,
BOOL stroke, BOOL fill, const SkPath& path);
HRESULT createPath(
IXpsOMGeometryFigure* figure,
IXpsOMVisualCollection* visuals,
IXpsOMPath** path);
HRESULT sideOfClamp(
const SkRect& leftPoints, const XPS_RECT& left,
IXpsOMImageResource* imageResource,
IXpsOMVisualCollection* visuals);
HRESULT cornerOfClamp(
const SkRect& tlPoints,
const SkColor color,
IXpsOMVisualCollection* visuals);
HRESULT clip(
IXpsOMVisual* xpsVisual,
const SkDraw& d);
HRESULT clipToPath(
IXpsOMVisual* xpsVisual,
const SkPath& clipPath,
XPS_FILL_RULE fillRule);
HRESULT drawInverseWindingPath(
const SkDraw& d,
const SkPath& devicePath,
IXpsOMPath* xpsPath);
HRESULT shadePath(
IXpsOMPath* shadedPath,
const SkPaint& shaderPaint,
const SkMatrix& matrix,
BOOL* fill, BOOL* stroke);
void convertToPpm(
const SkMaskFilter* filter,
SkMatrix* matrix,
SkVector* ppuScale,
const SkIRect& clip, SkIRect* clipIRect);
HRESULT applyMask(
const SkDraw& d,
const SkMask& mask,
const SkVector& ppuScale,
IXpsOMPath* shadedPath);
// override from SkDevice
virtual SkDevice* onCreateCompatibleDevice(
SkBitmap::Config config,
int width, int height,
bool isOpaque,
Usage usage) SK_OVERRIDE;
// Disable the default copy and assign implementation.
SkXPSDevice(const SkXPSDevice&);
void operator=(const SkXPSDevice&);
typedef SkDevice INHERITED;
};
#endif

View File

@ -41,9 +41,24 @@ public:
*/
bool orBits(const SkBitSet& source);
/** Export set bits to unsigned int array. (used in font subsetting)
/** Export indices of set bits to T array.
*/
void exportTo(SkTDArray<uint32_t>* array) const;
template<typename T>
void exportTo(SkTDArray<T>* array) const {
SkASSERT(array);
uint32_t* data = reinterpret_cast<uint32_t*>(fBitData.get());
for (unsigned int i = 0; i < fDwordCount; ++i) {
uint32_t value = data[i];
if (value) { // There are set bits
unsigned int index = i * 32;
for (unsigned int j = 0; j < 32; ++j) {
if (0x1 & (value >> j)) {
array->push(index + j);
}
}
}
}
}
private:
SkAutoFree fBitData;

View File

@ -0,0 +1,50 @@
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkHRESULT_DEFINED
#define SkHRESULT_DEFINED
#include "SkTypes.h"
void SkTraceHR(const char* file, unsigned long line,
HRESULT hr, const char* msg);
#ifdef SK_DEBUG
#define SK_TRACEHR(_hr, _msg) SkTraceHR(__FILE__, __LINE__, _hr, _msg)
#else
#define SK_TRACEHR(_hr, _msg) _hr
#endif
#define HR_GENERAL(_ex, _msg, _ret) {\
HRESULT _hr = _ex;\
if (FAILED(_hr)) {\
SK_TRACEHR(_hr, _msg);\
return _ret;\
}\
}
//@{
/**
These macros are for reporting HRESULT errors.
The expression will be evaluated.
If the resulting HRESULT SUCCEEDED then execution will continue normally.
If the HRESULT FAILED then the macro will return from the current function.
In variants ending with 'M' the given message will be traced when FAILED.
The HR variants will return the HRESULT when FAILED.
The HRB variants will return false when FAILED.
The HRV variants will simply return when FAILED.
*/
#define HR(ex) HR_GENERAL(ex, NULL, _hr)
#define HRM(ex, msg) HR_GENERAL(ex, msg, _hr)
#define HRB(ex) HR_GENERAL(ex, NULL, false)
#define HRBM(ex, msg) HR_GENERAL(ex, msg, false)
#define HRV(ex) HR_GENERAL(ex, NULL, )
#define HRVM(ex, msg) HR_GENERAL(ex, msg, )
//@}
#endif

View File

@ -6,12 +6,19 @@
* found in the LICENSE file.
*/
#ifndef SkSkTScopedPtr_DEFINED
#define SkSkTScopedPtr_DEFINED
#include "SkTypes.h"
#include "SkTemplates.h"
template<typename T>
class SkBlockComRef : public T {
private:
virtual ULONG STDMETHODCALLTYPE AddRef(void) = 0;
virtual ULONG STDMETHODCALLTYPE Release(void) = 0;
};
template<typename T>
class SkTScopedComPtr : SkNoncopyable {
private:
@ -23,7 +30,9 @@ public:
this->reset();
}
T &operator*() const { return *fPtr; }
T *operator->() const { return fPtr; }
SkBlockComRef<T> *operator->() const {
return static_cast<SkBlockComRef<T>*>(fPtr);
}
/**
* Returns the address of the underlying pointer.
* This is dangerous -- it breaks encapsulation and the reference escapes.
@ -38,6 +47,18 @@ public:
this->fPtr = NULL;
}
}
void swap(SkTScopedComPtr<T>& that) {
T* temp = this->fPtr;
this->fPtr = that.fPtr;
that.fPtr = temp;
}
T* release() {
T* temp = this->fPtr;
this->fPtr = NULL;
return temp;
}
};
#endif

File diff suppressed because it is too large Load Diff

View File

@ -81,19 +81,3 @@ bool SkBitSet::orBits(const SkBitSet& source) {
}
return true;
}
void SkBitSet::exportTo(SkTDArray<uint32_t>* array) const {
SkASSERT(array);
uint32_t* data = reinterpret_cast<uint32_t*>(fBitData.get());
for (unsigned int i = 0; i < fDwordCount; ++i) {
uint32_t value = data[i];
if (value) { // There are set bits
unsigned int index = i * 32;
for (unsigned int j = 0; j < 32; ++j) {
if (0x1 & (value >> j)) {
array->push(index + j);
}
}
}
}
}

View File

@ -0,0 +1,36 @@
/*
* Copyright 2011 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkTypes.h"
#include "SKHRESULT.h"
void SkTraceHR(const char* file, unsigned long line,
HRESULT hr, const char* msg) {
if (NULL != msg) SkDEBUGF(("%s\n", msg));
SkDEBUGF(("%s(%lu) : error 0x%x: ", file, line, hr));
LPSTR errorText = NULL;
FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
hr,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR) &errorText,
0,
NULL
);
if (NULL == errorText) {
SkDEBUGF(("<unknown>\n"));
} else {
SkDEBUGF((errorText));
LocalFree(errorText);
errorText = NULL;
}
}