SkEncoder.h 969 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright 2017 Google Inc.
  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 SkEncoder_DEFINED
  8. #define SkEncoder_DEFINED
  9. #include "include/core/SkPixmap.h"
  10. #include "include/private/SkNoncopyable.h"
  11. #include "include/private/SkTemplates.h"
  12. class SK_API SkEncoder : SkNoncopyable {
  13. public:
  14. /**
  15. * Encode |numRows| rows of input. If the caller requests more rows than are remaining
  16. * in the src, this will encode all of the remaining rows. |numRows| must be greater
  17. * than zero.
  18. */
  19. bool encodeRows(int numRows);
  20. virtual ~SkEncoder() {}
  21. protected:
  22. virtual bool onEncodeRows(int numRows) = 0;
  23. SkEncoder(const SkPixmap& src, size_t storageBytes)
  24. : fSrc(src)
  25. , fCurrRow(0)
  26. , fStorage(storageBytes)
  27. {}
  28. const SkPixmap& fSrc;
  29. int fCurrRow;
  30. SkAutoTMalloc<uint8_t> fStorage;
  31. };
  32. #endif