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 16bool SK_WARN_UNUSED_RESULT SkConvertPixels( 17 const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes, 18 const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRowBytes); 19 20static inline void SkRectMemcpy(void* dst, size_t dstRB, const void* src, size_t srcRB, 21 size_t trimRowBytes, int rowCount) { 22 SkASSERT(trimRowBytes <= dstRB); 23 SkASSERT(trimRowBytes <= srcRB); 24 if (trimRowBytes == dstRB && trimRowBytes == srcRB) { 25 memcpy(dst, src, trimRowBytes * rowCount); 26 return; 27 } 28 29 for (int i = 0; i < rowCount; ++i) { 30 memcpy(dst, src, trimRowBytes); 31 dst = SkTAddOffset<void>(dst, dstRB); 32 src = SkTAddOffset<const void>(src, srcRB); 33 } 34} 35 36#endif 37