Debian Codegraph @

src/core/SkReadPixelsRec.h

raw
1 /*
2 * Copyright 2014 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 SkReadPixelsRec_DEFINED
9 #define SkReadPixelsRec_DEFINED
10
11 #include "include/core/SkImageInfo.h"
12 #include "include/core/SkPixmap.h"
13
14 #include <cstddef>
15
16 /**
17 * Helper class to package and trim the parameters passed to readPixels()
18 */
19 struct SkReadPixelsRec {
20 SkReadPixelsRec(const SkImageInfo& info, void* pixels, size_t rowBytes, int x, int y)
21 : fPixels(pixels)
22 , fRowBytes(rowBytes)
23 , fInfo(info)
24 , fX(x)
25 , fY(y)
26 {}
27
28 SkReadPixelsRec(const SkPixmap& pm, int x, int y)
29 : fPixels(pm.writable_addr())
30 , fRowBytes(pm.rowBytes())
31 , fInfo(pm.info())
32 , fX(x)
33 , fY(y)
34 {}
35
36 void* fPixels;
37 size_t fRowBytes;
38 SkImageInfo fInfo;
39 int fX;
40 int fY;
41
42 /*
43 * On true, may have modified its fields (except fRowBytes) to make it a legal subset
44 * of the specified src width/height.
45 *
46 * On false, leaves self unchanged, but indicates that it does not overlap src, or
47 * is not valid (e.g. bad fInfo) for readPixels().
48 */
49 bool trim(int srcWidth, int srcHeight);
50 };
51
52 #endif