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


C++ SkMatrix::setPolyToPoly方法代码示例

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


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

示例1: doDraw

    static void doDraw(SkCanvas* canvas, SkPaint* paint, const int isrc[],
                       const int idst[], int count) {
        SkMatrix matrix;
        SkPoint src[4], dst[4];

        for (int i = 0; i < count; i++) {
            src[i].set(SkIntToScalar(isrc[2*i+0]), SkIntToScalar(isrc[2*i+1]));
            dst[i].set(SkIntToScalar(idst[2*i+0]), SkIntToScalar(idst[2*i+1]));
        }

        canvas->save();
        matrix.setPolyToPoly(src, dst, count);
        canvas->concat(matrix);

        paint->setColor(sk_tool_utils::color_to_565(SK_ColorGRAY));
        paint->setStyle(SkPaint::kStroke_Style);
        const SkScalar D = 64;
        canvas->drawRect(SkRect::MakeWH(D, D), *paint);
        canvas->drawLine(0, 0, D, D, *paint);
        canvas->drawLine(0, D, D, 0, *paint);

        SkPaint::FontMetrics fm;
        paint->getFontMetrics(&fm);
        paint->setColor(SK_ColorRED);
        paint->setStyle(SkPaint::kFill_Style);
        SkScalar x = D/2;
        SkScalar y = D/2 - (fm.fAscent + fm.fDescent)/2;
        uint16_t glyphID = 3; // X
        canvas->drawText((void*) &glyphID, sizeof(glyphID), x, y, *paint);
        canvas->restore();
    }
开发者ID:MIPS,项目名称:external-skia,代码行数:31,代码来源:poly2poly.cpp

示例2: NativeSetPolyToPoly

Boolean Matrix::NativeSetPolyToPoly(
    /* [in] */ Int64 nObj,
    /* [in] */ ArrayOf<Float>* _src,
    /* [in] */ Int32 srcIndex,
    /* [out] */ ArrayOf<Float>* _dst,
    /* [in] */ Int32 dstIndex,
    /* [in] */ Int32 ptCount)
{
    SkASSERT(srcIndex >= 0);
    SkASSERT(dstIndex >= 0);
    SkASSERT(ptCount <= 4);

    SkASSERT(_src->GetLength() >= srcIndex + (ptCount << 1));
    SkASSERT(_dst->GetLength() >= dstIndex + (ptCount << 1));

    SkMatrix* matrix = reinterpret_cast<SkMatrix*>(nObj);
    SkASSERT(srcIndex >= 0);
    SkASSERT(dstIndex >= 0);
    SkASSERT((unsigned)ptCount <= 4);

    // AutoJavaFloatArray autoSrc(env, jsrc, srcIndex + (ptCount << 1), kRO_JNIAccess);
    // AutoJavaFloatArray autoDst(env, jdst, dstIndex + (ptCount << 1), kRW_JNIAccess);
    Float* src = _src->GetPayload() + srcIndex;
    Float* dst = _dst->GetPayload() + dstIndex;
    bool result;

#ifdef SK_SCALAR_IS_FLOAT
    result = matrix->setPolyToPoly((const SkPoint*)src, (const SkPoint*)dst,
                                 ptCount);
#else
    SkASSERT(FALSE);
#endif
    return result ? TRUE : FALSE;
}
开发者ID:maerson,项目名称:CPP_Framework_Elastos5,代码行数:34,代码来源:Matrix.cpp

示例3: doDraw

    static void doDraw(SkCanvas* canvas, SkPaint* paint, const int isrc[],
                       const int idst[], int count) {
        SkMatrix matrix;
        SkPoint src[4], dst[4];

        for (int i = 0; i < count; i++) {
            src[i].set(SkIntToScalar(isrc[2*i+0]), SkIntToScalar(isrc[2*i+1]));
            dst[i].set(SkIntToScalar(idst[2*i+0]), SkIntToScalar(idst[2*i+1]));
        }

        canvas->save();
        matrix.setPolyToPoly(src, dst, count);
        canvas->concat(matrix);

        paint->setColor(SK_ColorGRAY);
        paint->setStyle(SkPaint::kStroke_Style);
        const SkScalar D = SkIntToScalar(64);
        canvas->drawRectCoords(0, 0, D, D, *paint);
        canvas->drawLine(0, 0, D, D, *paint);
        canvas->drawLine(0, D, D, 0, *paint);

        SkPaint::FontMetrics fm;
        paint->getFontMetrics(&fm);
        paint->setColor(SK_ColorRED);
        paint->setStyle(SkPaint::kFill_Style);
        SkScalar x = D/2;
        float y = D/2 - (fm.fAscent + fm.fDescent)/2;
        SkString str;
        str.appendS32(count);
        canvas->drawText(str.c_str(), str.size(),
                         x, y,
                         *paint);

        canvas->restore();
    }
开发者ID:ROM-PacMe,项目名称:skia,代码行数:35,代码来源:SamplePolyToPoly.cpp

示例4: draw

void draw(SkCanvas* canvas) {
    SkMatrix matrix;
    SkPoint bitmapBounds[4], perspect[4] = {{50, 10}, {180, 40}, {236, 176}, {10, 206}};
    SkRect::Make(source.bounds()).toQuad(bitmapBounds);
    matrix.setPolyToPoly(bitmapBounds, perspect, 4);
    matrix.preScale(.75f, 1.5f, source.width() / 2, source.height() / 2);
    canvas->concat(matrix);
    canvas->drawBitmap(source, 0, 0);
}
开发者ID:HalCanary,项目名称:skia-hc,代码行数:9,代码来源:Matrix_preScale.cpp

示例5: setPolyToPoly

    static jboolean setPolyToPoly(JNIEnv* env, jobject clazz, jlong matrixHandle,
                                  jfloatArray jsrc, jint srcIndex,
                                  jfloatArray jdst, jint dstIndex, jint ptCount) {
        SkMatrix* matrix = reinterpret_cast<SkMatrix*>(matrixHandle);
        SkASSERT(srcIndex >= 0);
        SkASSERT(dstIndex >= 0);
        SkASSERT((unsigned)ptCount <= 4);

        AutoJavaFloatArray autoSrc(env, jsrc, srcIndex + (ptCount << 1), kRO_JNIAccess);
        AutoJavaFloatArray autoDst(env, jdst, dstIndex + (ptCount << 1), kRW_JNIAccess);
        float* src = autoSrc.ptr() + srcIndex;
        float* dst = autoDst.ptr() + dstIndex;
        bool result;

#ifdef SK_SCALAR_IS_FLOAT
        result = matrix->setPolyToPoly((const SkPoint*)src, (const SkPoint*)dst,
                                     ptCount);
#else
        SkASSERT(false);
#endif
        return result ? JNI_TRUE : JNI_FALSE;
    }
开发者ID:7tiny,项目名称:platform_frameworks_base,代码行数:22,代码来源:Matrix.cpp


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