Sync with the latest tizen 2.x 26/48226/1 accepted/tizen_mobile accepted/tizen_tv tizen accepted/tizen/mobile/20150917.041052 accepted/tizen/tv/20150917.041115 submit/tizen/20150916.141025 submit/tizen/20150917.014254 submit/tizen_common/20151229.142028 submit/tizen_common/20151229.144031 submit/tizen_common/20151229.154718 tizen_3.0.m2.a1_mobile_release tizen_3.0.m2.a1_tv_release
authorSung-jae Park <nicesj.park@samsung.com>
Wed, 16 Sep 2015 11:40:23 +0000 (20:40 +0900)
committerSung-jae Park <nicesj.park@samsung.com>
Wed, 16 Sep 2015 11:40:23 +0000 (20:40 +0900)
Change-Id: I066dca1e746b6de1d359ec93a2b51b6bf0b8c749

widget_provider/src/fb.c

index 14ba951..d299948 100644 (file)
@@ -424,7 +424,13 @@ static inline struct gem_data *create_gem(Pixmap pixmap, int w, int h, int depth
                return NULL;
        }
 
-       if (auto_align && gem->dri2_buffer->pitch != gem->w * gem->depth) {
+       /**
+        * @note
+        * If the "auto_align" is turned on, forcely allocate compensate buffer,
+        * Even if the (pitch == w * depth).
+        * "auto_align" will work like "enabling cache layer"
+        */
+       if (auto_align || gem->dri2_buffer->pitch != gem->w * gem->depth) {
                gem->compensate_data = calloc(1, gem->w * gem->h * gem->depth);
                if (!gem->compensate_data) {
                        ErrPrint("Failed to allocate heap\n");
@@ -435,10 +441,10 @@ static inline struct gem_data *create_gem(Pixmap pixmap, int w, int h, int depth
                }
        }
 
-       DbgPrint("dri2_buffer: %p, name: %p, %dx%d (%dx%d), pitch: %d, buf_count: %d, gem: %p\n",
+       DbgPrint("dri2_buffer: %p, name: %p, %dx%d (%dx%d), pitch: %d, buf_count: %d, gem: %p, comp: %p\n",
                        gem->dri2_buffer, gem->dri2_buffer->name,
                        gem->w, gem->h, w, h,
-                       gem->dri2_buffer->pitch, gem->buf_count, gem);
+                       gem->dri2_buffer->pitch, gem->buf_count, gem, gem->compensate_data);
        return gem;
 }
 
@@ -499,8 +505,6 @@ static inline void release_gem(struct gem_data *gem)
                 * it means, acquire_gem didn't grab a lock.
                 */
                if (gem->compensate_data && gem->data) {
-                       register int x;
-                       register int y;
                        int *gem_pixel;
                        int *pixel;
                        int gap;
@@ -514,12 +518,23 @@ static inline void release_gem(struct gem_data *gem)
                         * write before copy the pixels, we should grab a lock
                         */
                        tbm_bo_map(gem->pixmap_bo, TBM_DEVICE_CPU, TBM_OPTION_READ | TBM_OPTION_WRITE);
-                       for (y = 0; y < gem->h; y++) {
-                               for (x = 0; x < gem->w; x++) {
-                                       *gem_pixel++ = *pixel++;
-                               }
+                       if (gap == 0) {
+                               /**
+                                * @note
+                                * I believe that the "memcpy" is faster than my code...
+                                */
+                               memcpy(gem_pixel, pixel, gem->dri2_buffer->pitch * gem->h);
+                       } else {
+                               register int x;
+                               register int y;
 
-                               gem_pixel = (int *)(((char *)gem_pixel) + gap);
+                               for (y = 0; y < gem->h; y++) {
+                                       for (x = 0; x < gem->w; x++) {
+                                               *gem_pixel++ = *pixel++;
+                                       }
+
+                                       gem_pixel = (int *)(((char *)gem_pixel) + gap);
+                               }
                        }
                }
                tbm_bo_unmap(gem->pixmap_bo);