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