当前位置: 首页>>代码示例>>C++>>正文


C++ SkString::size方法代码示例

本文整理汇总了C++中SkString::size方法的典型用法代码示例。如果您正苦于以下问题:C++ SkString::size方法的具体用法?C++ SkString::size怎么用?C++ SkString::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SkString的用法示例。


在下文中一共展示了SkString::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: writeBigDecAsText

bool SkWStream::writeBigDecAsText(int64_t dec, int minDigits)
{
    SkString    tmp;
    tmp.appendS64(dec, minDigits);
    return this->write(tmp.c_str(), tmp.size());
}
开发者ID:BBKeeper,项目名称:Skia,代码行数:6,代码来源:SkStream.cpp

示例2: 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("+");
    }
}
开发者ID:aseprite,项目名称:skia,代码行数:77,代码来源:SkpSkGrTest.cpp

示例3: lowercase

// "FooBar" -> "foobar".  Obviously, ASCII only.
static SkString lowercase(SkString s) {
    for (size_t i = 0; i < s.size(); i++) {
        s[i] = tolower(s[i]);
    }
    return s;
}
开发者ID:CodeMonkeyYao,项目名称:skia,代码行数:7,代码来源:DM.cpp

示例4: render

bool CopyTilesRenderer::render(SkBitmap** out) {
    int i = 0;
    bool success = true;
    SkBitmap dst;
    for (int x = 0; x < this->getViewWidth(); x += fLargeTileWidth) {
        for (int y = 0; y < this->getViewHeight(); y += fLargeTileHeight) {
            SkAutoCanvasRestore autoRestore(fCanvas, true);
            // Translate so that we draw the correct portion of the picture.
            // Perform a postTranslate so that the scaleFactor does not interfere with the
            // positioning.
            SkMatrix mat(fCanvas->getTotalMatrix());
            mat.postTranslate(SkIntToScalar(-x), SkIntToScalar(-y));
            fCanvas->setMatrix(mat);
            // Draw the picture
            if (fUseMultiPictureDraw) {
                SkMultiPictureDraw mpd;

                mpd.add(fCanvas, fPicture);

                mpd.draw();
            } else {
                fCanvas->drawPicture(fPicture);
            }
            // Now extract the picture into tiles
            SkBitmap baseBitmap;
            fCanvas->readPixels(SkIRect::MakeSize(fCanvas->getBaseLayerSize()), &baseBitmap);
            SkIRect subset;
            for (int tileY = 0; tileY < fLargeTileHeight; tileY += this->getTileHeight()) {
                for (int tileX = 0; tileX < fLargeTileWidth; tileX += this->getTileWidth()) {
                    subset.set(tileX, tileY, tileX + this->getTileWidth(),
                               tileY + this->getTileHeight());
                    SkDEBUGCODE(bool extracted =)
                    baseBitmap.extractSubset(&dst, subset);
                    SkASSERT(extracted);
                    if (!fWritePath.isEmpty()) {
                        // Similar to write() in PictureRenderer.cpp, but just encodes
                        // a bitmap directly.
                        // TODO: Share more common code with write() to do this, to properly
                        // write out the JSON summary, etc.
                        SkString pathWithNumber = SkOSPath::Join(fWritePath.c_str(),
                                                  fInputFilename.c_str());
                        pathWithNumber.remove(pathWithNumber.size() - 4, 4);
                        pathWithNumber.appendf("%i.png", i++);
                        SkBitmap copy;
#if SK_SUPPORT_GPU
                        if (isUsingGpuDevice()) {
                            dst.pixelRef()->readPixels(&copy, &subset);
                        } else {
#endif
                            dst.copyTo(&copy);
#if SK_SUPPORT_GPU
                        }
#endif
                        success &= SkImageEncoder::EncodeFile(pathWithNumber.c_str(), copy,
                                                              SkImageEncoder::kPNG_Type, 100);
                    }
                }
            }
        }
    }
    return success;
}
开发者ID:jagannathanraman,项目名称:skia,代码行数:62,代码来源:CopyTilesRenderer.cpp

示例5: tool_main

