• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 {
SkWritePixelsRecSkWritePixelsRec17     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 
SkWritePixelsRecSkWritePixelsRec25     SkWritePixelsRec(const SkPixmap& pm, int x, int y)
26         : fPixels(pm.addr())
27         , fRowBytes(pm.rowBytes())
28         , fInfo(pm.info())
29         , fX(x)
30         , fY(y)
31     {}
32 
33     const void* fPixels;
34     size_t      fRowBytes;
35     SkImageInfo fInfo;
36     int         fX;
37     int         fY;
38 
39     /*
40      *  On true, may have modified its fields (except fRowBytes) to make it a legal subset
41      *  of the specified dst width/height.
42      *
43      *  On false, leaves self unchanged, but indicates that it does not overlap dst, or
44      *  is not valid (e.g. bad fInfo) for writePixels().
45      */
46     bool trim(int dstWidth, int dstHeight);
47 };
48 
49 #endif
50