reed | 96472de | 2014-12-10 09:53:42 -0800 | [diff] [blame] | 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 "SkImageInfo.h" |
| 12 | |
| 13 | /** |
| 14 | * Helper class to package and trim the parameters passed to readPixels() |
| 15 | */ |
| 16 | struct 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 | |
| 25 | 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 src width/height. |
| 34 | * |
| 35 | * On false, leaves self unchanged, but indicates that it does not overlap src, or |
| 36 | * is not valid (e.g. bad fInfo) for readPixels(). |
| 37 | */ |
| 38 | bool trim(int srcWidth, int srcHeight); |
| 39 | }; |
| 40 | |
| 41 | #endif |