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