Home | History | Annotate | Download | only in core
      1 /*
      2  * Copyright 2017 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 SkWritePixelsRec_DEFINED
      9 #define SkWritePixelsRec_DEFINED
     10 
     11 #include "SkImageInfo.h"
     12 
     13 /**
     14  *  Helper class to package and trim the parameters passed to writePixels()
     15  */
     16 struct SkWritePixelsRec {
     17     SkWritePixelsRec(const SkImageInfo& info, const void* pixels, size_t rowBytes, int x, int y)
     18         : fPixels(pixels)
     19         , fRowBytes(rowBytes)
     20         , fInfo(info)
     21         , fX(x)
     22         , fY(y)
     23     {}
     24 
     25     const void* fPixels;
     26     size_t      fRowBytes;
     27     SkImageInfo fInfo;
     28     int         fX;
     29     int         fY;
     30 
     31     /*
     32      *  On true, may have modified its fields (except fRowBytes) to make it a legal subset
     33      *  of the specified dst width/height.
     34      *
     35      *  On false, leaves self unchanged, but indicates that it does not overlap dst, or
     36      *  is not valid (e.g. bad fInfo) for writePixels().
     37      */
     38     bool trim(int dstWidth, int dstHeight);
     39 };
     40 
     41 #endif
     42