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