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* ChooseL32(const SkPixmap& source, const SkPaint&, SkArenaAlloc*); 36 static SkSpriteBlitter* ChooseL565(const SkPixmap& source, const SkPaint&, SkArenaAlloc*); 37 static SkSpriteBlitter* ChooseLA8(const SkPixmap& source, const SkPaint&, SkArenaAlloc*); 38 39 protected: 40 SkPixmap fDst; 41 const SkPixmap fSource; 42 int fLeft, fTop; 43 const SkPaint* fPaint; 44 45 private: 46 typedef SkBlitter INHERITED; 47 }; 48 49 #endif 50