Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/util/util_rect.h
| Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | |||||
| ccl_device_inline int coord_to_local_index(int4 rect, int x, int y) | ccl_device_inline int coord_to_local_index(int4 rect, int x, int y) | ||||
| { | { | ||||
| int w = rect.z - rect.x; | int w = rect.z - rect.x; | ||||
| return (y - rect.y) * w + (x - rect.x); | return (y - rect.y) * w + (x - rect.x); | ||||
| } | } | ||||
| /* Finds the coordinates of a pixel given by its row-major index in the rect, | /* Finds the coordinates of a pixel given by its row-major index in the rect, | ||||
| * and returns whether the pixel is inside it. */ | * and returns whether the pixel is inside it. */ | ||||
| ccl_device_inline bool local_index_to_coord(int4 rect, int idx, int *x, int *y) | ccl_device_inline bool local_index_to_coord(int4 rect, | ||||
| int idx, | |||||
| ccl_private int *x, | |||||
| ccl_private int *y) | |||||
| { | { | ||||
| int w = rect.z - rect.x; | int w = rect.z - rect.x; | ||||
| *x = (idx % w) + rect.x; | *x = (idx % w) + rect.x; | ||||
| *y = (idx / w) + rect.y; | *y = (idx / w) + rect.y; | ||||
| return (*y < rect.w); | return (*y < rect.w); | ||||
| } | } | ||||
| ccl_device_inline int rect_size(int4 rect) | ccl_device_inline int rect_size(int4 rect) | ||||
| { | { | ||||
| return (rect.z - rect.x) * (rect.w - rect.y); | return (rect.z - rect.x) * (rect.w - rect.y); | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||
| #endif /* __UTIL_RECT_H__ */ | #endif /* __UTIL_RECT_H__ */ | ||||