| 1 |
/* |
| 2 |
* Copyright 2023 Google LLC |
| 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 |
|
| 8 |
#ifndef SkRectMemcpy_DEFINED |
| 9 |
#define SkRectMemcpy_DEFINED |
| 10 |
|
| 11 |
#include "include/private/base/SkAssert.h" |
| 12 |
#include "include/private/base/SkTemplates.h" |
| 13 |
|
| 14 |
#include <cstring> |
| 15 |
|
| 16 |
static inline void SkRectMemcpy(void* dst, size_t dstRB, const void* src, size_t srcRB, |
| 17 |
size_t trimRowBytes, int rowCount) { |
| 18 |
SkASSERT(trimRowBytes <= dstRB); |
| 19 |
SkASSERT(trimRowBytes <= srcRB); |
| 20 |
if (trimRowBytes == dstRB && trimRowBytes == srcRB) { |
| 21 |
memcpy(dst, src, trimRowBytes * rowCount); |
| 22 |
return; |
| 23 |
} |
| 24 |
|
| 25 |
for (int i = 0; i < rowCount; ++i) { |
| 26 |
memcpy(dst, src, trimRowBytes); |
| 27 |
dst = SkTAddOffset<void>(dst, dstRB); |
| 28 |
src = SkTAddOffset<const void>(src, srcRB); |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
#endif |