int tool_main(int argc, char** argv) {
    SkCommandLineFlags::SetUsage("Render .skp files.");
    SkCommandLineFlags::Parse(argc, argv);

    if (FLAGS_readPath.isEmpty()) {
        SkDebugf(".skp files or directories are required.\n");
        exit(-1);
    }

    if (FLAGS_maxComponentDiff < 0 || FLAGS_maxComponentDiff > 256) {
        SkDebugf("--maxComponentDiff must be between 0 and 256\n");
        exit(-1);
    }

    if (FLAGS_maxComponentDiff != 256 && !FLAGS_validate) {
        SkDebugf("--maxComponentDiff requires --validate\n");
        exit(-1);
    }

    if (FLAGS_writeEncodedImages) {
        if (FLAGS_writePath.isEmpty()) {
            SkDebugf("--writeEncodedImages requires --writePath\n");
            exit(-1);
        }
        if (FLAGS_deferImageDecoding) {
            SkDebugf("--writeEncodedImages is not compatible with --deferImageDecoding\n");
            exit(-1);
        }
    }

    SkString errorString;
    SkAutoTUnref<sk_tools::PictureRenderer> renderer(parseRenderer(errorString,
                                                                   kRender_PictureTool));
    if (errorString.size() > 0) {
        SkDebugf("%s\n", errorString.c_str());
    }

    if (renderer.get() == NULL) {
        exit(-1);
    }

    SkAutoGraphics ag;

    SkString writePath;
    if (FLAGS_writePath.count() == 1) {
        writePath.set(FLAGS_writePath[0]);
    }
    SkString mismatchPath;
    if (FLAGS_mismatchPath.count() == 1) {
        mismatchPath.set(FLAGS_mismatchPath[0]);
    }
    sk_tools::ImageResultsAndExpectations jsonSummary;
    sk_tools::ImageResultsAndExpectations* jsonSummaryPtr = NULL;
    if (FLAGS_writeJsonSummaryPath.count() == 1) {
        jsonSummaryPtr = &jsonSummary;
        if (FLAGS_readJsonSummaryPath.count() == 1) {
            SkASSERT(jsonSummary.readExpectationsFile(FLAGS_readJsonSummaryPath[0]));
        }
    }

    int failures = 0;
    for (int i = 0; i < FLAGS_readPath.count(); i ++) {
        failures += process_input(FLAGS_readPath[i], &writePath, &mismatchPath, *renderer.get(),
                                  jsonSummaryPtr);
    }
    if (failures != 0) {
        SkDebugf("Failed to render %i pictures.\n", failures);
        return 1;
    }
#if GR_CACHE_STATS && SK_SUPPORT_GPU
    if (renderer->isUsingGpuDevice()) {
        GrContext* ctx = renderer->getGrContext();
        ctx->printCacheStats();
    }
#endif

#if GR_GPU_STATS && SK_SUPPORT_GPU
    if (FLAGS_gpuStats && renderer->isUsingGpuDevice()) {
        renderer->getGrContext()->printGpuStats();
    }
#endif

    if (FLAGS_writeJsonSummaryPath.count() == 1) {
        // If there were any descriptions on the command line, insert them now.
        for (int i=0; i<FLAGS_descriptions.count(); i++) {
            SkTArray<SkString> tokens;
            SkStrSplit(FLAGS_descriptions[i], "=", &tokens);
            SkASSERT(tokens.count() == 2);
            jsonSummary.addDescription(tokens[0].c_str(), tokens[1].c_str());
        }
        if (FLAGS_imageBaseGSUrl.count() == 1) {
          jsonSummary.setImageBaseGSUrl(FLAGS_imageBaseGSUrl[0]);
        }
        jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]);
    }
    return 0;
}
开发者ID:webbjiang,项目名称:skia,代码行数:97,代码来源:render_pictures_main.cpp

示例6: fValue

SkPDFString::SkPDFString(const SkString& value)
    : fValue(FormatString(value.c_str(), value.size())) {
}
开发者ID:3rdexp,项目名称:soui,代码行数:3,代码来源:SkPDFTypes.cpp

示例7: addText

 void addText(const SkString& text) {
     fWriter->addText(text.c_str(), text.size());
 }
开发者ID:Jichao,项目名称:skia,代码行数:3,代码来源:SkSVGDevice.cpp

示例8: tool_main

