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 "SkCoreBlitters.h"
11 :
12 0 : SkA1_Blitter::SkA1_Blitter(const SkBitmap& device, const SkPaint& paint)
13 0 : : INHERITED(device) {
14 0 : fSrcA = paint.getAlpha();
15 0 : }
16 :
17 0 : void SkA1_Blitter::blitH(int x, int y, int width) {
18 0 : SkASSERT(x >= 0 && y >= 0 &&
19 : (unsigned)(x + width) <= (unsigned)fDevice.width());
20 :
21 0 : if (fSrcA <= 0x7F) {
22 0 : return;
23 : }
24 0 : uint8_t* dst = fDevice.getAddr1(x, y);
25 0 : int right = x + width;
26 :
27 0 : int left_mask = 0xFF >> (x & 7);
28 0 : int rite_mask = 0xFF << (8 - (right & 7));
29 0 : int full_runs = (right >> 3) - ((x + 7) >> 3);
30 :
31 : // check for empty right mask, so we don't read off the end
32 : // (or go slower than we need to)
33 0 : if (rite_mask == 0) {
34 0 : SkASSERT(full_runs >= 0);
35 0 : full_runs -= 1;
36 0 : rite_mask = 0xFF;
37 : }
38 0 : if (left_mask == 0xFF) {
39 0 : full_runs -= 1;
40 : }
41 0 : if (full_runs < 0) {
42 0 : SkASSERT((left_mask & rite_mask) != 0);
43 0 : *dst |= (left_mask & rite_mask);
44 : } else {
45 0 : *dst++ |= left_mask;
46 0 : memset(dst, 0xFF, full_runs);
47 0 : dst += full_runs;
48 0 : *dst |= rite_mask;
49 : }
50 : }
51 :
|