1/************************************************************************** 2 * 3 * Copyright 2007 VMware, Inc. 4 * All Rights Reserved. 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a 7 * copy of this software and associated documentation files (the 8 * "Software"), to deal in the Software without restriction, including 9 * without limitation the rights to use, copy, modify, merge, publish, 10 * distribute, sub license, and/or sell copies of the Software, and to 11 * permit persons to whom the Software is furnished to do so, subject to 12 * the following conditions: 13 * 14 * The above copyright notice and this permission notice (including the 15 * next paragraph) shall be included in all copies or substantial portions 16 * of the Software. 17 * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25 * 26 **************************************************************************/ 27 28#ifndef P_TILE_H 29#define P_TILE_H 30 31#include "pipe/p_compiler.h" 32#include "pipe/p_format.h" 33#include "pipe/p_state.h" 34 35struct pipe_context; 36struct pipe_transfer; 37 38/** 39 * Clip tile against transfer dims. 40 * 41 * XXX: this only clips width and height! 42 * 43 * \return TRUE if tile is totally clipped, FALSE otherwise 44 */ 45static inline boolean 46u_clip_tile(uint x, uint y, uint *w, uint *h, const struct pipe_box *box) 47{ 48 if ((int) x >= box->width) 49 return TRUE; 50 if ((int) y >= box->height) 51 return TRUE; 52 if ((int) (x + *w) > box->width) 53 *w = box->width - x; 54 if ((int) (y + *h) > box->height) 55 *h = box->height - y; 56 return FALSE; 57} 58 59#ifdef __cplusplus 60extern "C" { 61#endif 62 63void 64pipe_get_tile_raw(struct pipe_transfer *pt, 65 const void *src, 66 uint x, uint y, uint w, uint h, 67 void *p, int dst_stride); 68 69void 70pipe_put_tile_raw(struct pipe_transfer *pt, 71 void *dst, 72 uint x, uint y, uint w, uint h, 73 const void *p, int src_stride); 74 75 76void 77pipe_get_tile_rgba(struct pipe_transfer *pt, 78 const void *src, 79 uint x, uint y, uint w, uint h, 80 enum pipe_format format, 81 void *dst); 82 83void 84pipe_put_tile_rgba(struct pipe_transfer *pt, 85 void *dst, 86 uint x, uint y, uint w, uint h, 87 enum pipe_format format, 88 const void *src); 89 90#ifdef __cplusplus 91} 92#endif 93 94#endif 95