int tool_main(int argc, char** argv) {
    SkCommandLineFlags::SetUsage("Render .skp files.");
    SkCommandLineFlags::Parse(argc, argv);

    if (FLAGS_readPath.isEmpty()) {
        SkDebugf(".skp files or directories are required.\n");
        exit(-1);
    }

    if (FLAGS_maxComponentDiff < 0 || FLAGS_maxComponentDiff > 256) {
        SkDebugf("--maxComponentDiff must be between 0 and 256\n");
        exit(-1);
    }

    if (FLAGS_maxComponentDiff != 256 && !FLAGS_validate) {
        SkDebugf("--maxComponentDiff requires --validate\n");
        exit(-1);
    }

    if (FLAGS_clone < 0) {
        SkDebugf("--clone must be >= 0. Was %i\n", FLAGS_clone);
        exit(-1);
    }

    if (FLAGS_writeEncodedImages) {
        if (FLAGS_writePath.isEmpty()) {
            SkDebugf("--writeEncodedImages requires --writePath\n");
            exit(-1);
        }
        if (FLAGS_deferImageDecoding) {
            SkDebugf("--writeEncodedImages is not compatible with --deferImageDecoding\n");
            exit(-1);
        }
    }

    SkString errorString;
    SkAutoTUnref<sk_tools::PictureRenderer> renderer(parseRenderer(errorString,
                                                                   kRender_PictureTool));
    if (errorString.size() > 0) {
        SkDebugf("%s\n", errorString.c_str());
    }

    if (renderer.get() == NULL) {
        exit(-1);
    }

    SkAutoGraphics ag;

    SkString outputDir;
    if (FLAGS_writePath.count() == 1) {
        outputDir.set(FLAGS_writePath[0]);
    }
    sk_tools::ImageResultsSummary jsonSummary;
    sk_tools::ImageResultsSummary* jsonSummaryPtr = NULL;
    if (FLAGS_writeJsonSummaryPath.count() == 1) {
        jsonSummaryPtr = &jsonSummary;
    }

    int failures = 0;
    for (int i = 0; i < FLAGS_readPath.count(); i ++) {
        failures += process_input(FLAGS_readPath[i], &outputDir, *renderer.get(), jsonSummaryPtr);
    }
    if (failures != 0) {
        SkDebugf("Failed to render %i pictures.\n", failures);
        return 1;
    }
#if SK_SUPPORT_GPU
#if GR_CACHE_STATS
    if (renderer->isUsingGpuDevice()) {
        GrContext* ctx = renderer->getGrContext();
        ctx->printCacheStats();
#ifdef SK_DEVELOPER
        ctx->dumpFontCache();
#endif
    }
#endif
#endif
    if (FLAGS_writeJsonSummaryPath.count() == 1) {
        jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]);
    }
    return 0;
}
开发者ID:weiron,项目名称:skia,代码行数:82,代码来源:render_pictures_main.cpp

示例9: setup_benchmark

