epoger@google.com | ec3ed6a | 2011-07-28 14:26:00 +0000 | [diff] [blame] | 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 | |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 8 | #ifndef SkSpriteBlitter_DEFINED |
| 9 | #define SkSpriteBlitter_DEFINED |
| 10 | |
commit-bot@chromium.org | a5572e5 | 2014-03-07 03:24:41 +0000 | [diff] [blame] | 11 | #include "SkBlitter.h" |
reed | cb67414 | 2015-06-05 06:58:22 -0700 | [diff] [blame] | 12 | #include "SkPixmap.h" |
commit-bot@chromium.org | a5572e5 | 2014-03-07 03:24:41 +0000 | [diff] [blame] | 13 | #include "SkShader.h" |
| 14 | #include "SkSmallAllocator.h" |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 15 | |
| 16 | class SkPaint; |
| 17 | |
herb | 7df9e4a | 2016-06-10 13:01:27 -0700 | [diff] [blame^] | 18 | // SkSpriteBlitter specializes SkBlitter in a way to move large rectangles of pixels around. |
| 19 | // Because of this use, the main primitive shifts from blitH style things to the more efficient |
| 20 | // blitRect. |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 21 | class SkSpriteBlitter : public SkBlitter { |
| 22 | public: |
reed | c240e71 | 2015-05-23 12:26:41 -0700 | [diff] [blame] | 23 | SkSpriteBlitter(const SkPixmap& source); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 24 | |
reed | cb67414 | 2015-06-05 06:58:22 -0700 | [diff] [blame] | 25 | virtual void setup(const SkPixmap& dst, int left, int top, const SkPaint&); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 26 | |
herb | 7df9e4a | 2016-06-10 13:01:27 -0700 | [diff] [blame^] | 27 | // blitH, blitAntiH, blitV and blitMask should not be called on an SkSpriteBlitter. |
reed | c240e71 | 2015-05-23 12:26:41 -0700 | [diff] [blame] | 28 | void blitH(int x, int y, int width) override; |
| 29 | void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override; |
| 30 | void blitV(int x, int y, int height, SkAlpha alpha) override; |
| 31 | void blitMask(const SkMask&, const SkIRect& clip) override; |
herb | 7df9e4a | 2016-06-10 13:01:27 -0700 | [diff] [blame^] | 32 | |
| 33 | // A SkSpriteBlitter must implement blitRect. |
| 34 | void blitRect(int x, int y, int width, int height) override = 0; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 35 | |
reed | c240e71 | 2015-05-23 12:26:41 -0700 | [diff] [blame] | 36 | static SkSpriteBlitter* ChooseD16(const SkPixmap& source, const SkPaint&, SkTBlitterAllocator*); |
brianosman | fe4b4f0 | 2016-02-26 09:19:02 -0800 | [diff] [blame] | 37 | static SkSpriteBlitter* ChooseL32(const SkPixmap& source, const SkPaint&, SkTBlitterAllocator*); |
| 38 | static SkSpriteBlitter* ChooseS32(const SkPixmap& source, const SkPaint&, SkTBlitterAllocator*); |
reed | 129ed1c | 2016-02-22 06:42:31 -0800 | [diff] [blame] | 39 | static SkSpriteBlitter* ChooseF16(const SkPixmap& source, const SkPaint&, SkTBlitterAllocator*); |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 40 | |
| 41 | protected: |
reed | cb67414 | 2015-06-05 06:58:22 -0700 | [diff] [blame] | 42 | SkPixmap fDst; |
reed | c240e71 | 2015-05-23 12:26:41 -0700 | [diff] [blame] | 43 | const SkPixmap fSource; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 44 | int fLeft, fTop; |
| 45 | const SkPaint* fPaint; |
herb | 7df9e4a | 2016-06-10 13:01:27 -0700 | [diff] [blame^] | 46 | |
| 47 | private: |
| 48 | typedef SkBlitter INHERITED; |
reed@android.com | 8a1c16f | 2008-12-17 15:59:43 +0000 | [diff] [blame] | 49 | }; |
| 50 | |
| 51 | #endif |