SkConvertPixels.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright 2011 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 SkConvertPixels_DEFINED
  8. #define SkConvertPixels_DEFINED
  9. #include "include/core/SkImageInfo.h"
  10. #include "include/private/SkTemplates.h"
  11. class SkColorTable;
  12. void SkConvertPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
  13. const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRowBytes);
  14. static inline void SkRectMemcpy(void* dst, size_t dstRB, const void* src, size_t srcRB,
  15. size_t trimRowBytes, int rowCount) {
  16. SkASSERT(trimRowBytes <= dstRB);
  17. SkASSERT(trimRowBytes <= srcRB);
  18. if (trimRowBytes == dstRB && trimRowBytes == srcRB) {
  19. memcpy(dst, src, trimRowBytes * rowCount);
  20. return;
  21. }
  22. for (int i = 0; i < rowCount; ++i) {
  23. memcpy(dst, src, trimRowBytes);
  24. dst = SkTAddOffset<void>(dst, dstRB);
  25. src = SkTAddOffset<const void>(src, srcRB);
  26. }
  27. }
  28. #endif