blob: 3a62860867901c4075a47e3e2d37104c254ae0da [file] [log] [blame]
epoger@google.comec3ed6a2011-07-28 14:26:00 +00001/*
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.com8a1c16f2008-12-17 15:59:43 +00008#ifndef SkSpriteBlitter_DEFINED
9#define SkSpriteBlitter_DEFINED
10
commit-bot@chromium.orga5572e52014-03-07 03:24:41 +000011#include "SkBlitter.h"
reedcb674142015-06-05 06:58:22 -070012#include "SkPixmap.h"
commit-bot@chromium.orga5572e52014-03-07 03:24:41 +000013#include "SkShader.h"
14#include "SkSmallAllocator.h"
reed@android.com8a1c16f2008-12-17 15:59:43 +000015
16class SkPaint;
17
herb7df9e4a2016-06-10 13:01:27 -070018// 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.com8a1c16f2008-12-17 15:59:43 +000021class SkSpriteBlitter : public SkBlitter {
22public:
reedc240e712015-05-23 12:26:41 -070023 SkSpriteBlitter(const SkPixmap& source);
reed@android.com8a1c16f2008-12-17 15:59:43 +000024
reedcb674142015-06-05 06:58:22 -070025 virtual void setup(const SkPixmap& dst, int left, int top, const SkPaint&);
reed@android.com8a1c16f2008-12-17 15:59:43 +000026
herb7df9e4a2016-06-10 13:01:27 -070027 // blitH, blitAntiH, blitV and blitMask should not be called on an SkSpriteBlitter.
reedc240e712015-05-23 12:26:41 -070028 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;
herb7df9e4a2016-06-10 13:01:27 -070032
33 // A SkSpriteBlitter must implement blitRect.
34 void blitRect(int x, int y, int width, int height) override = 0;
reed@android.com8a1c16f2008-12-17 15:59:43 +000035
reedc240e712015-05-23 12:26:41 -070036 static SkSpriteBlitter* ChooseD16(const SkPixmap& source, const SkPaint&, SkTBlitterAllocator*);
brianosmanfe4b4f02016-02-26 09:19:02 -080037 static SkSpriteBlitter* ChooseL32(const SkPixmap& source, const SkPaint&, SkTBlitterAllocator*);
38 static SkSpriteBlitter* ChooseS32(const SkPixmap& source, const SkPaint&, SkTBlitterAllocator*);
reed129ed1c2016-02-22 06:42:31 -080039 static SkSpriteBlitter* ChooseF16(const SkPixmap& source, const SkPaint&, SkTBlitterAllocator*);
reed@android.com8a1c16f2008-12-17 15:59:43 +000040
41protected:
reedcb674142015-06-05 06:58:22 -070042 SkPixmap fDst;
reedc240e712015-05-23 12:26:41 -070043 const SkPixmap fSource;
reed@android.com8a1c16f2008-12-17 15:59:43 +000044 int fLeft, fTop;
45 const SkPaint* fPaint;
herb7df9e4a2016-06-10 13:01:27 -070046
47private:
48 typedef SkBlitter INHERITED;
reed@android.com8a1c16f2008-12-17 15:59:43 +000049};
50
51#endif