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 #ifndef SkSpriteBlitter_DEFINED 9 #define SkSpriteBlitter_DEFINED 10 11 #include "SkBlitter.h" 12 #include "SkPixmap.h" 13 #include "SkShader.h" 14 15 class SkPaint; 16 17 // SkSpriteBlitter specializes SkBlitter in a way to move large rectangles of pixels around. 18 // Because of this use, the main primitive shifts from blitH style things to the more efficient 19 // blitRect. 20 class SkSpriteBlitter : public SkBlitter { 21 public: 22 SkSpriteBlitter(const SkPixmap& source); 23 24 virtual void setup(const SkPixmap& dst, int left, int top, const SkPaint&); 25 26 // blitH, blitAntiH, blitV and blitMask should not be called on an SkSpriteBlitter. 27 void blitH(int x, int y, int width) override; 28 void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override; 29 void blitV(int x, int y, int height, SkAlpha alpha) override; 30 void blitMask(const SkMask&, const SkIRect& clip) override; 31 32 // A SkSpriteBlitter must implement blitRect. 33 void blitRect(int x, int y, int width, int height) override = 0; 34 35 static SkSpriteBlitter* ChooseD16(const SkPixmap& source, const SkPaint&, SkArenaAlloc*); 36 static SkSpriteBlitter* ChooseL32(const SkPixmap& source, const SkPaint&, SkArenaAlloc*); 37 static SkSpriteBlitter* ChooseS32(const SkPixmap& source, const SkPaint&, SkArenaAlloc*); 38 static SkSpriteBlitter* ChooseF16(const SkPixmap& source, const SkPaint&, SkArenaAlloc*); 39 40 protected: 41 SkPixmap fDst; 42 const SkPixmap fSource; 43 int fLeft, fTop; 44 const SkPaint* fPaint; 45 46 private: 47 typedef SkBlitter INHERITED; 48 }; 49 50 #endif 51