GL_CHECK(source_texture_location_ = evas_gl_api_->glGetUniformLocation (program_id_, "s_texture" ));
}
+bool RenderWidgetHostViewEfl::MakeCurrent() {
+ return evas_gl_make_current(evas_gl_, evas_gl_surface_, evas_gl_context_);
+}
+
#if defined(TIZEN_DISABLE_GPU_THREAD)
void RenderWidgetHostViewEfl::DoCompositeNow() {
evas_object_image_pixels_dirty_set(content_image_, true);
evas_render(evas_);
}
-bool RenderWidgetHostViewEfl::MakeCurrent() {
- return evas_gl_make_current(evas_gl_, evas_gl_surface_, evas_gl_context_);
-}
-
void RenderWidgetHostViewEfl::PaintToSurface() {
Evas_GL_API* gl_api = evasGlApi();
#include <iostream>
-//this constant is not defined in efl headers so we have to do it here
-#ifndef GL_BGRA
-#define GL_BGRA 0x80E1
-#endif
-
using namespace content;
using web_contents_utils::WebViewFromWebContents;
Evas_Object* EWebView::GetSnapshot(Eina_Rectangle rect) {
Evas_Object* image = NULL;
#ifdef OS_TIZEN
+ if (!rwhv() || !rwhv()->MakeCurrent())
+ return NULL;
+
int width = rect.w;
int height = rect.h;
Evas_GL_API* gl_api = rwhv()->evasGlApi();
DCHECK(gl_api);
- int size = width * height;
+ int size = width * height * sizeof(GLuint);
+
+ GLuint* tmp = (GLuint*)malloc(size);
+ if (!tmp)
+ return NULL;
- GLubyte tmp[size*4];
- GLubyte bits[size*4];
- gl_api->glReadPixels(x, y, width, height, GL_BGRA, GL_UNSIGNED_BYTE, bits);
+ GLuint* bits = (GLuint*)malloc(size);
+ if (!bits) {
+ free(tmp);
+ return NULL;
+ }
+
+ gl_api->glReadPixels(x, y, width, height, GL_RGBA, GL_UNSIGNED_BYTE, (GLubyte*)bits);
+
+ // flip the Y axis and change color format from RGBA to BGRA
+ int i, j, idx1, idx2;
+ GLuint d;
+ for (j = 0; j < height; j++) {
+ for (i = 0; i < width; i++) {
+ idx1 = (j * width) + i;
+ idx2 = ((height - 1) - j) * width + i;
+ d = bits[idx1];
+ tmp[idx2] = ((d & 0x000000ff) << 16) + ((d & 0x00ff0000) >> 16) + ((d & 0xff00ff00));
+ }
+ }
- //flip data after reading
- for (int i=0; i < height; i++)
- memcpy(&tmp[i*width*4], &bits[(height-i-1)*width*4], width*4*sizeof(unsigned char));
image = evas_object_image_filled_add(rwhv()->evas());
if (image) {
evas_object_image_size_set(image, width, height);