blob: 6626ef26fcd6d9dee0815b7b2b6477901b1e81b3 [file] [log] [blame]
reed96472de2014-12-10 09:53:42 -08001/*
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 "SkImageInfo.h"
12
13/**
14 * Helper class to package and trim the parameters passed to readPixels()
15 */
16struct SkReadPixelsRec {
17 SkReadPixelsRec(const SkImageInfo& info, 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
Mike Reed353196f2017-07-21 11:01:18 -040025 SkReadPixelsRec(const SkPixmap& pm, int x, int y)
26 : fPixels(pm.writable_addr())
27 , fRowBytes(pm.rowBytes())
28 , fInfo(pm.info())
29 , fX(x)
30 , fY(y)
31 {}
32
reed96472de2014-12-10 09:53:42 -080033 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 src width/height.
42 *
43 * On false, leaves self unchanged, but indicates that it does not overlap src, or
44 * is not valid (e.g. bad fInfo) for readPixels().
45 */
46 bool trim(int srcWidth, int srcHeight);
47};
48
49#endif