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 | |
Mike Klein | c0bd9f9 | 2019-04-23 12:05:21 -0500 | [diff] [blame] | 11 | #include "include/core/SkImageInfo.h" |
Hal Canary | 02eefbe | 2019-06-26 13:54:14 -0400 | [diff] [blame] | 12 | #include "include/core/SkPixmap.h" |
reed | 96472de | 2014-12-10 09:53:42 -0800 | [diff] [blame] | 13 | |
| 14 | /** |
| 15 | * Helper class to package and trim the parameters passed to readPixels() |
| 16 | */ |
| 17 | struct SkReadPixelsRec { |
| 18 | SkReadPixelsRec(const SkImageInfo& info, 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 | |
Mike Reed | 353196f | 2017-07-21 11:01:18 -0400 | [diff] [blame] | 26 | SkReadPixelsRec(const SkPixmap& pm, int x, int y) |
| 27 | : fPixels(pm.writable_addr()) |
| 28 | , fRowBytes(pm.rowBytes()) |
| 29 | , fInfo(pm.info()) |
| 30 | , fX(x) |
| 31 | , fY(y) |
| 32 | {} |
| 33 | |
reed | 96472de | 2014-12-10 09:53:42 -0800 | [diff] [blame] | 34 | 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 src width/height. |
| 43 | * |
| 44 | * On false, leaves self unchanged, but indicates that it does not overlap src, or |
| 45 | * is not valid (e.g. bad fInfo) for readPixels(). |
| 46 | */ |
| 47 | bool trim(int srcWidth, int srcHeight); |
| 48 | }; |
| 49 | |
| 50 | #endif |