| 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 | */ | 
|---|
| 7 |  | 
|---|
| 8 | #include "include/core/SkShader.h" | 
|---|
| 9 | #include "include/private/SkColorData.h" | 
|---|
| 10 | #include "src/core/SkCoreBlitters.h" | 
|---|
| 11 | #include "src/core/SkXfermodePriv.h" | 
|---|
| 12 |  | 
|---|
| 13 | SkA8_Coverage_Blitter::SkA8_Coverage_Blitter(const SkPixmap& device, | 
|---|
| 14 | const SkPaint& paint) : SkRasterBlitter(device) { | 
|---|
| 15 | SkASSERT(nullptr == paint.getShader()); | 
|---|
| 16 | SkASSERT(paint.isSrcOver()); | 
|---|
| 17 | SkASSERT(nullptr == paint.getColorFilter()); | 
|---|
| 18 | } | 
|---|
| 19 |  | 
|---|
| 20 | void SkA8_Coverage_Blitter::blitAntiH(int x, int y, const SkAlpha antialias[], | 
|---|
| 21 | const int16_t runs[]) { | 
|---|
| 22 | uint8_t* device = fDevice.writable_addr8(x, y); | 
|---|
| 23 | SkDEBUGCODE(int totalCount = 0;) | 
|---|
| 24 |  | 
|---|
| 25 | for (;;) { | 
|---|
| 26 | int count = runs[0]; | 
|---|
| 27 | SkASSERT(count >= 0); | 
|---|
| 28 | if (count == 0) { | 
|---|
| 29 | return; | 
|---|
| 30 | } | 
|---|
| 31 | if (antialias[0]) { | 
|---|
| 32 | memset(device, antialias[0], count); | 
|---|
| 33 | } | 
|---|
| 34 | runs += count; | 
|---|
| 35 | antialias += count; | 
|---|
| 36 | device += count; | 
|---|
| 37 |  | 
|---|
| 38 | SkDEBUGCODE(totalCount += count;) | 
|---|
| 39 | } | 
|---|
| 40 | SkASSERT(fDevice.width() == totalCount); | 
|---|
| 41 | } | 
|---|
| 42 |  | 
|---|
| 43 | void SkA8_Coverage_Blitter::blitH(int x, int y, int width) { | 
|---|
| 44 | memset(fDevice.writable_addr8(x, y), 0xFF, width); | 
|---|
| 45 | } | 
|---|
| 46 |  | 
|---|
| 47 | void SkA8_Coverage_Blitter::blitV(int x, int y, int height, SkAlpha alpha) { | 
|---|
| 48 | if (0 == alpha) { | 
|---|
| 49 | return; | 
|---|
| 50 | } | 
|---|
| 51 |  | 
|---|
| 52 | uint8_t* dst = fDevice.writable_addr8(x, y); | 
|---|
| 53 | const size_t dstRB = fDevice.rowBytes(); | 
|---|
| 54 | while (--height >= 0) { | 
|---|
| 55 | *dst = alpha; | 
|---|
| 56 | dst += dstRB; | 
|---|
| 57 | } | 
|---|
| 58 | } | 
|---|
| 59 |  | 
|---|
| 60 | void SkA8_Coverage_Blitter::blitRect(int x, int y, int width, int height) { | 
|---|
| 61 | uint8_t* dst = fDevice.writable_addr8(x, y); | 
|---|
| 62 | const size_t dstRB = fDevice.rowBytes(); | 
|---|
| 63 | while (--height >= 0) { | 
|---|
| 64 | memset(dst, 0xFF, width); | 
|---|
| 65 | dst += dstRB; | 
|---|
| 66 | } | 
|---|
| 67 | } | 
|---|
| 68 |  | 
|---|
| 69 | void SkA8_Coverage_Blitter::blitMask(const SkMask& mask, const SkIRect& clip) { | 
|---|
| 70 | if (SkMask::kA8_Format != mask.fFormat) { | 
|---|
| 71 | this->INHERITED::blitMask(mask, clip); | 
|---|
| 72 | return; | 
|---|
| 73 | } | 
|---|
| 74 |  | 
|---|
| 75 | int x = clip.fLeft; | 
|---|
| 76 | int y = clip.fTop; | 
|---|
| 77 | int width = clip.width(); | 
|---|
| 78 | int height = clip.height(); | 
|---|
| 79 |  | 
|---|
| 80 | uint8_t* dst = fDevice.writable_addr8(x, y); | 
|---|
| 81 | const uint8_t* src = mask.getAddr8(x, y); | 
|---|
| 82 | const size_t srcRB = mask.fRowBytes; | 
|---|
| 83 | const size_t dstRB = fDevice.rowBytes(); | 
|---|
| 84 |  | 
|---|
| 85 | while (--height >= 0) { | 
|---|
| 86 | memcpy(dst, src, width); | 
|---|
| 87 | dst += dstRB; | 
|---|
| 88 | src += srcRB; | 
|---|
| 89 | } | 
|---|
| 90 | } | 
|---|
| 91 |  | 
|---|
| 92 | const SkPixmap* SkA8_Coverage_Blitter::justAnOpaqueColor(uint32_t*) { | 
|---|
| 93 | return nullptr; | 
|---|
| 94 | } | 
|---|
| 95 |  | 
|---|