From b54a7c449ebf973db8a3f457d014827df6d2001f Mon Sep 17 00:00:00 2001 From: Stefano Ceccherini Date: Sat, 28 May 2005 16:57:37 +0000 Subject: [PATCH] Stolen Ingo's code and implemented bitmaps_support_space(). Now BBitmap::InitObject() uses that one instead of the private method. I was obviously wrong about bitmaps_support_space() and get_pixel_size_for(). git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12868 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/Bitmap.cpp | 37 ++------------------------- src/kits/interface/GraphicsDefs.cpp | 39 +++++++++++++++++++++-------- 2 files changed, 31 insertions(+), 45 deletions(-) diff --git a/src/kits/interface/Bitmap.cpp b/src/kits/interface/Bitmap.cpp index a00d16471b..64e1757ff9 100644 --- a/src/kits/interface/Bitmap.cpp +++ b/src/kits/interface/Bitmap.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -118,40 +119,6 @@ const rgb_color kSystemPalette[] = { { 255, 255, 255, 255 } }; -// is_supported -/*! \brief Returns whether or not a color space is supported by BBitmap. - \param colorSpace The color space in question. - \return \c true, if \a colorSpace is supported, \c false otherwise. -*/ -static inline -bool -is_supported(color_space colorSpace) -{ - bool result = false; - switch (colorSpace) { - // supported - case B_RGB32: case B_RGBA32: case B_RGB24: - case B_RGB32_BIG: case B_RGBA32_BIG: case B_RGB24_BIG: - case B_RGB16: case B_RGB15: case B_RGBA15: - case B_RGB16_BIG: case B_RGB15_BIG: case B_RGBA15_BIG: - case B_CMAP8: case B_GRAY8: case B_GRAY1: - case B_YCbCr422: case B_YCbCr411: case B_YCbCr444: case B_YCbCr420: - case B_YUV422: case B_YUV411: case B_YUV444: case B_YUV420: - case B_UVL24: case B_UVL32: case B_UVLA32: - case B_LAB24: case B_LAB32: case B_LABA32: - case B_HSI24: case B_HSI32: case B_HSIA32: - case B_HSV24: case B_HSV32: case B_HSVA32: - case B_HLS24: case B_HLS32: case B_HLSA32: - case B_CMY24: case B_CMY32: case B_CMYA32: case B_CMYK32: - result = true; - break; - // unsupported - case B_NO_COLOR_SPACE: - case B_YUV9: case B_YUV12: - break; - } - return result; -} // get_raw_bytes_per_row /*! \brief Returns the number of bytes per row needed to store the actual @@ -2222,7 +2189,7 @@ BBitmap::InitObject(BRect bounds, color_space colorSpace, uint32 flags, CleanUp(); // check params - if (!bounds.IsValid() || !is_supported(colorSpace)) + if (!bounds.IsValid() || !bitmaps_support_space(colorSpace, NULL)) error = B_BAD_VALUE; if (error == B_OK) { int32 bpr = get_bytes_per_row(colorSpace, bounds.IntegerWidth() + 1); diff --git a/src/kits/interface/GraphicsDefs.cpp b/src/kits/interface/GraphicsDefs.cpp index 7278e3fa05..97b1ee8027 100644 --- a/src/kits/interface/GraphicsDefs.cpp +++ b/src/kits/interface/GraphicsDefs.cpp @@ -48,14 +48,8 @@ const uint32 B_TRANSPARENT_MAGIC_RGBA32_BIG = 0x77747700; // misc. const struct screen_id B_MAIN_SCREEN_ID = {0}; -// GraphicsDefs.h -// Note: one would think that these functions need to query the app server to retrieve -// the needed values, since this kind of stuff is kept server side. Well, a quick -// examination of the asm dump showed that it's not the case, at least on BeOS R5. -// libbe probably keeps some global struct which is updated when the resolution changes. - -_IMPEXP_BE status_t +status_t get_pixel_size_for(color_space space, size_t *pixelChunk, size_t *rowAlignment, size_t *pixelsPerChunk) { // TODO: Implement @@ -63,9 +57,34 @@ get_pixel_size_for(color_space space, size_t *pixelChunk, size_t *rowAlignment, } -_IMPEXP_BE bool +bool bitmaps_support_space(color_space space, uint32 *supportFlags) { - // TODO: Implement - return false; + // TODO: fill supportFlags with the supported flags: + // - B_VIEWS_SUPPORT_DRAW_BITMAP + // - B_BITMAPS_SUPPORT_ATTACHED_VIEWS + bool result = false; + switch (space) { + // supported + case B_RGB32: case B_RGBA32: case B_RGB24: + case B_RGB32_BIG: case B_RGBA32_BIG: case B_RGB24_BIG: + case B_RGB16: case B_RGB15: case B_RGBA15: + case B_RGB16_BIG: case B_RGB15_BIG: case B_RGBA15_BIG: + case B_CMAP8: case B_GRAY8: case B_GRAY1: + case B_YCbCr422: case B_YCbCr411: case B_YCbCr444: case B_YCbCr420: + case B_YUV422: case B_YUV411: case B_YUV444: case B_YUV420: + case B_UVL24: case B_UVL32: case B_UVLA32: + case B_LAB24: case B_LAB32: case B_LABA32: + case B_HSI24: case B_HSI32: case B_HSIA32: + case B_HSV24: case B_HSV32: case B_HSVA32: + case B_HLS24: case B_HLS32: case B_HLSA32: + case B_CMY24: case B_CMY32: case B_CMYA32: case B_CMYK32: + result = true; + break; + // unsupported + case B_NO_COLOR_SPACE: + case B_YUV9: case B_YUV12: + break; + } + return result; }