Merge pull request #453 from tocsick/master

Handle window resize for Cairo
This commit is contained in:
Joshua Granick
2015-05-26 08:07:06 -07:00
5 changed files with 33 additions and 6 deletions

View File

@@ -51,6 +51,7 @@ class NativeRenderer {
} else {
render ();
parent.context = CAIRO (cairo);
}
#end
@@ -94,16 +95,21 @@ class NativeRenderer {
if (cacheLock == null || cacheLock.pixels != lock.pixels || cacheLock.width != lock.width || cacheLock.height != lock.height) {
if ( primarySurface != null )
primarySurface.destroy ();
primarySurface = CairoSurface.createForData (lock.pixels, CairoFormat.ARGB32, lock.width, lock.height, lock.pitch);
if (cairo != null) {
cairo.destroy ();
primarySurface.destroy ();
cairo.recreate( primarySurface );
} else {
cairo = new Cairo (primarySurface);
}
primarySurface = CairoSurface.createForData (lock.pixels, CairoFormat.ARGB32, lock.width, lock.height, lock.pitch);
cairo = new Cairo (primarySurface);
parent.context = CAIRO (cairo);
}

View File

@@ -161,6 +161,8 @@ class GLRenderContext {
public var ALPHA = 0x1906;
public var RGB = 0x1907;
public var RGBA = 0x1908;
public var BGR_EXT = 0x80E0;
public var BGRA_EXT = 0x80E1;
public var LUMINANCE = 0x1909;
public var LUMINANCE_ALPHA = 0x190A;

View File

@@ -46,6 +46,14 @@ class Cairo {
}
public function recreate (surface:CairoSurface) : Void {
#if lime_cairo
destroy();
handle = lime_cairo_create (surface);
#end
}
public function arc (xc:Float, yc:Float, radius:Float, angle1:Float, angle2:Float):Void {

View File

@@ -12,6 +12,9 @@ namespace lime {
sdlWindow = ((SDLWindow*)window)->sdlWindow;
sdlTexture = 0;
width = 0;
height = 0;
int sdlFlags = 0;
if (window->flags & WINDOW_FLAG_HARDWARE) {
@@ -64,7 +67,10 @@ namespace lime {
SDL_GetRendererOutputSize (sdlRenderer, &width, &height);
if (!sdlTexture) {
if ( width != this->width || height != this->height) {
if( sdlTexture )
SDL_DestroyTexture( sdlTexture );
sdlTexture = SDL_CreateTexture (sdlRenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, width, height);

View File

@@ -23,6 +23,11 @@ namespace lime {
SDL_Renderer* sdlRenderer;
SDL_Texture* sdlTexture;
SDL_Window* sdlWindow;
private:
int width;
int height;
};