コード例 #1
0
// returning null means the caller will call SkBlitter::Choose() and
// have wrapped the source bitmap inside a shader
SkBlitter* SkBlitter::ChooseSprite( const SkBitmap& device,
                                    const SkPaint& paint,
                                    const SkBitmap& source,
                                    int left, int top,
                                    void* storage, size_t storageSize)
{
    /*  We currently ignore antialiasing and filtertype, meaning we will take our
        special blitters regardless of these settings. Ignoring filtertype seems fine
        since by definition there is no scale in the matrix. Ignoring antialiasing is
        a bit of a hack, since we "could" pass in the fractional left/top for the bitmap,
        and respect that by blending the edges of the bitmap against the device. To support
        this we could either add more special blitters here, or detect antialiasing in the
        paint and return null if it is set, forcing the client to take the slow shader case
        (which does respect soft edges).
    */

    SkSpriteBlitter* blitter;

    switch (device.getConfig()) {
    case SkBitmap::kRGB_565_Config:
        blitter = SkSpriteBlitter::ChooseD16(source, paint, storage, storageSize);
        break;
    case SkBitmap::kARGB_8888_Config:
        blitter = SkSpriteBlitter::ChooseD32(source, paint, storage, storageSize);
        break;
    default:
        blitter = NULL;
        break;
    }

    if (blitter)
        blitter->setup(device, left, top, paint);
    return blitter;
}
コード例 #2
0
ファイル: SkBlitter_Sprite.cpp プロジェクト: guolianzhu/skia
// returning null means the caller will call SkBlitter::Choose() and
// have wrapped the source bitmap inside a shader
SkBlitter* SkBlitter::ChooseSprite(const SkPixmap& dst, const SkPaint& paint,
        const SkPixmap& source, int left, int top, SkTBlitterAllocator* allocator) {
    /*  We currently ignore antialiasing and filtertype, meaning we will take our
        special blitters regardless of these settings. Ignoring filtertype seems fine
        since by definition there is no scale in the matrix. Ignoring antialiasing is
        a bit of a hack, since we "could" pass in the fractional left/top for the bitmap,
        and respect that by blending the edges of the bitmap against the device. To support
        this we could either add more special blitters here, or detect antialiasing in the
        paint and return null if it is set, forcing the client to take the slow shader case
        (which does respect soft edges).
    */
    SkASSERT(allocator != NULL);

    SkSpriteBlitter* blitter;

    switch (dst.colorType()) {
        case kRGB_565_SkColorType:
            blitter = SkSpriteBlitter::ChooseD16(source, paint, allocator);
            break;
        case kN32_SkColorType:
            blitter = SkSpriteBlitter::ChooseD32(source, paint, allocator);
            break;
        default:
            blitter = NULL;
            break;
    }

    if (blitter) {
        blitter->setup(dst, left, top, paint);
    }
    return blitter;
}
コード例 #3
0
ファイル: SkBlitter_Sprite.cpp プロジェクト: google/skia
// returning null means the caller will call SkBlitter::Choose() and
// have wrapped the source bitmap inside a shader
SkBlitter* SkBlitter::ChooseSprite(const SkPixmap& dst, const SkPaint& paint,
        const SkPixmap& source, int left, int top, SkArenaAlloc* allocator) {
    /*  We currently ignore antialiasing and filtertype, meaning we will take our
        special blitters regardless of these settings. Ignoring filtertype seems fine
        since by definition there is no scale in the matrix. Ignoring antialiasing is
        a bit of a hack, since we "could" pass in the fractional left/top for the bitmap,
        and respect that by blending the edges of the bitmap against the device. To support
        this we could either add more special blitters here, or detect antialiasing in the
        paint and return null if it is set, forcing the client to take the slow shader case
        (which does respect soft edges).
    */
    SkASSERT(allocator != nullptr);

    if (source.alphaType() == kUnpremul_SkAlphaType) {
        return nullptr;
    }

    SkSpriteBlitter* blitter = nullptr;

    if (!SkColorSpaceXformSteps::Required(source.colorSpace(), dst.colorSpace())) {
        if (!blitter && SkSpriteBlitter_Memcpy::Supports(dst, source, paint)) {
            blitter = allocator->make<SkSpriteBlitter_Memcpy>(source);
        }
        if (!blitter) {
            switch (dst.colorType()) {
                case kN32_SkColorType:
                    blitter = SkSpriteBlitter::ChooseL32(source, paint, allocator);
                    break;
                case kRGB_565_SkColorType:
                    blitter = SkSpriteBlitter::ChooseL565(source, paint, allocator);
                    break;
                case kAlpha_8_SkColorType:
                    blitter = SkSpriteBlitter::ChooseLA8(source, paint, allocator);
                    break;
                default:
                    break;
            }
        }
    }
    if (!blitter && !paint.getMaskFilter()) {
        blitter = allocator->make<SkRasterPipelineSpriteBlitter>(source, allocator);
    }

    if (blitter) {
        blitter->setup(dst, left, top, paint);
    }
    return blitter;
}
コード例 #4
0
// returning null means the caller will call SkBlitter::Choose() and
// have wrapped the source bitmap inside a shader
SkBlitter* SkBlitter::ChooseSprite(const SkPixmap& dst, const SkPaint& paint,
        const SkPixmap& source, int left, int top, SkArenaAlloc* allocator) {
    /*  We currently ignore antialiasing and filtertype, meaning we will take our
        special blitters regardless of these settings. Ignoring filtertype seems fine
        since by definition there is no scale in the matrix. Ignoring antialiasing is
        a bit of a hack, since we "could" pass in the fractional left/top for the bitmap,
        and respect that by blending the edges of the bitmap against the device. To support
        this we could either add more special blitters here, or detect antialiasing in the
        paint and return null if it is set, forcing the client to take the slow shader case
        (which does respect soft edges).
    */
    SkASSERT(allocator != nullptr);

    // Defer to the general code if the pixels are unpremultipled. This case is not common,
    // and this simplifies the code.
    if (source.alphaType() == kUnpremul_SkAlphaType) {
        return nullptr;
    }

    SkSpriteBlitter* blitter = nullptr;

    if (SkSpriteBlitter_Src_SrcOver::Supports(dst, source, paint)) {
        blitter = allocator->make<SkSpriteBlitter_Src_SrcOver>(source);
    } else {
        switch (dst.colorType()) {
            case kRGB_565_SkColorType:
                blitter = SkSpriteBlitter::ChooseD16(source, paint, allocator);
                break;
            case kN32_SkColorType:
                if (dst.info().gammaCloseToSRGB()) {
                    blitter = SkSpriteBlitter::ChooseS32(source, paint, allocator);
                } else {
                    blitter = SkSpriteBlitter::ChooseL32(source, paint, allocator);
                }
                break;
            case kRGBA_F16_SkColorType:
                blitter = SkSpriteBlitter::ChooseF16(source, paint, allocator);
                break;
            default:
                break;
        }
    }

    if (blitter) {
        blitter->setup(dst, left, top, paint);
    }
    return blitter;
}