1cb93a386Sopenharmony_ci/*
2cb93a386Sopenharmony_ci * Copyright 2006 The Android Open Source Project
3cb93a386Sopenharmony_ci *
4cb93a386Sopenharmony_ci * Use of this source code is governed by a BSD-style license that can be
5cb93a386Sopenharmony_ci * found in the LICENSE file.
6cb93a386Sopenharmony_ci */
7cb93a386Sopenharmony_ci
8cb93a386Sopenharmony_ci#ifndef SkSpriteBlitter_DEFINED
9cb93a386Sopenharmony_ci#define SkSpriteBlitter_DEFINED
10cb93a386Sopenharmony_ci
11cb93a386Sopenharmony_ci#include "include/core/SkPixmap.h"
12cb93a386Sopenharmony_ci#include "include/core/SkShader.h"
13cb93a386Sopenharmony_ci#include "src/core/SkBlitter.h"
14cb93a386Sopenharmony_ci
15cb93a386Sopenharmony_ciclass SkPaint;
16cb93a386Sopenharmony_ci
17cb93a386Sopenharmony_ci// SkSpriteBlitter specializes SkBlitter in a way to move large rectangles of pixels around.
18cb93a386Sopenharmony_ci// Because of this use, the main primitive shifts from blitH style things to the more efficient
19cb93a386Sopenharmony_ci// blitRect.
20cb93a386Sopenharmony_ciclass SkSpriteBlitter : public SkBlitter {
21cb93a386Sopenharmony_cipublic:
22cb93a386Sopenharmony_ci    SkSpriteBlitter(const SkPixmap& source);
23cb93a386Sopenharmony_ci
24cb93a386Sopenharmony_ci    virtual bool setup(const SkPixmap& dst, int left, int top, const SkPaint&);
25cb93a386Sopenharmony_ci
26cb93a386Sopenharmony_ci    // blitH, blitAntiH, blitV and blitMask should not be called on an SkSpriteBlitter.
27cb93a386Sopenharmony_ci    void blitH(int x, int y, int width) override;
28cb93a386Sopenharmony_ci    void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override;
29cb93a386Sopenharmony_ci    void blitV(int x, int y, int height, SkAlpha alpha) override;
30cb93a386Sopenharmony_ci    void blitMask(const SkMask&, const SkIRect& clip) override;
31cb93a386Sopenharmony_ci
32cb93a386Sopenharmony_ci    // A SkSpriteBlitter must implement blitRect.
33cb93a386Sopenharmony_ci    void blitRect(int x, int y, int width, int height) override = 0;
34cb93a386Sopenharmony_ci
35cb93a386Sopenharmony_ci    static SkSpriteBlitter* ChooseL32(const SkPixmap& source, const SkPaint&, SkArenaAlloc*);
36cb93a386Sopenharmony_ci    static SkSpriteBlitter* ChooseL565(const SkPixmap& source, const SkPaint&, SkArenaAlloc*);
37cb93a386Sopenharmony_ci    static SkSpriteBlitter* ChooseLA8(const SkPixmap& source, const SkPaint&, SkArenaAlloc*);
38cb93a386Sopenharmony_ci
39cb93a386Sopenharmony_ciprotected:
40cb93a386Sopenharmony_ci    SkPixmap        fDst;
41cb93a386Sopenharmony_ci    const SkPixmap  fSource;
42cb93a386Sopenharmony_ci    int             fLeft, fTop;
43cb93a386Sopenharmony_ci    const SkPaint*  fPaint;
44cb93a386Sopenharmony_ci
45cb93a386Sopenharmony_ciprivate:
46cb93a386Sopenharmony_ci    using INHERITED = SkBlitter;
47cb93a386Sopenharmony_ci};
48cb93a386Sopenharmony_ci
49cb93a386Sopenharmony_ci#endif
50