Get Cairo GLES max surface size based on dynamic query. 09/10709/2
authorYan Wang <yan.wang@linux.intel.com>
Thu, 10 Oct 2013 04:42:25 +0000 (12:42 +0800)
committerGerrit Code Review <gerrit@review.vlan103.tizen.org>
Mon, 18 Nov 2013 19:48:59 +0000 (11:48 -0800)
Change-Id: I6b66c4710fc0f4650f5379bfd21b000798d35a00
Signed-off-by: Yan Wang <yan.wang@linux.intel.com>
Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp

index bff8c29..c5b5676 100644 (file)
@@ -37,8 +37,8 @@
 #if ENABLE(TIZEN_CAIROGLES_IMAGE_CACHE) || ENABLE(TIZEN_USE_XPIXMAP_DECODED_IMAGESOURCE)
 #include <cairo-gl.h>
 #if ENABLE(TIZEN_CAIROGLES_IMAGE_AUTOSCALE)
-#define CAIRO_GL_SURFACE_MAX_WIDTH 4096
-#define CAIRO_GL_SURFACE_MAX_HEIGHT 4096
+#include <GLES2/gl2.h>
+#include <GLES2/gl2ext.h>
 #endif
 #endif
 
@@ -185,6 +185,9 @@ void PlatformContextCairo::drawSurfaceToContext(cairo_surface_t* surface, const
     }
     int current_width = original_width;
     int current_height = original_height;
+    static int cairo_gl_surface_max_size = 0;
+    if(cairo_gl_surface_max_size < 1)
+        glGetIntegerv(GL_MAX_TEXTURE_SIZE, &cairo_gl_surface_max_size);
 #endif
 
     if (surfaceType == CAIRO_SURFACE_TYPE_IMAGE && cairo_surface_get_type(surface) != CAIRO_SURFACE_TYPE_IMAGE) {
@@ -205,9 +208,9 @@ void PlatformContextCairo::drawSurfaceToContext(cairo_surface_t* surface, const
             int w = cairo_image_surface_get_width(surface);
             int h = cairo_image_surface_get_height(surface);
 #if ENABLE(TIZEN_CAIROGLES_IMAGE_AUTOSCALE)
-            if( w > CAIRO_GL_SURFACE_MAX_WIDTH || h > CAIRO_GL_SURFACE_MAX_HEIGHT) {
-                float scaleX = CAIRO_GL_SURFACE_MAX_WIDTH / (float)w;
-                float scaleY = CAIRO_GL_SURFACE_MAX_HEIGHT / (float)h;
+            if( w > cairo_gl_surface_max_size || h > cairo_gl_surface_max_size) {
+                float scaleX = cairo_gl_surface_max_size / (float)w;
+                float scaleY = cairo_gl_surface_max_size / (float)h;
                 RefPtr<cairo_surface_t> shrink_image = 0;
                 float scale = scaleX < scaleY ? scaleX : scaleY;
                 shrink_image = adoptRef(cairo_image_surface_create(cairo_image_surface_get_format (surface),