[DEV] try correct image compositing
This commit is contained in:
parent
d2ce3d279c
commit
50f0f350ed
@ -323,8 +323,7 @@ void ewol::compositing::Image::setSource(egami::Image _image) {
|
||||
m_filename = "direct image BUFFER";
|
||||
m_requestSize = _image.getSize();
|
||||
m_resourceImage = ewol::resource::Texture::create();
|
||||
m_resourceImage->get() = _image;
|
||||
m_resourceImage->flush();
|
||||
m_resourceImage->set(etk::move(_image));
|
||||
}
|
||||
|
||||
bool ewol::compositing::Image::hasSources() {
|
||||
@ -335,7 +334,8 @@ bool ewol::compositing::Image::hasSources() {
|
||||
|
||||
vec2 ewol::compositing::Image::getRealSize() {
|
||||
if ( m_resource == nullptr
|
||||
&& m_resourceDF == nullptr) {
|
||||
&& m_resourceDF == nullptr
|
||||
&& m_resourceImage == nullptr) {
|
||||
return vec2(0,0);
|
||||
}
|
||||
if (m_resource != nullptr) {
|
||||
@ -344,6 +344,9 @@ vec2 ewol::compositing::Image::getRealSize() {
|
||||
if (m_resourceDF != nullptr) {
|
||||
return m_resourceDF->getRealSize();
|
||||
}
|
||||
if (m_resourceImage != nullptr) {
|
||||
return m_resourceImage->getUsableSize();
|
||||
}
|
||||
return vec2(0,0);
|
||||
}
|
||||
|
||||
|
@ -400,7 +400,7 @@ namespace ewol {
|
||||
vec3 calculateSize(const etk::UString& _text);
|
||||
/**
|
||||
* @brief calculate a theoric charcode size
|
||||
* @param[in] _charcode The µUnicode value to calculate dimention.
|
||||
* @param[in] _charcode The Unicode value to calculate dimention.
|
||||
* @return The theoric size used.
|
||||
*/
|
||||
inline vec3 calculateSize(const char32_t& _charcode) {
|
||||
|
@ -49,24 +49,13 @@ void ewol::resource::TextureFile::init(etk::String _genName, const etk::String&
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
ewol::resource::Texture::init(_genName);
|
||||
EWOL_DEBUG("create a new resource::Image : _genName=" << _genName << " _tmpFilename=" << _tmpFilename << " size=" << _size);
|
||||
m_data = egami::load(_tmpFilename, _size);
|
||||
if (m_data.exist() == false) {
|
||||
EWOL_ERROR("ERROR when loading the image : " << _tmpFilename);
|
||||
}
|
||||
//egami::store(m_data, "tmpResult.bmp");
|
||||
ivec2 tmp = m_data.getSize();
|
||||
m_realImageSize = vec2(tmp.x(), tmp.y());
|
||||
vec2 compatibilityHWSize = vec2(nextP2(tmp.x()), nextP2(tmp.y()));
|
||||
if (m_realImageSize != compatibilityHWSize) {
|
||||
EWOL_DEBUG("RESIZE Image for HArwareCompatibility:" << m_realImageSize << " => " << compatibilityHWSize);
|
||||
m_data.resize(ivec2(compatibilityHWSize.x(),compatibilityHWSize.y()));
|
||||
}
|
||||
egami::Image tmp = egami::load(_tmpFilename, _size);
|
||||
set(etk::move(tmp));
|
||||
//m_lastSize = m_realImageSize;
|
||||
#ifdef GENERATE_DISTANCE_FIELD_MODE
|
||||
//egami::generateDistanceFieldFile(_tmpFilename, etk::String(_tmpFilename, 0, _tmpFilename.size()-4) + ".bmp");
|
||||
egami::generateDistanceFieldFile(_tmpFilename, etk::String(_tmpFilename, 0, _tmpFilename.size()-4) + ".edf");
|
||||
#endif
|
||||
flush();
|
||||
}
|
||||
|
||||
ememory::SharedPtr<ewol::resource::TextureFile> ewol::resource::TextureFile::create(const etk::String& _filename, ivec2 _size, ivec2 _sizeRegister) {
|
||||
|
@ -297,3 +297,22 @@ void ewol::resource::Texture::setImageSize(ivec2 _newSize) {
|
||||
_newSize.setValue( nextP2(_newSize.x()), nextP2(_newSize.y()) );
|
||||
m_data.resize(_newSize);
|
||||
}
|
||||
|
||||
void ewol::resource::Texture::set(egami::Image _image) {
|
||||
EWOL_WARNING("Set a new image in a texture:");
|
||||
ethread::RecursiveLock lock(m_mutex);
|
||||
if (_image.exist() == false) {
|
||||
EWOL_ERROR("ERROR when loading the image : [raw data]");
|
||||
return;
|
||||
}
|
||||
EWOL_WARNING(" size=" << _image.getSize());
|
||||
etk::swap(m_data, _image);
|
||||
ivec2 tmp = m_data.getSize();
|
||||
m_realImageSize = vec2(tmp.x(), tmp.y());
|
||||
vec2 compatibilityHWSize = vec2(nextP2(tmp.x()), nextP2(tmp.y()));
|
||||
if (m_realImageSize != compatibilityHWSize) {
|
||||
EWOL_ERROR("RESIZE Image for HArwareCompatibility:" << m_realImageSize << " => " << compatibilityHWSize);
|
||||
m_data.resize(ivec2(compatibilityHWSize.x(),compatibilityHWSize.y()));
|
||||
}
|
||||
flush();
|
||||
}
|
||||
|
@ -59,13 +59,19 @@ namespace ewol {
|
||||
DECLARE_RESOURCE_FACTORY(Texture);
|
||||
virtual ~Texture();
|
||||
public:
|
||||
// you must set the size here, because it will be set in multiple of pow(2)
|
||||
// You must set the size here, because it will be set in multiple of pow(2)
|
||||
void setImageSize(ivec2 _newSize);
|
||||
// get the reference on this image to draw nomething on it ...
|
||||
// Get the reference on this image to draw nomething on it ...
|
||||
inline egami::Image& get() {
|
||||
return m_data;
|
||||
};
|
||||
// flush the data to send it at the openGl system
|
||||
/**
|
||||
* @brief Set the image in the texture system
|
||||
* @note It will reize in square2 if needed by the system.
|
||||
* @param[in] _image Image to set. (use @code set(etk::move(xxx)); @endcode )
|
||||
*/
|
||||
void set(egami::Image _image);
|
||||
// Flush the data to send it at the openGl system
|
||||
void flush();
|
||||
bool updateContext();
|
||||
void removeContext();
|
||||
|
@ -50,6 +50,13 @@ void ewol::widget::Image::set(const etk::String& _file, const gale::Dimension& _
|
||||
propertySource.set(_file);
|
||||
}
|
||||
|
||||
void ewol::widget::Image::setCustumSource(const egami::Image& _image) {
|
||||
// TODO : Better interfacing of all element internal ==> this is a temporary prototype
|
||||
m_compositing.setSource(_image);
|
||||
markToRedraw();
|
||||
requestUpdateSize();
|
||||
}
|
||||
|
||||
void ewol::widget::Image::onDraw() {
|
||||
m_compositing.draw();
|
||||
}
|
||||
@ -60,12 +67,11 @@ void ewol::widget::Image::onRegenerateDisplay() {
|
||||
}
|
||||
// remove data of the previous composition :
|
||||
m_compositing.clear();
|
||||
if (*propertyUseThemeColor == true) {
|
||||
if (m_colorProperty != nullptr) {
|
||||
m_compositing.setColor(m_colorProperty->get(m_colorId));
|
||||
}
|
||||
if ( *propertyUseThemeColor == true
|
||||
&& m_colorProperty != nullptr) {
|
||||
m_compositing.setColor(m_colorProperty->get(m_colorId));
|
||||
}
|
||||
// calculate the new position and size :
|
||||
// Calculate the new position and size:
|
||||
vec2 imageBoder = propertyBorder->getPixel();
|
||||
vec2 origin = imageBoder;
|
||||
imageBoder *= 2.0f;
|
||||
@ -118,28 +124,29 @@ void ewol::widget::Image::onRegenerateDisplay() {
|
||||
}
|
||||
|
||||
void ewol::widget::Image::calculateMinMaxSize() {
|
||||
EWOL_VERBOSE("calculate min size: border=" << propertyBorder << " size=" << propertyImageSize << " min-size=" << propertyMinSize);
|
||||
EWOL_WARNING("calculate min size: border=" << propertyBorder << " size=" << propertyImageSize << " min-size=" << propertyMinSize);
|
||||
vec2 imageBoder = propertyBorder->getPixel()*2.0f;
|
||||
vec2 imageSize = propertyImageSize->getPixel();
|
||||
vec2 size = propertyMinSize->getPixel();
|
||||
EWOL_VERBOSE(" ==> border=" << imageBoder << " size=" << imageSize << " min-size=" << size);
|
||||
EWOL_WARNING(" ==> border=" << imageBoder << " size=" << imageSize << " min-size=" << size);
|
||||
if (imageSize != vec2(0,0)) {
|
||||
m_minSize = imageBoder+imageSize;
|
||||
m_maxSize = m_minSize;
|
||||
} else {
|
||||
vec2 imageSizeReal = m_compositing.getRealSize();
|
||||
EWOL_WARNING(" Real Size = " << imageSizeReal);
|
||||
vec2 min1 = imageBoder+propertyMinSize->getPixel();
|
||||
m_minSize = imageBoder+imageSizeReal;
|
||||
//EWOL_DEBUG(" set max : " << m_minSize << " " << min1);
|
||||
EWOL_WARNING(" set max : " << m_minSize << " min1=" << min1);
|
||||
m_minSize.setMax(min1);
|
||||
//EWOL_DEBUG(" result : " << m_minSize);
|
||||
EWOL_WARNING(" result : " << m_minSize);
|
||||
m_maxSize = imageBoder+propertyMaxSize->getPixel();
|
||||
m_minSize.setMin(m_maxSize);
|
||||
}
|
||||
m_imageRenderSize = m_minSize;
|
||||
m_minSize.setMax(size);
|
||||
m_maxSize.setMax(m_minSize);
|
||||
//EWOL_ERROR("set widget min=" << m_minSize << " max=" << m_maxSize << " with real Image size=" << m_imageRenderSize << " img size=" << imageSize << " " << propertyImageSize);
|
||||
EWOL_ERROR("set widget min=" << m_minSize << " max=" << m_maxSize << " with real Image size=" << m_imageRenderSize << " img size=" << imageSize << " " << propertyImageSize);
|
||||
markToRedraw();
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,11 @@ namespace ewol {
|
||||
* @param[in] _border New border size to set
|
||||
*/
|
||||
void set(const etk::String& _file, const gale::Dimension& _border);
|
||||
/**
|
||||
* @brief Set an image with direct elements
|
||||
* @param[in] _image Image to set in the display
|
||||
*/
|
||||
void setCustumSource(const egami::Image& _image);
|
||||
protected:
|
||||
vec2 m_imageRenderSize; //!< size of the image when we render it
|
||||
protected:
|
||||
|
19
monk_ewol.py
Normal file
19
monk_ewol.py
Normal file
@ -0,0 +1,19 @@
|
||||
#!/usr/bin/python
|
||||
import monkModule
|
||||
import monkTools as tools
|
||||
import os
|
||||
|
||||
def get_desc():
|
||||
return "EWOL main library (Edn Widget on OpenGl Layer)"
|
||||
|
||||
def create():
|
||||
# module name is 'ewol' and type binary.
|
||||
myModule = monkModule.Module(__file__, 'ewol', 'LIBRARY')
|
||||
# enable doculentation :
|
||||
myModule.set_website("http://atria-soft.github.io/ewol/")
|
||||
myModule.set_website_sources("http://github.com/atria-soft/ewol/")
|
||||
myModule.set_path(os.path.join(tools.get_current_path(__file__), "ewol"))
|
||||
myModule.set_path_general_doc(os.path.join(tools.get_current_path(__file__), "doc"))
|
||||
|
||||
return myModule
|
||||
|
Loading…
x
Reference in New Issue
Block a user