gfx/skia/trunk/src/core/SkBlitter_Sprite.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/skia/trunk/src/core/SkBlitter_Sprite.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,82 @@
     1.4 +/*
     1.5 + * Copyright 2006 The Android Open Source Project
     1.6 + *
     1.7 + * Use of this source code is governed by a BSD-style license that can be
     1.8 + * found in the LICENSE file.
     1.9 + */
    1.10 +
    1.11 +#include "SkSmallAllocator.h"
    1.12 +#include "SkSpriteBlitter.h"
    1.13 +
    1.14 +SkSpriteBlitter::SkSpriteBlitter(const SkBitmap& source)
    1.15 +        : fSource(&source) {
    1.16 +    fSource->lockPixels();
    1.17 +}
    1.18 +
    1.19 +SkSpriteBlitter::~SkSpriteBlitter() {
    1.20 +    fSource->unlockPixels();
    1.21 +}
    1.22 +
    1.23 +void SkSpriteBlitter::setup(const SkBitmap& device, int left, int top,
    1.24 +                            const SkPaint& paint) {
    1.25 +    fDevice = &device;
    1.26 +    fLeft = left;
    1.27 +    fTop = top;
    1.28 +    fPaint = &paint;
    1.29 +}
    1.30 +
    1.31 +#ifdef SK_DEBUG
    1.32 +void SkSpriteBlitter::blitH(int x, int y, int width) {
    1.33 +    SkDEBUGFAIL("how did we get here?");
    1.34 +}
    1.35 +
    1.36 +void SkSpriteBlitter::blitAntiH(int x, int y, const SkAlpha antialias[],
    1.37 +                                const int16_t runs[]) {
    1.38 +    SkDEBUGFAIL("how did we get here?");
    1.39 +}
    1.40 +
    1.41 +void SkSpriteBlitter::blitV(int x, int y, int height, SkAlpha alpha) {
    1.42 +    SkDEBUGFAIL("how did we get here?");
    1.43 +}
    1.44 +
    1.45 +void SkSpriteBlitter::blitMask(const SkMask&, const SkIRect& clip) {
    1.46 +    SkDEBUGFAIL("how did we get here?");
    1.47 +}
    1.48 +#endif
    1.49 +
    1.50 +///////////////////////////////////////////////////////////////////////////////
    1.51 +
    1.52 +// returning null means the caller will call SkBlitter::Choose() and
    1.53 +// have wrapped the source bitmap inside a shader
    1.54 +SkBlitter* SkBlitter::ChooseSprite(const SkBitmap& device, const SkPaint& paint,
    1.55 +        const SkBitmap& source, int left, int top, SkTBlitterAllocator* allocator) {
    1.56 +    /*  We currently ignore antialiasing and filtertype, meaning we will take our
    1.57 +        special blitters regardless of these settings. Ignoring filtertype seems fine
    1.58 +        since by definition there is no scale in the matrix. Ignoring antialiasing is
    1.59 +        a bit of a hack, since we "could" pass in the fractional left/top for the bitmap,
    1.60 +        and respect that by blending the edges of the bitmap against the device. To support
    1.61 +        this we could either add more special blitters here, or detect antialiasing in the
    1.62 +        paint and return null if it is set, forcing the client to take the slow shader case
    1.63 +        (which does respect soft edges).
    1.64 +    */
    1.65 +    SkASSERT(allocator != NULL);
    1.66 +
    1.67 +    SkSpriteBlitter* blitter;
    1.68 +
    1.69 +    switch (device.colorType()) {
    1.70 +        case kRGB_565_SkColorType:
    1.71 +            blitter = SkSpriteBlitter::ChooseD16(source, paint, allocator);
    1.72 +            break;
    1.73 +        case kPMColor_SkColorType:
    1.74 +            blitter = SkSpriteBlitter::ChooseD32(source, paint, allocator);
    1.75 +            break;
    1.76 +        default:
    1.77 +            blitter = NULL;
    1.78 +            break;
    1.79 +    }
    1.80 +
    1.81 +    if (blitter) {
    1.82 +        blitter->setup(device, left, top, paint);
    1.83 +    }
    1.84 +    return blitter;
    1.85 +}

mercurial