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 11 class SkSPRITE_CLASSNAME : public SkSpriteBlitter { 12 public: SkSPRITE_CLASSNAME(const SkBitmap & source SkSPRITE_ARGS)13 SkSPRITE_CLASSNAME(const SkBitmap& source SkSPRITE_ARGS) 14 : SkSpriteBlitter(source) { 15 SkSPRITE_INIT 16 } 17 blitRect(int x,int y,int width,int height)18 virtual void blitRect(int x, int y, int width, int height) { 19 SkASSERT(width > 0 && height > 0); 20 int srcX = x - fLeft; 21 int srcY = y - fTop; 22 SkSPRITE_DST_TYPE* SK_RESTRICT dst =fDevice->SkSPRITE_DST_GETADDR(x, y); 23 const SkSPRITE_SRC_TYPE* SK_RESTRICT src = 24 fSource->SkSPRITE_SRC_GETADDR(srcX, srcY); 25 size_t dstRB = fDevice->rowBytes(); 26 size_t srcRB = fSource->rowBytes(); 27 28 SkDEBUGCODE((void)fDevice->SkSPRITE_DST_GETADDR(x + width - 1, y + height - 1);) 29 SkDEBUGCODE((void)fSource->SkSPRITE_SRC_GETADDR(srcX + width - 1, srcY + height - 1);) 30 31 SkSPRITE_PREAMBLE((*fSource), srcX, srcY); 32 33 do { 34 SkSPRITE_DST_TYPE* d = dst; 35 const SkSPRITE_SRC_TYPE* s = src; 36 #ifdef SkSPRITE_BEGIN_ROW 37 SkSPRITE_BEGIN_ROW 38 #endif 39 40 #ifdef SkSPRITE_ROW_PROC 41 SkSPRITE_ROW_PROC(d, s, width, x, y); 42 #else 43 int w = width; 44 do { 45 SkSPRITE_SRC_TYPE sc = *s++; 46 SkSPRITE_BLIT_PIXEL(d, sc); 47 d += 1; 48 } while (--w != 0); 49 #endif 50 dst = (SkSPRITE_DST_TYPE* SK_RESTRICT)((char*)dst + dstRB); 51 src = (const SkSPRITE_SRC_TYPE* SK_RESTRICT) 52 ((const char*)src + srcRB); 53 SkSPRITE_NEXT_ROW 54 #ifdef SkSPRITE_ROW_PROC 55 y += 1; 56 #endif 57 } while (--height != 0); 58 59 SkSPRITE_POSTAMBLE((*fSource)); 60 } 61 62 private: 63 SkSPRITE_FIELDS 64 }; 65 66 #undef SkSPRITE_BLIT_PIXEL 67 #undef SkSPRITE_CLASSNAME 68 #undef SkSPRITE_DST_TYPE 69 #undef SkSPRITE_SRC_TYPE 70 #undef SkSPRITE_DST_GETADDR 71 #undef SkSPRITE_SRC_GETADDR 72 #undef SkSPRITE_PREAMBLE 73 #undef SkSPRITE_POSTAMBLE 74 #undef SkSPRITE_ARGS 75 #undef SkSPRITE_FIELDS 76 #undef SkSPRITE_INIT 77 #undef SkSPRITE_NEXT_ROW 78 #undef SkSPRITE_BEGIN_ROW 79 80 #ifdef SkSPRITE_ROW_PROC 81 #undef SkSPRITE_ROW_PROC 82 #endif 83