From 2222702f56e2c4b387efd82a9194b9d36c919248 Mon Sep 17 00:00:00 2001 From: Yan Wang Date: Thu, 10 Oct 2013 12:42:25 +0800 Subject: [PATCH] Get Cairo GLES max surface size based on dynamic query. Change-Id: I6b66c4710fc0f4650f5379bfd21b000798d35a00 Signed-off-by: Yan Wang --- .../platform/graphics/cairo/PlatformContextCairo.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp b/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp index bff8c29..c5b5676 100644 --- a/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp +++ b/Source/WebCore/platform/graphics/cairo/PlatformContextCairo.cpp @@ -37,8 +37,8 @@ #if ENABLE(TIZEN_CAIROGLES_IMAGE_CACHE) || ENABLE(TIZEN_USE_XPIXMAP_DECODED_IMAGESOURCE) #include #if ENABLE(TIZEN_CAIROGLES_IMAGE_AUTOSCALE) -#define CAIRO_GL_SURFACE_MAX_WIDTH 4096 -#define CAIRO_GL_SURFACE_MAX_HEIGHT 4096 +#include +#include #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 shrink_image = 0; float scale = scaleX < scaleY ? scaleX : scaleY; shrink_image = adoptRef(cairo_image_surface_create(cairo_image_surface_get_format (surface), -- 2.7.4