José Fonseca | bfd7a9c | 2009-10-25 09:09:59 +0000 | [diff] [blame] | 1 | /************************************************************************** |
| 2 | * |
| 3 | * Copyright 2009 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 | /** |
| 29 | * @file |
| 30 | * Utility functions to make assertions about formats. |
| 31 | * |
| 32 | * This module centralizes most of logic used when determining what algorithm |
| 33 | * is most suitable (i.e., most efficient yet correct) for a given format. |
| 34 | * |
| 35 | * It might be possible to move some of these functions to u_format module, |
| 36 | * but since tiny differences in the format my render it more/less |
| 37 | * appropriate to a given algorithm it is impossible to make any long term |
| 38 | * guarantee about the semantics of these functions. |
| 39 | * |
| 40 | * @author Jose Fonseca <jfonseca@vmware.com> |
| 41 | */ |
| 42 | |
| 43 | |
| 44 | #include "util/u_format.h" |
| 45 | |
| 46 | #include "lp_bld_format.h" |
| 47 | |
| 48 | |
| 49 | /** |
| 50 | * Whether this format is a 4 rgba8 variant |
| 51 | */ |
| 52 | boolean |
| 53 | lp_format_is_rgba8(const struct util_format_description *desc) |
| 54 | { |
| 55 | unsigned chan; |
| 56 | |
| 57 | if(desc->block.width != 1 || |
| 58 | desc->block.height != 1 || |
| 59 | desc->block.bits != 32) |
| 60 | return FALSE; |
| 61 | |
| 62 | for(chan = 0; chan < 4; ++chan) { |
| 63 | if(desc->channel[chan].type != UTIL_FORMAT_TYPE_UNSIGNED && |
| 64 | desc->channel[chan].type != UTIL_FORMAT_TYPE_SIGNED && |
| 65 | desc->channel[chan].type != UTIL_FORMAT_TYPE_VOID) |
| 66 | return FALSE; |
| 67 | if(desc->channel[chan].size != 8) |
| 68 | return FALSE; |
| 69 | } |
| 70 | |
| 71 | return TRUE; |
| 72 | } |