diff options
author | Topi Pohjolainen <[email protected]> | 2012-12-28 12:22:54 +0200 |
---|---|---|
committer | Topi Pohjolainen <[email protected]> | 2013-08-02 08:56:03 +0300 |
commit | 904587ac3aae82c2c9c2aba94280021703cb88bd (patch) | |
tree | c95961d338699ab9e501a0288e3ef331f4665a4a /src/mesa | |
parent | 55162e21640380bab6cb537ca6b937870be0fc9a (diff) |
intel: refactor planar format lookup
v2 (Eric): refactor both occurences, not just one
v3 (Chad): replace 0 by NULL
Signed-off-by: Topi Pohjolainen <[email protected]>
Reviewed-by: Chad Versace <[email protected]>
Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/i965/intel_screen.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index ce7a51e5512..0738cf62f8f 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -231,6 +231,21 @@ static struct intel_image_format intel_image_formats[] = { { 0, 1, 0, __DRI_IMAGE_FORMAT_ARGB8888, 4 } } } }; +static struct intel_image_format * +intel_image_format_lookup(int fourcc) +{ + struct intel_image_format *f = NULL; + + for (unsigned i = 0; i < ARRAY_SIZE(intel_image_formats); i++) { + if (intel_image_formats[i].fourcc == fourcc) { + f = &intel_image_formats[i]; + break; + } + } + + return f; +} + static __DRIimage * intel_allocate_image(int dri_format, void *loaderPrivate) { @@ -601,12 +616,7 @@ intel_create_image_from_names(__DRIscreen *screen, if (screen == NULL || names == NULL || num_names != 1) return NULL; - for (i = 0; i < ARRAY_SIZE(intel_image_formats); i++) { - if (intel_image_formats[i].fourcc == fourcc) { - f = &intel_image_formats[i]; - } - } - + f = intel_image_format_lookup(fourcc); if (f == NULL) return NULL; @@ -635,19 +645,14 @@ intel_create_image_from_fds(__DRIscreen *screen, void *loaderPrivate) { struct intel_screen *intelScreen = screen->driverPrivate; - struct intel_image_format *f = NULL; + struct intel_image_format *f; __DRIimage *image; int i, index; if (fds == NULL || num_fds != 1) return NULL; - for (i = 0; i < ARRAY_SIZE(intel_image_formats); i++) { - if (intel_image_formats[i].fourcc == fourcc) { - f = &intel_image_formats[i]; - } - } - + f = intel_image_format_lookup(fourcc); if (f == NULL) return NULL; |