From ae115b13f0f1256a3edf82af76b4d8025290435e Mon Sep 17 00:00:00 2001 From: Thilo Graf Date: Thu, 15 Jun 2017 01:01:55 +0200 Subject: [PATCH] CCDraw: rework getScreen(), getScreenData(), add pixbuf checks Origin commit data ------------------ Commit: https://github.com/neutrino-images/ni-neutrino/commit/5fda283a616fc90a2232cb4502350fc423109480 Author: Thilo Graf Date: 2017-06-15 (Thu, 15 Jun 2017) --- src/gui/components/cc_draw.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gui/components/cc_draw.cpp b/src/gui/components/cc_draw.cpp index 078edf940..c28144444 100644 --- a/src/gui/components/cc_draw.cpp +++ b/src/gui/components/cc_draw.cpp @@ -440,11 +440,13 @@ bool CCDraw::CheckFbData(const cc_fbdata_t& fbdata, const char* func, const int //screen area save fb_pixel_t* CCDraw::getScreen(int ax, int ay, int dx, int dy) { + fb_pixel_t* pixbuf = NULL; + if (dx < 1 || dy < 1 || dx * dy == 0) return NULL; + else + pixbuf = new fb_pixel_t[dx * dy]; - dprintf(DEBUG_INFO, "[CCDraw] INFO! [%s - %d], ax = %d, ay = %d, dx = %d, dy = %d\n", __func__, __LINE__, ax, ay, dx, dy); - fb_pixel_t* pixbuf = new fb_pixel_t[dx * dy]; frameBuffer->waitForIdle("CCDraw::getScreen()"); frameBuffer->SaveScreen(ax, ay, dx, dy, pixbuf); return pixbuf; @@ -453,8 +455,14 @@ fb_pixel_t* CCDraw::getScreen(int ax, int ay, int dx, int dy) cc_screen_data_t CCDraw::getScreenData(const int& ax, const int& ay, const int& dx, const int& dy) { cc_screen_data_t res; + res.x = res.y = res.dx = res.dy = 0; res.pixbuf = getScreen(ax, ay, dx, dy); - res.x = ax; res.y = ay; res.dx = dx; res.dy = dy; + + if (res.pixbuf){ + res.x = ax; res.y = ay; res.dx = dx; res.dy = dy; + } + else + dprintf(DEBUG_NORMAL, "\033[33m[CCDraw]\[%s - %d], Warning: initialize of screen buffer failed!\033[0m\n", __func__, __LINE__); return res; }