SkWritePixelsRec.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 SkWritePixelsRec_DEFINED
  8. #define SkWritePixelsRec_DEFINED
  9. #include "include/core/SkImageInfo.h"
  10. #include "include/core/SkPixmap.h"
  11. /**
  12. * Helper class to package and trim the parameters passed to writePixels()
  13. */
  14. struct SkWritePixelsRec {
  15. SkWritePixelsRec(const SkImageInfo& info, const void* pixels, size_t rowBytes, int x, int y)
  16. : fPixels(pixels)
  17. , fRowBytes(rowBytes)
  18. , fInfo(info)
  19. , fX(x)
  20. , fY(y)
  21. {}
  22. SkWritePixelsRec(const SkPixmap& pm, int x, int y)
  23. : fPixels(pm.addr())
  24. , fRowBytes(pm.rowBytes())
  25. , fInfo(pm.info())
  26. , fX(x)
  27. , fY(y)
  28. {}
  29. const void* fPixels;
  30. size_t fRowBytes;
  31. SkImageInfo fInfo;
  32. int fX;
  33. int fY;
  34. /*
  35. * On true, may have modified its fields (except fRowBytes) to make it a legal subset
  36. * of the specified dst width/height.
  37. *
  38. * On false, leaves self unchanged, but indicates that it does not overlap dst, or
  39. * is not valid (e.g. bad fInfo) for writePixels().
  40. */
  41. bool trim(int dstWidth, int dstHeight);
  42. };
  43. #endif