@@ -13,6 +13,7 @@ local FPS_Smoother = CreateClientConVar( "cinema_smoother", 1, true, false, "Mak
1313
1414local function ChangeFrameCap ()
1515 local bool = FPS_Smoother :GetBool ()
16+
1617 FPS_Cap = bool and 60 or 30
1718end
1819ChangeFrameCap ()
@@ -25,35 +26,33 @@ function draw.TheaterText(text, font, x, y, colour, xalign, yalign)
2526 draw_SimpleText (text , font , x , y , colour , xalign , yalign )
2627end
2728
29+ local mat , pw , ph
2830function draw .HTMLTexture ( panel , w , h )
29- if not (panel and IsValid (panel ) and w and h ) then return end
30-
31- -- Initialize cache on first use
32- if not panel ._cachedWidth then
33- local pw , ph = panel :GetSize ()
34- local w_scalar = w / pw
35- local h_scalar = h / ph
36- local pw_adjusted = pw * (math .power2 (pw ) / pw )
37- local ph_adjusted = ph * (math .power2 (ph ) / ph )
38-
39- panel ._cachedWidth = w_scalar * pw_adjusted
40- panel ._cachedHeight = h_scalar * ph_adjusted
41- end
31+ if not panel or not IsValid (panel ) then return end
32+ if not w or not h then return end
4233
43- -- Update texture at throttled rate
4434 if not panel .NextHTMLTextureThink or RealTime () > panel .NextHTMLTextureThink then
4535 panel :UpdateHTMLTexture ()
4636 panel .NextHTMLTextureThink = RealTime () + (1 / FPS_Cap )
47- panel ._cachedMaterial = panel :GetHTMLMaterial ()
4837 end
4938
50- -- Render using cached values
51- if panel ._cachedMaterial then
39+ pw , ph = panel :GetSize ()
40+
41+ -- Convert to scalar
42+ w = w / pw
43+ h = h / ph
44+
45+ -- Fix for non-power-of-two html panel size
46+ pw = pw * (math .power2 (pw ) / pw )
47+ ph = ph * (math .power2 (ph ) / ph )
48+
49+ mat = panel :GetHTMLMaterial ()
50+ if mat then
5251 surface_SetDrawColor ( 255 , 255 , 255 , 255 )
53- surface_SetMaterial ( panel . _cachedMaterial )
54- surface_DrawTexturedRect ( 0 , 0 , panel . _cachedWidth , panel . _cachedHeight )
52+ surface_SetMaterial ( mat )
53+ surface_DrawTexturedRect ( 0 , 0 , w * pw , h * ph )
5554 else
5655 surface_SetDrawColor ( 0 , 0 , 0 , 255 )
57- surface_DrawRect ( 0 , 0 , panel . _cachedWidth , panel . _cachedHeight )
56+ surface_DrawRect ( 0 , 0 , w * pw , h * ph )
5857 end
5958end
0 commit comments