static void setup_benchmark(sk_tools::PictureBenchmark* benchmark) {
    sk_tools::PictureRenderer::DrawFilterFlags drawFilters[SkDrawFilter::kTypeCount];
    sk_bzero(drawFilters, sizeof(drawFilters));

    if (FLAGS_filter.count() > 0) {
        const char* filters = FLAGS_filter[0];
        const char* colon = strchr(filters, ':');
        if (colon) {
            int32_t type = -1;
            size_t typeLen = colon - filters;
            for (size_t tIndex = 0; tIndex < kFilterTypesCount; ++tIndex) {
                if (typeLen == strlen(gFilterTypes[tIndex])
                        && !strncmp(filters, gFilterTypes[tIndex], typeLen)) {
                    type = SkToS32(tIndex);
                    break;
                }
            }
            if (type < 0) {
                SkString err;
                err.printf("Unknown type for --filter %s\n", filters);
                gLogger.logError(err);
                exit(-1);
            }
            int flag = -1;
            size_t flagLen = strlen(filters) - typeLen - 1;
            for (size_t fIndex = 0; fIndex < kFilterFlagsCount; ++fIndex) {
                if (flagLen == strlen(gFilterFlags[fIndex])
                        && !strncmp(colon + 1, gFilterFlags[fIndex], flagLen)) {
                    flag = 1 << fIndex;
                    break;
                }
            }
            if (flag < 0) {
                SkString err;
                err.printf("Unknown flag for --filter %s\n", filters);
                gLogger.logError(err);
                exit(-1);
            }
            for (int index = 0; index < SkDrawFilter::kTypeCount; ++index) {
                if (type != SkDrawFilter::kTypeCount && index != type) {
                    continue;
                }
                drawFilters[index] = (sk_tools::PictureRenderer::DrawFilterFlags)
                        (drawFilters[index] | flag);
            }
        } else {
            SkString err;
            err.printf("Unknown arg for --filter %s : missing colon\n", filters);
            gLogger.logError(err);
            exit(-1);
        }
    }

    if (FLAGS_timers.count() > 0) {
        size_t index = 0;
        bool timerWall = false;
        bool truncatedTimerWall = false;
        bool timerCpu = false;
        bool truncatedTimerCpu = false;
        bool timerGpu = false;
        while (index < strlen(FLAGS_timers[0])) {
            switch (FLAGS_timers[0][index]) {
                case 'w':
                    timerWall = true;
                    break;
                case 'c':
                    timerCpu = true;
                    break;
                case 'W':
                    truncatedTimerWall = true;
                    break;
                case 'C':
                    truncatedTimerCpu = true;
                    break;
                case 'g':
                    timerGpu = true;
                    break;
                default:
                    SkDebugf("mystery character\n");
                    break;
            }
            index++;
        }
        benchmark->setTimersToShow(timerWall, truncatedTimerWall, timerCpu, truncatedTimerCpu,
                                  timerGpu);
    }

    SkString errorString;
    SkAutoTUnref<sk_tools::PictureRenderer> renderer(parseRenderer(errorString,
                                                                   kBench_PictureTool));

    if (errorString.size() > 0) {
        gLogger.logError(errorString);
    }

    if (NULL == renderer.get()) {
        exit(-1);
    }

    if (FLAGS_timeIndividualTiles) {
//.........这里部分代码省略.........
开发者ID:Axure,项目名称:skia,代码行数:101,代码来源:bench_pictures_main.cpp

示例10: writeChangedAttributes

bool SkSVGPaint::writeChangedAttributes(SkSVGParser& parser,
        SkSVGPaint& current, bool* changed) {
    SkSVGPaint& lastState = parser.fLastFlush;
    for (int index = kInitial + 1; index < kTerminal; index++) {
        if (changed[index] == false)
                continue;
        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:
            case kEnableBackground:
                break;
            case kFill:
                if (topAttr->equals("none") == false && lastAttr->equals("none") == true)
                    parser._addAttribute("stroke", "false");
                goto fillStrokeAttrCommon;
            case kFillRule:
            case kFilter:
            case kFontFamily:
                break;
            case kFontSize:
                parser._addAttributeLen("textSize", attrValue, attrLength);
                break;
            case kLetterSpacing:
                parser._addAttributeLen("textTracking", attrValue, attrLength);
                break;
            case kMask:
                break;
            case kOpacity:
                break;
            case kStopColor:
                break;
            case kStopOpacity:
                break;
            case kStroke:
                if (topAttr->equals("none") == false && lastAttr->equals("none") == true)
                    parser._addAttribute("stroke", "true");
fillStrokeAttrCommon:
                if (strncmp(attrValue, "url(", 4) == 0) {
                    SkASSERT(attrValue[4] == '#');
                    const char* idStart = attrValue + 5;
                    const char* idEnd = strrchr(attrValue, ')');
                    SkASSERT(idStart < idEnd);
                    SkString id(idStart, idEnd - idStart);
                    SkSVGElement* found;
                    if (strncmp(id.c_str(), "mask", 4) != 0) {
                        bool itsFound = parser.fIDs.find(id.c_str(), &found);
                        SkASSERT(itsFound);
                        SkASSERT(found->getType() == SkSVGType_LinearGradient ||
                            found->getType() == SkSVGType_RadialGradient);
                    }
                    parser._addAttribute("shader", id.c_str());
                }
                break;
            case kStroke_Dasharray:
                break;
            case kStroke_Linecap:
                parser._addAttributeLen("strokeCap", attrValue, attrLength);
                break;
            case kStroke_Linejoin:
                parser._addAttributeLen("strokeJoin", attrValue, attrLength);
                break;
            case kStroke_Miterlimit:
                parser._addAttributeLen("strokeMiter", attrValue, attrLength);
                break;
            case kStroke_Width:
                parser._addAttributeLen("strokeWidth", attrValue, attrLength);
            case kStyle:
            case kTransform:
                break;
        default:
            SkASSERT(0);
            return false;
        }
    }
    return true;
}
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:82,代码来源:SkSVGPaintState.cpp

示例11: 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;
}
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:92,代码来源:SkSVGPaintState.cpp

