SkSpriteBlitter.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #ifndef SkSpriteBlitter_DEFINED
  8. #define SkSpriteBlitter_DEFINED
  9. #include "include/core/SkPixmap.h"
  10. #include "include/core/SkShader.h"
  11. #include "src/core/SkBlitter.h"
  12. class SkPaint;
  13. // SkSpriteBlitter specializes SkBlitter in a way to move large rectangles of pixels around.
  14. // Because of this use, the main primitive shifts from blitH style things to the more efficient
  15. // blitRect.
  16. class SkSpriteBlitter : public SkBlitter {
  17. public:
  18. SkSpriteBlitter(const SkPixmap& source);
  19. virtual void setup(const SkPixmap& dst, int left, int top, const SkPaint&);
  20. // blitH, blitAntiH, blitV and blitMask should not be called on an SkSpriteBlitter.
  21. void blitH(int x, int y, int width) override;
  22. void blitAntiH(int x, int y, const SkAlpha antialias[], const int16_t runs[]) override;
  23. void blitV(int x, int y, int height, SkAlpha alpha) override;
  24. void blitMask(const SkMask&, const SkIRect& clip) override;
  25. // A SkSpriteBlitter must implement blitRect.
  26. void blitRect(int x, int y, int width, int height) override = 0;
  27. static SkSpriteBlitter* ChooseL32(const SkPixmap& source, const SkPaint&, SkArenaAlloc*);
  28. static SkSpriteBlitter* ChooseL565(const SkPixmap& source, const SkPaint&, SkArenaAlloc*);
  29. static SkSpriteBlitter* ChooseLA8(const SkPixmap& source, const SkPaint&, SkArenaAlloc*);
  30. protected:
  31. SkPixmap fDst;
  32. const SkPixmap fSource;
  33. int fLeft, fTop;
  34. const SkPaint* fPaint;
  35. private:
  36. typedef SkBlitter INHERITED;
  37. };
  38. #endif