61 var scaling = VisualRoot?.RenderScaling ?? 1.0;
62 var physW = Math.Max(1, (
int)Math.Round(Bounds.Width * scaling));
63 var physH = Math.Max(1, (
int)Math.Round(Bounds.Height * scaling));
66 Host =
new RenderSurfaceHost<GpuBackbuffer>(
Adapter);
70 Adapter.AttachToEngine(RequestNextFrameRendering);
84 if (_disposeRequested != 0)
return;
85 _glInterface = GRGlInterface.Create();
86 if (_glInterface ==
null)
return;
87 _grContext = GRContext.CreateGl(_glInterface);
88 if (_grContext ==
null)
90 _glInterface.Dispose();
96 var scaling = VisualRoot?.RenderScaling ?? 1.0;
97 var physW = (int)Math.Round(Bounds.Width * scaling);
98 var physH = (int)Math.Round(Bounds.Height * scaling);
100 if (physW <= 0 || physH <= 0)
return;
105 Adapter.UpdateDimensions(physW, physH);
106 _gpuBackbuffer?.EnsureInitialized(_grContext);
112 long telemetryGeneration =
Host?.Telemetry?.BeginSample() ?? 0;
113 if (Volatile.Read(ref _disposeRequested) != 0 || _grContext ==
null || _gpuBackbuffer ==
null)
return;
117 _grContext.ResetContext();
119 var scaling = VisualRoot?.RenderScaling ?? 1.0;
120 var physW = (int)Math.Round(Bounds.Width * scaling);
121 var physH = (int)Math.Round(Bounds.Height * scaling);
123 if (physW <= 0 || physH <= 0)
125 _lastPhysW = _lastPhysH = 0;
126 Adapter.UpdateDimensions(0, 0);
131 if (physW != _lastPhysW || physH != _lastPhysH)
135 Adapter.UpdateDimensions(physW, physH);
139 _gpuBackbuffer.EnsureInitialized(_grContext);
143 var fbInfo =
new GRGlFramebufferInfo((uint)fb, GlRgba8);
144 using var renderTarget =
new GRBackendRenderTarget(physW, physH, sampleCount: 0, stencilBits: 0, fbInfo);
145 using var fbSurface = SKSurface.Create(_grContext, renderTarget, GRSurfaceOrigin.BottomLeft, SKColorType.Rgba8888);
147 if (fbSurface ==
null)
return;
149 var canvas = fbSurface.Canvas;
152 using var img =
Host.GlRenderAndSnapshot();
159 canvas.Clear(
Adapter.ClearColor);
163 _gpuBackbuffer.RecordFrame();
164 if (telemetryGeneration != 0)
Host!.Telemetry!.Record(telemetryGeneration,
"presentation.count", 1);