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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /*
     2  * Copyright 2006 The Android Open Source Project
     3  *
     4  * Use of this source code is governed by a BSD-style license that can be
     5  * found in the LICENSE file.
     6  */
     8 #include "SkSmallAllocator.h"
     9 #include "SkSpriteBlitter.h"
    11 SkSpriteBlitter::SkSpriteBlitter(const SkBitmap& source)
    12         : fSource(&source) {
    13     fSource->lockPixels();
    14 }
    16 SkSpriteBlitter::~SkSpriteBlitter() {
    17     fSource->unlockPixels();
    18 }
    20 void SkSpriteBlitter::setup(const SkBitmap& device, int left, int top,
    21                             const SkPaint& paint) {
    22     fDevice = &device;
    23     fLeft = left;
    24     fTop = top;
    25     fPaint = &paint;
    26 }
    28 #ifdef SK_DEBUG
    29 void SkSpriteBlitter::blitH(int x, int y, int width) {
    30     SkDEBUGFAIL("how did we get here?");
    31 }
    33 void SkSpriteBlitter::blitAntiH(int x, int y, const SkAlpha antialias[],
    34                                 const int16_t runs[]) {
    35     SkDEBUGFAIL("how did we get here?");
    36 }
    38 void SkSpriteBlitter::blitV(int x, int y, int height, SkAlpha alpha) {
    39     SkDEBUGFAIL("how did we get here?");
    40 }
    42 void SkSpriteBlitter::blitMask(const SkMask&, const SkIRect& clip) {
    43     SkDEBUGFAIL("how did we get here?");
    44 }
    45 #endif
    47 ///////////////////////////////////////////////////////////////////////////////
    49 // returning null means the caller will call SkBlitter::Choose() and
    50 // have wrapped the source bitmap inside a shader
    51 SkBlitter* SkBlitter::ChooseSprite(const SkBitmap& device, const SkPaint& paint,
    52         const SkBitmap& source, int left, int top, SkTBlitterAllocator* allocator) {
    53     /*  We currently ignore antialiasing and filtertype, meaning we will take our
    54         special blitters regardless of these settings. Ignoring filtertype seems fine
    55         since by definition there is no scale in the matrix. Ignoring antialiasing is
    56         a bit of a hack, since we "could" pass in the fractional left/top for the bitmap,
    57         and respect that by blending the edges of the bitmap against the device. To support
    58         this we could either add more special blitters here, or detect antialiasing in the
    59         paint and return null if it is set, forcing the client to take the slow shader case
    60         (which does respect soft edges).
    61     */
    62     SkASSERT(allocator != NULL);
    64     SkSpriteBlitter* blitter;
    66     switch (device.colorType()) {
    67         case kRGB_565_SkColorType:
    68             blitter = SkSpriteBlitter::ChooseD16(source, paint, allocator);
    69             break;
    70         case kPMColor_SkColorType:
    71             blitter = SkSpriteBlitter::ChooseD32(source, paint, allocator);
    72             break;
    73         default:
    74             blitter = NULL;
    75             break;
    76     }
    78     if (blitter) {
    79         blitter->setup(device, left, top, paint);
    80     }
    81     return blitter;
    82 }

mercurial