File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 4343#include " FrameLoaderClient.h"
4444#include " GPUBasedCanvasRenderingContext.h"
4545#include " GeometryUtilities.h"
46+ #include " GLContext.h"
4647#include " GraphicsContext.h"
4748#include " HostWindow.h"
4849#include " HTMLNames.h"
6970#include < JavaScriptCore/JSCInlines.h>
7071#include < math.h>
7172#include < wtf/IsoMallocInlines.h>
73+ #include < wtf/MainThread.h>
7274#include < wtf/RAMSize.h>
7375#include < wtf/text/StringBuilder.h>
7476
@@ -898,6 +900,21 @@ bool HTMLCanvasElement::shouldAccelerate(unsigned area) const
898900 if (!settings.canvasUsesAcceleratedDrawing ())
899901 return false ;
900902
903+ // Don't accelerate canvases created on worker threads.
904+ if (!isMainThread ())
905+ return false ;
906+
907+ // Don't accelerate canvases when nonCompositedWebGL is enabled.
908+ if (settings.nonCompositedWebGLEnabled ())
909+ return false ;
910+
911+ // Don't accelerate canvases if there's an existent glContext that's not the sharing one, as
912+ // it means that there's WebGL content being rendered.
913+ GLContext* activeContext = GLContext::current ();
914+ GLContext* sharingContext = PlatformDisplay::sharedDisplayForCompositing ().sharingGLContext ();
915+ if (activeContext && activeContext != sharingContext)
916+ return false ;
917+
901918 if (area < settings.minimumAccelerated2dCanvasSize ())
902919 return false ;
903920
You can’t perform that action at this time.
0 commit comments