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

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

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

mercurial