示例12: 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
}
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:77,代码来源:SkSVGPaintState.cpp

示例13: flush

bool SkSVGPaint::flush(SkSVGParser& parser, bool isFlushable, bool isDef) {
    SkSVGPaint current;
    SkSVGPaint* walking = parser.fHead;
    int index;
    while (walking != NULL) {
        for (index = kInitial + 1; index < kTerminal; index++) {
            SkString* lastAttr = (*walking)[index];
            if (lastAttr->size() == 0)
                continue;
            if (current[index]->size() > 0)
                continue;
            current[index]->set(*lastAttr);
        }
        walking = walking->fNext;
    }
    bool paintChanged = false;
    SkSVGPaint& lastState = parser.fLastFlush;
    if (isFlushable == false) {
        if (isDef == true) {
            if (current.f_mask.size() > 0 && current.f_mask.equals(lastState.f_mask) == false) {
                SkSVGElement* found;
                const char* idStart = strchr(current.f_mask.c_str(), '#');
                SkASSERT(idStart);
                SkString id(idStart + 1, strlen(idStart) - 2);
                bool itsFound = parser.fIDs.find(id.c_str(), &found);
                SkASSERT(itsFound);
                SkSVGElement* gradient = found->getGradient();
                if (gradient) {
                    gradient->write(parser, current.f_fill);
                    gradient->write(parser, current.f_stroke);
                }
            }
        }
        goto setLast;
    }
    {
        bool changed[kTerminal];
        memset(changed, 0, sizeof(changed));
        for (index = kInitial + 1; index < kTerminal; index++) {
            if (index == kTransform || index == kClipPath || index == kStopColor || index == kStopOpacity ||
                    index == kClipRule || index == kFillRule)
                continue;
            SkString* lastAttr = lastState[index];
            SkString* currentAttr = current[index];
            paintChanged |= changed[index] = lastAttr->equals(*currentAttr) == false;
        }
        if (paintChanged) {
            if (current.f_mask.size() > 0) {
                if (current.f_fill.equals("none") == false && strncmp(current.f_fill.c_str(), "url(#", 5) != 0) {
                    SkASSERT(current.f_fill.c_str()[0] == '#');
                    SkString replacement("url(#mask");
                    replacement.append(current.f_fill.c_str() + 1);
                    replacement.appendUnichar(')');
                    current.f_fill.set(replacement);
                }
                if (current.f_stroke.equals("none") == false && strncmp(current.f_stroke.c_str(), "url(#", 5) != 0) {
                    SkASSERT(current.f_stroke.c_str()[0] == '#');
                    SkString replacement("url(#mask");
                    replacement.append(current.f_stroke.c_str() + 1);
                    replacement.appendUnichar(')');
                    current.f_stroke.set(replacement);
                }
            }
            if (current.f_fill.equals("none") && current.f_stroke.equals("none"))
                current.f_opacity.set("0");
            if (parser.fSuppressPaint == false) {
                parser._startElement("paint");
                bool success = writeChangedAttributes(parser, current, changed);
                if (success == false)
                    return paintChanged;
                success = writeChangedElements(parser, current, changed);
                if (success == false)
                    return paintChanged;
                parser._endElement(); // paint
            }
        }
    }
setLast:
    for (index = kInitial + 1; index < kTerminal; index++) {
        SkString* lastAttr = lastState[index];
        SkString* currentAttr = current[index];
        lastAttr->set(*currentAttr);
    }
    return paintChanged;
}
开发者ID:AshishNamdev,项目名称:mozilla-central,代码行数:85,代码来源:SkSVGPaintState.cpp

示例14: draw_string

static SkScalar draw_string(SkCanvas* canvas, const SkString& text, SkScalar x,
                           SkScalar y, const SkFont& font) {
    SkPaint paint;
    canvas->drawString(text, x, y, font, paint);
    return x + font.measureText(text.c_str(), text.size(), SkTextEncoding::kUTF8);
}
开发者ID:google,项目名称:skia,代码行数:6,代码来源:fontcache.cpp

示例15: writeScalarAsText

bool SkWStream::writeScalarAsText(SkScalar value)
{
    SkString    tmp;
    tmp.appendScalar(value);
    return this->write(tmp.c_str(), tmp.size());
}
开发者ID:BBKeeper,项目名称:Skia,代码行数:6,代码来源:SkStream.cpp


注:本文中的SkString::size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。