Home | History | Annotate | Download | only in core
      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 "SkImageInfo.h"
     12 #include "SkTemplates.h"
     13 
     14 class SkColorTable;
     15 
     16 void SkConvertPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
     17                      const SkImageInfo& srcInfo, const void* srcPixels, size_t srcRowBytes,
     18                      SkColorTable* srcCTable, SkTransferFunctionBehavior behavior);
     19 
     20 static inline void SkRectMemcpy(void* dst, size_t dstRB, const void* src, size_t srcRB,
     21                                 size_t bytesPerRow, int rowCount) {
     22     SkASSERT(bytesPerRow <= dstRB);
     23     SkASSERT(bytesPerRow <= srcRB);
     24     if (bytesPerRow == dstRB && bytesPerRow == srcRB) {
     25         memcpy(dst, src, bytesPerRow * rowCount);
     26         return;
     27     }
     28 
     29     for (int i = 0; i < rowCount; ++i) {
     30         memcpy(dst, src, bytesPerRow);
     31         dst = SkTAddOffset<void>(dst, dstRB);
     32         src = SkTAddOffset<const void>(src, srcRB);
     33     }
     34 }
     35 
     36 #endif
     37