• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "include/core/SkPixmap.h"
12 #include "include/core/SkShader.h"
13 #include "src/core/SkBlitter.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 bool 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 
37 protected:
38     SkPixmap        fDst;
39     const SkPixmap  fSource;
40     int             fLeft, fTop;
41     const SkPaint*  fPaint;
42 
43 private:
44     using INHERITED = SkBlitter;
45 };
46 
47 #endif
48