本文整理汇总了C++中SkString::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ SkString::c_str方法的具体用法?C++ SkString::c_str怎么用?C++ SkString::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SkString
的用法示例。
在下文中一共展示了SkString::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: make_out_dirs
static bool make_out_dirs() {
SkString outDir = make_filepath(0, OUT_DIR, "");
if (!sk_exists(outDir.c_str())) {
if (!sk_mkdir(outDir.c_str())) {
SkDebugf("could not create dir %s\n", outDir.c_str());
return false;
}
}
SkString grDir = make_filepath(0, outGrDir, "");
if (!sk_exists(grDir.c_str())) {
if (!sk_mkdir(grDir.c_str())) {
SkDebugf("could not create dir %s\n", grDir.c_str());
return false;
}
}
SkString skDir = make_filepath(0, outSkDir, "");
if (!sk_exists(skDir.c_str())) {
if (!sk_mkdir(skDir.c_str())) {
SkDebugf("could not create dir %s\n", skDir.c_str());
return false;
}
}
SkString skpDir = make_filepath(0, outSkpDir, "");
if (!sk_exists(skpDir.c_str())) {
if (!sk_mkdir(skpDir.c_str())) {
SkDebugf("could not create dir %s\n", skpDir.c_str());
return false;
}
}
SkString diffDir = make_filepath(0, outDiffDir, "");
if (!sk_exists(diffDir.c_str())) {
if (!sk_mkdir(diffDir.c_str())) {
SkDebugf("could not create dir %s\n", diffDir.c_str());
return false;
}
}
SkString statusDir = make_filepath(0, outStatusDir, "");
if (!sk_exists(statusDir.c_str())) {
if (!sk_mkdir(statusDir.c_str())) {
SkDebugf("could not create dir %s\n", statusDir.c_str());
return false;
}
}
return true;
}
示例2: run
//.........这里部分代码省略.........
SkAutoTDelete<Timer> perTileTimer(this->setupTimer(false));
TimerData perTileTimerData(numInnerLoops);
longRunningTimer->start();
for (int inner = 0; inner < numInnerLoops; ++inner) {
perTileTimer->start();
tiledRenderer->drawCurrentTile();
perTileTimer->truncatedEnd();
tiledRenderer->resetState(false); // flush & swapBuffers, but don't Finish
perTileTimer->end();
SkAssertResult(perTileTimerData.appendTimes(perTileTimer.get()));
if (fPurgeDecodedTex) {
fRenderer->purgeTextures();
}
}
longRunningTimer->truncatedEnd();
tiledRenderer->resetState(true); // flush, swapBuffers and Finish
longRunningTimer->end();
SkAssertResult(longRunningTimerData.appendTimes(longRunningTimer.get()));
}
fWriter->tileConfig(tiledRenderer->getConfigName());
fWriter->tileMeta(x, y, xTiles, yTiles);
// TODO(borenet): Turn off per-iteration tile time reporting for now.
// Avoiding logging the time for every iteration for each tile cuts
// down on data file size by a significant amount. Re-enable this once
// we're loading the bench data directly into a data store and are no
// longer generating SVG graphs.
#if 0
fWriter->tileData(
&perTileTimerData,
timeFormat.c_str(),
fTimerResult,
timerTypes);
#endif
if (fPurgeDecodedTex) {
fWriter->addTileFlag(PictureResultsWriter::kPurging);
}
fWriter->addTileFlag(PictureResultsWriter::kAvg);
fWriter->tileData(
&longRunningTimerData,
tiledRenderer->getNormalTimeFormat().c_str(),
TimerData::kAvg_Result,
timerTypes,
numInnerLoops);
}
} else {
SkAutoTDelete<Timer> longRunningTimer(this->setupTimer());
TimerData longRunningTimerData(numOuterLoops);
for (int outer = 0; outer < numOuterLoops; ++outer) {
SkAutoTDelete<Timer> perRunTimer(this->setupTimer(false));
TimerData perRunTimerData(numInnerLoops);
longRunningTimer->start();
for (int inner = 0; inner < numInnerLoops; ++inner) {
fRenderer->setup();
perRunTimer->start();
fRenderer->render(NULL);
perRunTimer->truncatedEnd();
fRenderer->resetState(false); // flush & swapBuffers, but don't Finish
perRunTimer->end();
示例3: TestWStream
static void TestWStream(skiatest::Reporter* reporter) {
SkDynamicMemoryWStream ds;
const char s[] = "abcdefghijklmnopqrstuvwxyz";
int i;
for (i = 0; i < 100; i++) {
REPORTER_ASSERT(reporter, ds.write(s, 26));
}
REPORTER_ASSERT(reporter, ds.getOffset() == 100 * 26);
char* dst = new char[100 * 26 + 1];
dst[100*26] = '*';
ds.copyTo(dst);
REPORTER_ASSERT(reporter, dst[100*26] == '*');
for (i = 0; i < 100; i++) {
REPORTER_ASSERT(reporter, memcmp(&dst[i * 26], s, 26) == 0);
}
{
SkAutoTDelete<SkStreamAsset> stream(ds.detachAsStream());
REPORTER_ASSERT(reporter, 100 * 26 == stream->getLength());
REPORTER_ASSERT(reporter, ds.getOffset() == 0);
test_loop_stream(reporter, stream.get(), s, 26, 100);
SkAutoTDelete<SkStreamAsset> stream2(stream->duplicate());
test_loop_stream(reporter, stream2.get(), s, 26, 100);
SkAutoTDelete<SkStreamAsset> stream3(stream->fork());
REPORTER_ASSERT(reporter, stream3->isAtEnd());
char tmp;
size_t bytes = stream->read(&tmp, 1);
REPORTER_ASSERT(reporter, 0 == bytes);
stream3->rewind();
test_loop_stream(reporter, stream3.get(), s, 26, 100);
}
for (i = 0; i < 100; i++) {
REPORTER_ASSERT(reporter, ds.write(s, 26));
}
REPORTER_ASSERT(reporter, ds.getOffset() == 100 * 26);
{
SkAutoTUnref<SkData> data(ds.copyToData());
REPORTER_ASSERT(reporter, 100 * 26 == data->size());
REPORTER_ASSERT(reporter, memcmp(dst, data->data(), data->size()) == 0);
}
{
// Test that this works after a copyToData.
SkAutoTDelete<SkStreamAsset> stream(ds.detachAsStream());
REPORTER_ASSERT(reporter, ds.getOffset() == 0);
test_loop_stream(reporter, stream.get(), s, 26, 100);
SkAutoTDelete<SkStreamAsset> stream2(stream->duplicate());
test_loop_stream(reporter, stream2.get(), s, 26, 100);
}
delete[] dst;
SkString tmpDir = skiatest::GetTmpDir();
if (!tmpDir.isEmpty()) {
test_filestreams(reporter, tmpDir.c_str());
}
}
示例4: onDraw
virtual void onDraw(SkCanvas* canvas) {
static const int kBmpSize = 2048;
if (fLargeBitmap.isNull()) {
makebm(&fLargeBitmap, kBmpSize, kBmpSize);
}
SkRect dstRect = { 0, 0, SkIntToScalar(64), SkIntToScalar(64)};
static const int kMaxSrcRectSize = 1 << (SkNextLog2(kBmpSize) + 2);
static const int kPadX = 30;
static const int kPadY = 40;
SkPaint paint;
paint.setAlpha(0x20);
canvas->drawBitmapRect(fLargeBitmap, NULL,
SkRect::MakeWH(gSize * SK_Scalar1,
gSize * SK_Scalar1),
&paint);
canvas->translate(SK_Scalar1 * kPadX / 2,
SK_Scalar1 * kPadY / 2);
SkPaint blackPaint;
SkScalar titleHeight = SK_Scalar1 * 24;
blackPaint.setColor(SK_ColorBLACK);
blackPaint.setTextSize(titleHeight);
blackPaint.setAntiAlias(true);
SkString title;
title.printf("Bitmap size: %d x %d", kBmpSize, kBmpSize);
canvas->drawText(title.c_str(), title.size(), 0,
titleHeight, blackPaint);
canvas->translate(0, SK_Scalar1 * kPadY / 2 + titleHeight);
int rowCount = 0;
canvas->save();
for (int w = 1; w <= kMaxSrcRectSize; w *= 4) {
for (int h = 1; h <= kMaxSrcRectSize; h *= 4) {
SkIRect srcRect = SkIRect::MakeXYWH((kBmpSize - w) / 2,
(kBmpSize - h) / 2,
w, h);
canvas->drawBitmapRect(fLargeBitmap, &srcRect, dstRect);
SkString label;
label.appendf("%d x %d", w, h);
blackPaint.setAntiAlias(true);
blackPaint.setStyle(SkPaint::kFill_Style);
blackPaint.setTextSize(SK_Scalar1 * 10);
SkScalar baseline = dstRect.height() +
blackPaint.getTextSize() + SK_Scalar1 * 3;
canvas->drawText(label.c_str(), label.size(),
0, baseline,
blackPaint);
blackPaint.setStyle(SkPaint::kStroke_Style);
blackPaint.setStrokeWidth(SK_Scalar1);
blackPaint.setAntiAlias(false);
canvas->drawRect(dstRect, blackPaint);
canvas->translate(dstRect.width() + SK_Scalar1 * kPadX, 0);
++rowCount;
if ((dstRect.width() + kPadX) * rowCount > gSize) {
canvas->restore();
canvas->translate(0, dstRect.height() + SK_Scalar1 * kPadY);
canvas->save();
rowCount = 0;
}
}
}
{
// test the following code path:
// SkGpuDevice::drawPath() -> SkGpuDevice::drawWithMaskFilter()
SkIRect srcRect;
SkPaint paint;
SkBitmap bm;
bm = make_chessbm(5, 5);
paint.setFilterLevel(SkPaint::kLow_FilterLevel);
srcRect.setXYWH(1, 1, 3, 3);
SkMaskFilter* mf = SkBlurMaskFilter::Create(
kNormal_SkBlurStyle,
SkBlurMask::ConvertRadiusToSigma(SkIntToScalar(5)),
SkBlurMaskFilter::kHighQuality_BlurFlag |
SkBlurMaskFilter::kIgnoreTransform_BlurFlag);
paint.setMaskFilter(mf)->unref();
canvas->drawBitmapRect(bm, &srcRect, dstRect, &paint);
}
}
示例5: onGetName
virtual const char* onGetName() {
return fName.c_str();
}
示例6: writeChangedElements
bool SkSVGPaint::writeChangedElements(SkSVGParser& parser,
SkSVGPaint& current, bool* changed) {
SkSVGPaint& lastState = parser.fLastFlush;
for (int index = kInitial + 1; index < kTerminal; index++) {
SkString* topAttr = current[index];
size_t attrLength = topAttr->size();
if (attrLength == 0)
continue;
const char* attrValue = topAttr->c_str();
SkString* lastAttr = lastState[index];
switch(index) {
case kClipPath:
case kClipRule:
// !!! need to add this outside of paint
break;
case kEnableBackground:
// !!! don't know what to do with this
break;
case kFill:
goto addColor;
case kFillRule:
case kFilter:
break;
case kFontFamily:
parser._startElement("typeface");
parser._addAttributeLen("fontName", attrValue, attrLength);
parser._endElement(); // typeface
break;
case kFontSize:
case kLetterSpacing:
break;
case kMask:
case kOpacity:
if (changed[kStroke] == false && changed[kFill] == false) {
parser._startElement("color");
SkString& opacity = current.f_opacity;
parser._addAttributeLen("color", parser.fLastColor.c_str(), parser.fLastColor.size());
parser._addAttributeLen("alpha", opacity.c_str(), opacity.size());
parser._endElement(); // color
}
break;
case kStopColor:
break;
case kStopOpacity:
break;
case kStroke:
addColor:
if (strncmp(lastAttr->c_str(), "url(", 4) == 0 && strncmp(attrValue, "url(", 4) != 0) {
parser._startElement("shader");
parser._endElement();
}
if (topAttr->equals(*lastAttr))
continue;
{
bool urlRef = strncmp(attrValue, "url(", 4) == 0;
bool colorNone = strcmp(attrValue, "none") == 0;
bool lastEqual = parser.fLastColor.equals(attrValue, attrLength);
bool newColor = urlRef == false && colorNone == false && lastEqual == false;
if (newColor || changed[kOpacity]) {
parser._startElement("color");
if (newColor || changed[kOpacity]) {
parser._addAttributeLen("color", attrValue, attrLength);
parser.fLastColor.set(attrValue, attrLength);
}
if (changed[kOpacity]) {
SkString& opacity = current.f_opacity;
parser._addAttributeLen("alpha", opacity.c_str(), opacity.size());
}
parser._endElement(); // color
}
}
break;
case kStroke_Dasharray:
parser._startElement("dash");
SkSVGParser::ConvertToArray(*topAttr);
parser._addAttribute("intervals", topAttr->c_str());
parser._endElement(); // dash
break;
case kStroke_Linecap:
case kStroke_Linejoin:
case kStroke_Miterlimit:
case kStroke_Width:
case kStyle:
case kTransform:
break;
default:
SkASSERT(0);
return false;
}
}
return true;
}
示例7: onGetName
const char* onGetName() override {
return fName.c_str();
}
示例8: run_single_benchmark
static bool run_single_benchmark(const SkString& inputPath,
sk_tools::PictureBenchmark& benchmark) {
SkFILEStream inputStream;
inputStream.setPath(inputPath.c_str());
if (!inputStream.isValid()) {
SkString err;
err.printf("Could not open file %s\n", inputPath.c_str());
gLogger.logError(err);
return false;
}
// Since the old picture has been deleted, all pixels should be cleared.
SkASSERT(gLruImageCache.getImageCacheUsed() == 0);
if (FLAGS_countRAM) {
// Set the limit to zero, so all pixels will be kept
gLruImageCache.setImageCacheLimit(0);
}
SkPicture::InstallPixelRefProc proc;
if (FLAGS_deferImageDecoding) {
proc = &sk_tools::LazyDecodeBitmap;
} else {
proc = &SkImageDecoder::DecodeMemory;
}
SkAutoTUnref<SkPicture> picture(SkPicture::CreateFromStream(&inputStream, proc));
if (NULL == picture.get()) {
SkString err;
err.printf("Could not read an SkPicture from %s\n", inputPath.c_str());
gLogger.logError(err);
return false;
}
SkString filename;
sk_tools::get_basename(&filename, inputPath);
SkString result;
result.printf("running bench [%i %i] %s ", picture->width(), picture->height(),
filename.c_str());
gLogger.logProgress(result);
benchmark.run(picture);
#if LAZY_CACHE_STATS
if (FLAGS_trackDeferredCaching) {
int32_t cacheHits = SkLazyPixelRef::GetCacheHits();
int32_t cacheMisses = SkLazyPixelRef::GetCacheMisses();
SkLazyPixelRef::ResetCacheStats();
SkString hitString;
hitString.printf("Cache hit rate: %f\n", (double) cacheHits / (cacheHits + cacheMisses));
gLogger.logProgress(hitString);
gTotalCacheHits += cacheHits;
gTotalCacheMisses += cacheMisses;
}
#endif
if (FLAGS_countRAM) {
SkString ramCount("RAM used for bitmaps: ");
size_t bytes = gLruImageCache.getImageCacheUsed();
if (bytes > 1024) {
size_t kb = bytes / 1024;
if (kb > 1024) {
size_t mb = kb / 1024;
ramCount.appendf("%zi MB\n", mb);
} else {
ramCount.appendf("%zi KB\n", kb);
}
} else {
ramCount.appendf("%zi bytes\n", bytes);
}
gLogger.logProgress(ramCount);
}
return true;
}
示例9: resource
static SkStreamAsset* resource(const char path[]) {
SkString fullPath = GetResourcePath(path);
return SkStream::NewFromFile(fullPath.c_str());
}
示例10: testRunner
DEF_TEST(SkpSkGrThreaded, reporter) {
if (!initTest()) {
return;
}
SkpSkGrThreadedTestRunner testRunner(reporter);
for (int dirIndex = 1; dirIndex <= 100; ++dirIndex) {
SkString pictDir = make_in_dir_name(dirIndex);
if (pictDir.size() == 0) {
continue;
}
SkOSFile::Iter iter(pictDir.c_str(), "skp");
SkString filename;
while (iter.next(&filename)) {
SkString pngName = make_png_name(filename.c_str());
SkString oldPng = make_filepath(dirIndex, outSkDir, pngName.c_str());
SkString newPng = make_filepath(dirIndex, outGrDir, pngName.c_str());
if (sk_exists(oldPng.c_str()) && sk_exists(newPng.c_str())) {
bumpCount(reporter, true);
continue;
}
for (size_t index = 0; index < skipOverSkGrCount; ++index) {
if (skipOverSkGr[index].directory == dirIndex
&& strcmp(filename.c_str(), skipOverSkGr[index].filename) == 0) {
bumpCount(reporter, true);
goto skipOver;
}
}
*testRunner.fRunnables.append() = new SkpSkGrThreadedRunnable(
&testSkGrMain, dirIndex, filename.c_str(), &testRunner);
skipOver:
;
}
}
testRunner.render();
SkpSkGrThreadState& max = testRunner.fRunnables[0]->fState;
for (int dirIndex = 2; dirIndex <= 100; ++dirIndex) {
SkpSkGrThreadState& state = testRunner.fRunnables[dirIndex - 1]->fState;
for (int index = 0; index < state.fFoundCount; ++index) {
int maxIdx = max.fFoundCount;
if (maxIdx < kMaxFiles) {
max.fError[maxIdx] = state.fError[index];
strcpy(max.fFilesFound[maxIdx], state.fFilesFound[index]);
max.fDirsFound[maxIdx] = state.fDirsFound[index];
++max.fFoundCount;
continue;
}
for (maxIdx = 0; maxIdx < max.fFoundCount; ++maxIdx) {
if (max.fError[maxIdx] < state.fError[index]) {
max.fError[maxIdx] = state.fError[index];
strcpy(max.fFilesFound[maxIdx], state.fFilesFound[index]);
max.fDirsFound[maxIdx] = state.fDirsFound[index];
break;
}
}
}
}
TestResult encoder;
encoder.fTestStep = kEncodeFiles;
for (int index = 0; index < max.fFoundCount; ++index) {
encoder.fDirNo = max.fDirsFound[index];
strcpy(encoder.fFilename, max.fFilesFound[index]);
encoder.testOne();
SkDebugf("+");
}
}
示例11: test
void test(int dirNo, const SkString& filename) {
init(dirNo);
strcpy(fFilename, filename.c_str());
testOne();
}
示例12: iter
DEF_TEST(SkpSkGr, reporter) {
SkTArray<TestResult, true> errors;
if (!initTest()) {
return;
}
SkpSkGrThreadState state;
state.init(0);
int smallCount = 0;
for (int dirNo = 1; dirNo <= 100; ++dirNo) {
SkString pictDir = make_in_dir_name(dirNo);
SkASSERT(pictDir.size());
if (reporter->verbose()) {
SkDebugf("dirNo=%d\n", dirNo);
}
SkOSFile::Iter iter(pictDir.c_str(), "skp");
SkString filename;
int testCount = 0;
PreParser preParser(dirNo);
SkFILEWStream statusStream(makeStatusString(dirNo).c_str());
while (iter.next(&filename)) {
for (size_t index = 0; index < skipOverSkGrCount; ++index) {
if (skipOverSkGr[index].directory == dirNo
&& strcmp(filename.c_str(), skipOverSkGr[index].filename) == 0) {
goto skipOver;
}
}
if (preParser.match(filename, &statusStream, &state.fResult)) {
addError(&state);
++testCount;
goto checkEarlyExit;
}
if (state.fSmallestError > 5000000) {
goto breakOut;
}
{
TestResult& result = state.fResult;
result.test(dirNo, filename);
SkString outStr(result.status());
statusStream.write(outStr.c_str(), outStr.size());
statusStream.flush();
if (1) {
SkDebugf("%s", outStr.c_str());
}
bool noMatch = addError(&state);
if (noMatch) {
smallCount = 0;
} else if (++smallCount > 10000) {
goto breakOut;
}
}
++testCount;
if (reporter->verbose()) {
if (testCount % 100 == 0) {
SkDebugf("#%d\n", testCount);
}
}
skipOver:
reporter->bumpTestCount();
checkEarlyExit:
if (1 && testCount == 20) {
break;
}
}
}
breakOut:
if (reporter->verbose()) {
for (int index = 0; index < state.fFoundCount; ++index) {
SkDebugf("%d %s %d\n", state.fDirsFound[index], state.fFilesFound[index],
state.fError[index]);
}
}
for (int index = 0; index < state.fFoundCount; ++index) {
TestResult::Test(state.fDirsFound[index], state.fFilesFound[index], kEncodeFiles,
reporter->verbose());
if (reporter->verbose()) SkDebugf("+");
}
}
示例13: makeStatusString
static SkString makeStatusString(int dirNo) {
SkString statName;
statName.printf("stats%d.txt", dirNo);
SkString statusFile = make_filepath(0, outStatusDir, statName.c_str());
return statusFile;
}
示例14: testOne
void TestResult::testOne() {
SkPicture* pic = NULL;
{
SkString d;
d.printf(" {%d, \"%s\"},", fDirNo, fFilename);
SkString path = make_filepath(fDirNo, IN_DIR, fFilename);
SkFILEStream stream(path.c_str());
if (!stream.isValid()) {
SkDebugf("invalid stream %s\n", path.c_str());
goto finish;
}
if (fTestStep == kEncodeFiles) {
size_t length = stream.getLength();
SkTArray<char, true> bytes;
bytes.push_back_n(length);
stream.read(&bytes[0], length);
stream.rewind();
SkString wPath = make_filepath(0, outSkpDir, fFilename);
SkFILEWStream wStream(wPath.c_str());
wStream.write(&bytes[0], length);
wStream.flush();
}
pic = SkPicture::CreateFromStream(&stream, &SkImageDecoder::DecodeMemory);
if (!pic) {
SkDebugf("unable to decode %s\n", fFilename);
goto finish;
}
int pWidth = pic->width();
int pHeight = pic->height();
int pLargerWH = SkTMax(pWidth, pHeight);
GrContextFactory contextFactory;
#ifdef SK_BUILD_FOR_WIN
GrContext* context = contextFactory.get(kAngle);
#else
GrContext* context = contextFactory.get(kNative);
#endif
if (NULL == context) {
SkDebugf("unable to allocate context for %s\n", fFilename);
goto finish;
}
int maxWH = context->getMaxRenderTargetSize();
int scale = 1;
while (pLargerWH / scale > maxWH) {
scale *= 2;
}
SkBitmap bitmap;
SkIPoint dim;
do {
dim.fX = (pWidth + scale - 1) / scale;
dim.fY = (pHeight + scale - 1) / scale;
bool success = bitmap.allocN32Pixels(dim.fX, dim.fY);
if (success) {
break;
}
SkDebugf("-%d-", scale);
} while ((scale *= 2) < 256);
if (scale >= 256) {
SkDebugf("unable to allocate bitmap for %s (w=%d h=%d) (sw=%d sh=%d)\n",
fFilename, pWidth, pHeight, dim.fX, dim.fY);
goto finish;
}
SkCanvas skCanvas(bitmap);
drawPict(pic, &skCanvas, fScaleOversized ? scale : 1);
GrTextureDesc desc;
desc.fConfig = kSkia8888_GrPixelConfig;
desc.fFlags = kRenderTarget_GrTextureFlagBit;
desc.fWidth = dim.fX;
desc.fHeight = dim.fY;
desc.fSampleCnt = 0;
SkAutoTUnref<GrTexture> texture(context->createUncachedTexture(desc, NULL, 0));
if (!texture) {
SkDebugf("unable to allocate texture for %s (w=%d h=%d)\n", fFilename,
dim.fX, dim.fY);
goto finish;
}
SkGpuDevice grDevice(context, texture.get());
SkCanvas grCanvas(&grDevice);
drawPict(pic, &grCanvas, fScaleOversized ? scale : 1);
SkBitmap grBitmap;
grBitmap.allocPixels(grCanvas.imageInfo());
grCanvas.readPixels(&grBitmap, 0, 0);
if (fTestStep == kCompareBits) {
fPixelError = similarBits(grBitmap, bitmap);
int skTime = timePict(pic, &skCanvas);
int grTime = timePict(pic, &grCanvas);
fTime = skTime - grTime;
} else if (fTestStep == kEncodeFiles) {
SkString pngStr = make_png_name(fFilename);
const char* pngName = pngStr.c_str();
writePict(grBitmap, outGrDir, pngName);
writePict(bitmap, outSkDir, pngName);
}
}
finish:
delete pic;
}
示例15: setSave
void SkSVGPaint::setSave(SkSVGParser& parser) {
SkTDArray<SkString*> clips;
SkSVGPaint* walking = parser.fHead;
int index;
SkMatrix sum;
sum.reset();
while (walking != NULL) {
for (index = kInitial + 1; index < kTerminal; index++) {
SkString* lastAttr = (*walking)[index];
if (lastAttr->size() == 0)
continue;
if (index == kTransform) {
const char* str = lastAttr->c_str();
SkASSERT(strncmp(str, "matrix(", 7) == 0);
str += 6;
const char* strEnd = strrchr(str, ')');
SkASSERT(strEnd != NULL);
SkString mat(str, strEnd - str);
SkSVGParser::ConvertToArray(mat);
SkScalar values[6];
SkParse::FindScalars(mat.c_str() + 1, values, 6);
SkMatrix matrix;
matrix.reset();
matrix.setScaleX(values[0]);
matrix.setSkewY(values[1]);
matrix.setSkewX(values[2]);
matrix.setScaleY(values[3]);
matrix.setTranslateX(values[4]);
matrix.setTranslateY(values[5]);
sum.setConcat(matrix, sum);
continue;
}
if ( index == kClipPath)
*clips.insert(0) = lastAttr;
}
walking = walking->fNext;
}
if ((sum == parser.fLastTransform) == false) {
SkMatrix inverse;
bool success = parser.fLastTransform.invert(&inverse);
SkASSERT(success == true);
SkMatrix output;
output.setConcat(inverse, sum);
parser.fLastTransform = sum;
SkString outputStr;
outputStr.appendUnichar('[');
outputStr.appendScalar(output.getScaleX());
outputStr.appendUnichar(',');
outputStr.appendScalar(output.getSkewX());
outputStr.appendUnichar(',');
outputStr.appendScalar(output.getTranslateX());
outputStr.appendUnichar(',');
outputStr.appendScalar(output.getSkewY());
outputStr.appendUnichar(',');
outputStr.appendScalar(output.getScaleY());
outputStr.appendUnichar(',');
outputStr.appendScalar(output.getTranslateY());
outputStr.appendUnichar(',');
outputStr.appendScalar(output.getPerspX());
outputStr.appendUnichar(',');
outputStr.appendScalar(output.getPerspY());
outputStr.append(",1]");
parser._startElement("matrix");
parser._addAttributeLen("matrix", outputStr.c_str(), outputStr.size());
parser._endElement();
}
#if 0 // incomplete
if (parser.fTransformClips.size() > 0) {
// need to reset the clip when the 'g' scope is ended
parser._startElement("add");
const char* start = strchr(current->f_clipPath.c_str(), '#') + 1;
SkASSERT(start);
parser._addAttributeLen("use", start, strlen(start) - 1);
parser._endElement(); // clip
}
#endif
}