From af73eb90f5387ab374df4a25bb07f96af76d0c80 Mon Sep 17 00:00:00 2001 From: hyzboy Date: Fri, 29 Nov 2019 19:36:38 +0800 Subject: [PATCH] init file --- CMakeLists.txt | 8 ++++ inc/hgl/2d/Bitmap.h | 13 ++++++ inc/hgl/2d/VSBase.h | 87 ++++++++++++++++++++++++++++++++++++++++ path_config.cmake | 9 +++++ src/CMakeLists.txt | 10 +++++ src/PixelFormat/rgb.cpp | 0 src/PixelFormat/rgba.cpp | 0 7 files changed, 127 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 inc/hgl/2d/Bitmap.h create mode 100644 inc/hgl/2d/VSBase.h create mode 100644 path_config.cmake create mode 100644 src/CMakeLists.txt create mode 100644 src/PixelFormat/rgb.cpp create mode 100644 src/PixelFormat/rgba.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..5fd62c0 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.0) + +project(CM2D) + +include(path_config.cmake) +CM2DSetup(${CMAKE_CURRENT_SOURCE_DIR}) + +add_subdirectory(${CM2D_ROOT_SOURCE_PATH}) \ No newline at end of file diff --git a/inc/hgl/2d/Bitmap.h b/inc/hgl/2d/Bitmap.h new file mode 100644 index 0000000..7161131 --- /dev/null +++ b/inc/hgl/2d/Bitmap.h @@ -0,0 +1,13 @@ +#ifndef HGL_2D_BITMAP_INCLUDE +#define HGL_2D_BITMAP_INCLUDE + +namespace hgl +{ + /** + * 简单的2D象素处理 + */ + template class Bitmap2D + { + };// +}//namespace hgl +#endif//HGL_2D_BITMAP_INCLUDE diff --git a/inc/hgl/2d/VSBase.h b/inc/hgl/2d/VSBase.h new file mode 100644 index 0000000..ee4b138 --- /dev/null +++ b/inc/hgl/2d/VSBase.h @@ -0,0 +1,87 @@ +#ifndef HGL_VSBASE_INCLUDE +#define HGL_VSBASE_INCLUDE + +namespace hgl +{ + namespace vs + { + /** + * 为方便程序处理,内存中仅支持以下格式 + */ + enum class DataFormat + { + U8,U16,U32, + S8,S16,S32, + F32,F64, + }; + + struct VSDataSource + { + void *pixel_data=nullptr; ///<象素数据 + + public: + + virtual ~VSDataSource()=0; + };//class VSDataSource + + struct VSDataSourceRef:public VSDataSource + { + public: + + ~VSDataSourceRef() override {} + };// + + class VSDataSourceCreate + + /** + * 虚拟屏幕数据源 + */ + class VSData + { + protected: + + uint width,height; ///<尺寸 + uint color_component; ///<颜色成份数量(1-4) + DataFormat data_format[4]; ///<数据格式 + + uint pixel_bytes; ///<每象素字节数 + uint line_bytes; ///<每一行象素数据的字节数 + + public: + + VSData() + { + pixel_data=nullptr; + } + + virtual ~VSData()=0; + + void *GetPointer(){return pixel_data;} + + void *GetPointer(uint row) + { + if(row>=height)return(nullptr); + + return ((uint8 *)pixel_data)+row*line_bytes; + } + + void *GetPointer(uint col,uint row) + { + if(col>=width)return(nullptr); + if(row>=height)return(nullptr); + + return ((uint8 *)pixel_data)+row*line_bytes+col*pixel_bytes; + } + };//class VSData + + /** + * 虚拟屏幕基类 + */ + class VSBase + { + };//class VSBase + + + }//namespace vs +}//namespace hgl +#endif//HGL_VSBASE_INCLUDE diff --git a/path_config.cmake b/path_config.cmake new file mode 100644 index 0000000..5fc436f --- /dev/null +++ b/path_config.cmake @@ -0,0 +1,9 @@ +macro(CM2DSetup CM2D_ROOT_PATH) + + message("CM2D_ROOT_PATH: " ${CM2D_ROOT_PATH}) + + set(CM2D_ROOT_INCLUDE_PATH ${CM2D_ROOT_PATH}/inc) + set(CM2D_ROOT_SOURCE_PATH ${CM2D_ROOT_PATH}/src) + + include_directories(${CM2D_ROOT_INCLUDE_PATH}) +endmacro() \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..417e03f --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,10 @@ +file(GLOB CM2D_HEADER ${CM2D_ROOT_INCLUDE_PATH}/hgl/2d/*.h) + +file(GLOB CM2D_PIXEL_SOURCE PixelFormat/*.cpp) +file(GLOB CM2D_BITMAP_SOURCE Bitmap/*.cpp) + +SOURCE_GROUP("Header Files" FILES ${CM2D_HEADER}) +SOURCE_GROUP("PixelFormat" FILES ${CM2D_PIXEL_SOURCE}) +SOURCE_GROUP("Bitmap" FILES ${CM2D_BITMAP_SOURCE}) + +add_cm_library(CM2D "CM" ${CM2D_HEADER} ${CM2D_PIXEL_SOURCE} ${CM2D_BITMAP_SOURCE}) diff --git a/src/PixelFormat/rgb.cpp b/src/PixelFormat/rgb.cpp new file mode 100644 index 0000000..e69de29 diff --git a/src/PixelFormat/rgba.cpp b/src/PixelFormat/rgba.cpp new file mode 100644 index 0000000..e69de29