cc_draw.cpp: remove variable cc_fbdata_t& fbdata

Try to avoid som possible data races.
This commit is contained in:
2018-12-07 21:41:19 +01:00
parent 94284c2e5b
commit 420fba0e1b

View File

@@ -532,16 +532,14 @@ void CCDraw::paintFbItems(bool do_save_bg)
}
for(size_t i=0; i< v_fbdata.size(); i++){
cc_fbdata_t& fbdata = v_fbdata[i];
int fbtype = fbdata.fbdata_type;
int fbtype = v_fbdata[i].fbdata_type;
//ignore bg screen layer
if (fbtype == CC_FBDATA_TYPE_BGSCREEN)
continue;
// Don't paint on dimension or position error dx or dy are 0.
if (!CheckFbData(fbdata, __func__, __LINE__))
if (!CheckFbData(v_fbdata[i], __func__, __LINE__))
continue;
/* Paint all fb relevant basic parts (shadow, frame and body)
@@ -549,8 +547,8 @@ void CCDraw::paintFbItems(bool do_save_bg)
*/
if (cc_enable_frame && cc_body_image.empty()){
if (fbtype == CC_FBDATA_TYPE_FRAME) {
if (fbdata.frame_thickness > 0 && cc_allow_paint){
frameBuffer->paintBoxFrame(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy, fbdata.frame_thickness, fbdata.color, fbdata.r, fbdata.rtype);
if (v_fbdata[i].frame_thickness > 0 && cc_allow_paint){
frameBuffer->paintBoxFrame(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].frame_thickness, v_fbdata[i].color, v_fbdata[i].r, v_fbdata[i].rtype);
v_fbdata[i].is_painted = true;
}
continue;
@@ -558,31 +556,31 @@ void CCDraw::paintFbItems(bool do_save_bg)
}
if (paint_bg){
if (fbtype == CC_FBDATA_TYPE_BACKGROUND){
frameBuffer->paintBackgroundBoxRel(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy);
frameBuffer->paintBackgroundBoxRel(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy);
v_fbdata[i].is_painted = true;
if (CCDraw_debug)
frameBuffer->paintBoxFrame(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy, 1, COL_RED);
frameBuffer->paintBoxFrame(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, 1, COL_RED);
continue;
}
}
if (fbtype == CC_FBDATA_TYPE_SHADOW_BOX && ((!is_painted || !fbdata.is_painted)|| shadow_force || force_paint_bg)) {
if (fbdata.enabled) {
if (fbtype == CC_FBDATA_TYPE_SHADOW_BOX && ((!is_painted || !v_fbdata[i].is_painted)|| shadow_force || force_paint_bg)) {
if (v_fbdata[i].enabled) {
/* Here we paint the shadow around the body.
* On 1st step we check for already cached screen buffer, if true
* then restore this instead to call the paint methode.
* This could be usally, if we use an existant instances of "this" object
*/
if (cc_allow_paint){
if (fbdata.pixbuf){
if (v_fbdata[i].pixbuf){
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], paint shadow from cache...\033[0m\n", __func__, __LINE__);
frameBuffer->RestoreScreen(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy, fbdata.pixbuf);
frameBuffer->RestoreScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].pixbuf);
}else{
frameBuffer->paintBoxRel(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy, fbdata.color, fbdata.r, fbdata.rtype);
frameBuffer->paintBoxRel(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].color, v_fbdata[i].r, v_fbdata[i].rtype);
}
//If is paint cache enabled, catch screen into cache
if (cc_paint_cache && fbdata.pixbuf == NULL)
fbdata.pixbuf = getScreen(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy);
fbdata.is_painted = true;
if (cc_paint_cache && v_fbdata[i].pixbuf == NULL)
v_fbdata[i].pixbuf = getScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy);
v_fbdata[i].is_painted = true;
}
continue;
}
@@ -595,15 +593,15 @@ void CCDraw::paintFbItems(bool do_save_bg)
* then restore this instead to call the paint methodes and gradient creation.
* Paint cache can be enable/disable with enablePaintCache()
*/
if (fbdata.pixbuf){
if (v_fbdata[i].pixbuf){
/* If is paint cache enabled and cache is filled, it's prefered to paint
* from cache. Cache is also filled if body background images are used
*/
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], paint body from cache...\033[0m\n", __func__, __LINE__);
frameBuffer->RestoreScreen(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy, fbdata.pixbuf);
frameBuffer->RestoreScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].pixbuf);
}else{
//Ensure clean gradient data on disabled gradient.
if(cc_body_gradient_enable == CC_COLGRAD_OFF && fbdata.gradient_data){
if(cc_body_gradient_enable == CC_COLGRAD_OFF && v_fbdata[i].gradient_data){
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], gradient mode is disabled but filled\033[0m\n", __func__, __LINE__);
clearFbGradientData();
}
@@ -613,20 +611,20 @@ void CCDraw::paintFbItems(bool do_save_bg)
* Paint of background image is prefered, next steps will be ignored!
*/
if (!cc_body_image.empty()){
if (g_PicViewer->DisplayImage(cc_body_image, fbdata.x, fbdata.y, fbdata.dx, fbdata.dy)){
if (g_PicViewer->DisplayImage(cc_body_image, v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy)){
// catch screen and store into paint cache
fbdata.pixbuf = getScreen(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy);
fbdata.is_painted = true;
v_fbdata[i].pixbuf = getScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy);
v_fbdata[i].is_painted = true;
}else{
if (fbdata.pixbuf){
delete[] fbdata.pixbuf;
fbdata.pixbuf = NULL;
if (v_fbdata[i].pixbuf){
delete[] v_fbdata[i].pixbuf;
v_fbdata[i].pixbuf = NULL;
}
fbdata.is_painted = false;
v_fbdata[i].is_painted = false;
}
// On failed image paint, write this into log and reset image name.
if (!fbdata.is_painted){
if (!v_fbdata[i].is_painted){
dprintf(DEBUG_NORMAL, "\033[33m\[CCDraw]\t[%s - %d], WARNING: bg image %s defined, but paint failed,\nfallback to default rendering...\033[0m\n", __func__, __LINE__, cc_body_image.c_str());
cc_body_image = "";
}
@@ -642,22 +640,22 @@ void CCDraw::paintFbItems(bool do_save_bg)
* instance and add it to the fbdata object
* On disabled color gradient or image paint was failed, we do paint only a default box
*/
if (fbdata.gradient_data == NULL){
if (v_fbdata[i].gradient_data == NULL){
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], create new gradient data)...\033[0m\n", __func__, __LINE__);
fbdata.gradient_data = getGradientData();
v_fbdata[i].gradient_data = getGradientData();
}
if (fbdata.gradient_data->boxBuf == NULL){
if (fbdata.pixbuf == NULL){
if (v_fbdata[i].gradient_data->boxBuf == NULL){
if (v_fbdata[i].pixbuf == NULL){
/* Before we paint any gradient box with hw acceleration, we must cleanup first.
* FIXME: This is only a workaround for this framebuffer behavior on enabled hw acceleration.
* Without this, ugly ghost letters or ghost images inside gradient boxes are possible.
*/
if (cc_gradient_bg_cleanup)
frameBuffer->paintBoxRel(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy, 0, fbdata.r, fbdata.rtype);
frameBuffer->paintBoxRel(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, 0, v_fbdata[i].r, v_fbdata[i].rtype);
// create gradient buffer and paint gradient box
fbdata.gradient_data->boxBuf = frameBuffer->paintBoxRel(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy, 0, fbdata.gradient_data, fbdata.r, fbdata.rtype);
v_fbdata[i].gradient_data->boxBuf = frameBuffer->paintBoxRel(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, 0, v_fbdata[i].gradient_data, v_fbdata[i].r, v_fbdata[i].rtype);
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], paint and cache new gradient into gradient cache...\033[0m\n", __func__, __LINE__);
}
@@ -666,16 +664,16 @@ void CCDraw::paintFbItems(bool do_save_bg)
*/
if (cc_paint_cache || cc_gradient_bg_cleanup){
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], cache new created gradient into external cache...\033[0m\n", __func__, __LINE__);
fbdata.pixbuf = getScreen(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy);
v_fbdata[i].pixbuf = getScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy);
if (clearFbGradientData())
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], remove unused gradient data...\033[0m\n", __func__, __LINE__);
}
}else{
// If found gradient buffer, paint box from gradient cache.
if (frameBuffer->checkFbArea(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy, true)){
if (frameBuffer->checkFbArea(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, true)){
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], paint cached gradient)...\033[0m\n", __func__, __LINE__);
frameBuffer->blitBox2FB(fbdata.gradient_data->boxBuf, fbdata.gradient_data->dx, fbdata.dy, fbdata.gradient_data->x, fbdata.y);
frameBuffer->checkFbArea(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy, false);
frameBuffer->blitBox2FB(v_fbdata[i].gradient_data->boxBuf, v_fbdata[i].gradient_data->dx, v_fbdata[i].dy, v_fbdata[i].gradient_data->x, v_fbdata[i].y);
frameBuffer->checkFbArea(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, false);
}
}
}else{
@@ -683,11 +681,11 @@ void CCDraw::paintFbItems(bool do_save_bg)
* render a default box.
*/
dprintf(DEBUG_INFO, "\033[33m[CCDraw]\t[%s - %d], paint default box)...\033[0m\n", __func__, __LINE__);
frameBuffer->paintBoxRel(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy, fbdata.color, fbdata.r, fbdata.rtype);
frameBuffer->paintBoxRel(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, v_fbdata[i].color, v_fbdata[i].r, v_fbdata[i].rtype);
//If is paint cache enabled, catch screen into cache.
if (cc_paint_cache)
fbdata.pixbuf = getScreen(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy);
v_fbdata[i].pixbuf = getScreen(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy);
}
}
}
@@ -697,7 +695,7 @@ void CCDraw::paintFbItems(bool do_save_bg)
}
}
if (CCDraw_debug)
frameBuffer->paintBoxFrame(fbdata.x, fbdata.y, fbdata.dx, fbdata.dy, 1, COL_RED);
frameBuffer->paintBoxFrame(v_fbdata[i].x, v_fbdata[i].y, v_fbdata[i].dx, v_fbdata[i].dy, 1, COL_RED);
}
//set is_painted attribut. if any layer was painted set it to true;