@@ -28,6 +28,12 @@ internal class GLRenderSurface : GLArea, IRenderSurface
28
28
private const SKColorType colorType = SKColorType . Rgba8888 ;
29
29
private const GRSurfaceOrigin surfaceOrigin = GRSurfaceOrigin . BottomLeft ;
30
30
31
+ /// <summary>
32
+ /// Include a guard band for the creation of the OpenGL surface to avoid
33
+ /// incorrect renders when the surface is exactly the size of the GLArea.
34
+ /// </summary>
35
+ private const int GuardBand = 32 ;
36
+
31
37
private readonly DisplayInformation _displayInformation ;
32
38
private FocusManager ? _focusManager ;
33
39
@@ -77,9 +83,6 @@ private void UnoGLDrawingArea_Render(object o, RenderArgs args)
77
83
_grContext = GRContext . CreateGl ( glInterface ) ;
78
84
}
79
85
80
- _gl . Clear ( ClearBufferMask . ColorBufferBit ) ;
81
- _gl . ClearColor ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
82
-
83
86
// manage the drawing surface
84
87
var res = ( int ) Math . Max ( 1.0 , Screen . Resolution / 96.0 ) ;
85
88
var w = Math . Max ( 0 , AllocatedWidth * res ) ;
@@ -102,24 +105,33 @@ private void UnoGLDrawingArea_Render(object o, RenderArgs args)
102
105
103
106
var glInfo = new GRGlFramebufferInfo ( ( uint ) framebuffer , colorType . ToGlSizedFormat ( ) ) ;
104
107
105
- _renderTarget = new GRBackendRenderTarget ( w , h , samples , stencil , glInfo ) ;
108
+ _renderTarget = new GRBackendRenderTarget ( w + GuardBand , h + GuardBand , samples , stencil , glInfo ) ;
106
109
107
110
// create the surface
108
111
_surface ? . Dispose ( ) ;
109
112
_surface = SKSurface . Create ( _grContext , _renderTarget , surfaceOrigin , colorType ) ;
113
+
114
+ if ( this . Log ( ) . IsEnabled ( LogLevel . Trace ) )
115
+ {
116
+ this . Log ( ) . Trace ( $ "Recreate render surface { w } x{ h } colorType:{ colorType } sample:{ samples } ") ;
117
+ }
110
118
}
111
119
112
- using ( new SKAutoCanvasRestore ( _surface . Canvas , true ) )
113
- {
114
- _surface . Canvas . Clear ( SKColors . White ) ;
120
+ _gl . Clear ( ClearBufferMask . ColorBufferBit | ClearBufferMask . StencilBufferBit | ClearBufferMask . DepthBufferBit ) ;
121
+ _gl . ClearColor ( 1.0f , 1.0f , 1.0f , 1.0f ) ;
115
122
116
- // _surface.Canvas.Scale((float)(1/_dpi));
123
+ var canvas = _surface . Canvas ;
124
+
125
+ using ( new SKAutoCanvasRestore ( canvas , true ) )
126
+ {
127
+ canvas . Clear ( SKColors . White ) ;
128
+ canvas . Translate ( new SKPoint ( 0 , GuardBand ) ) ;
117
129
118
130
WUX . Window . Current . Compositor . Render ( _surface ) ;
119
131
}
120
132
121
133
// update the control
122
- _surface . Canvas . Flush ( ) ;
134
+ canvas . Flush ( ) ;
123
135
124
136
_gl . Flush ( ) ;
125
137
}
0 commit comments