Skip to content

Commit af55248

Browse files
committed
[accCanvas] Restrict the conditions to accelerate a canvas
1 parent 165b0ef commit af55248

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

Source/WebCore/html/HTMLCanvasElement.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
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"
@@ -69,6 +70,7 @@
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

0 commit comments

Comments
 (0)