From 8164adb15b76f537f8b6c78b9992786b61d61cc8 Mon Sep 17 00:00:00 2001 From: chai Date: Sat, 30 Mar 2019 21:49:29 +0800 Subject: *misc --- source/modules/asura-core/graphics/image_data.h | 45 +++++++++++++++++-------- 1 file changed, 31 insertions(+), 14 deletions(-) (limited to 'source/modules/asura-core/graphics/image_data.h') diff --git a/source/modules/asura-core/graphics/image_data.h b/source/modules/asura-core/graphics/image_data.h index ea1d53a..b9d656c 100644 --- a/source/modules/asura-core/graphics/image_data.h +++ b/source/modules/asura-core/graphics/image_data.h @@ -7,8 +7,9 @@ #include #include #include +#include -#include "pixel_format.h" +#include "texture.h" #include "color.h" namespace AsuraEngine @@ -29,27 +30,28 @@ namespace AsuraEngine /// /// 解析图片数据文件,并构建像素信息,如果解析失败,抛出异常 /// - ImageData(const AEIO::DataBuffer& buffer); + ImageData(); ~ImageData(); - void Load(const AEIO::DataBuffer& buffer); - void LoadAsync(const AEIO::DataBuffer& buffer, AEThreading::Thread* thread); + void Decode(AEIO::DataBuffer& buffer) override; + + void Lock(); + void Unlock(); Color GetPixel(uint x, uint y); - uint width, height; - PixelFormat format; - std::size_t size; - byte* pixels; + //----------------------------------------------------------------------------// - private: + uint width, height; // 像素尺寸 + ColorFormat format; // 格式 + byte* pixels; // 像素数据 + std::size_t size; // 数据长度 - void Decode(const AEIO::DataBuffer& buffer) override; + //----------------------------------------------------------------------------// - /// - /// 在第一次准备image data时构建所有提供的decoder。在几个decoders中间选择解析策略。 - /// - static std::list ImageDecoders; + private: + + //----------------------------------------------------------------------------// LUAX_DECL_METHOD(_New); LUAX_DECL_METHOD(_GetPixel); @@ -57,6 +59,21 @@ namespace AsuraEngine LUAX_DECL_METHOD(_GetWidth); LUAX_DECL_METHOD(_GetHeight); LUAX_DECL_METHOD(_GetPixelFormat); + LUAX_DECL_METHOD(_Decode); + LUAX_DECL_METHOD(_DecodeAsync); + LUAX_DECL_METHOD(_IsAvailable); + + //----------------------------------------------------------------------------// + + /// + /// 在第一次准备image data时构建所有提供的decoder。在几个decoders中间选择解析策略。 + /// + static std::list ImageDecoders; + + /// + /// 写数据的锁。 + /// + AEThreading::Mutex mMutex; }; -- cgit v1.1-26-g67d0