Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: third_party/WebKit/Source/modules/webgl/WebGLRenderingContextBase.h

Issue 1881563003: Implement OffscreenCanvas.getContext('webgl') (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: offscreenCanvas.getContext('webgl') crashes on worker Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Apple Inc. All rights reserved. 2 * Copyright (C) 2009 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 17 matching lines...) Expand all
28 28
29 #include "bindings/core/v8/Nullable.h" 29 #include "bindings/core/v8/Nullable.h"
30 #include "bindings/core/v8/ScriptState.h" 30 #include "bindings/core/v8/ScriptState.h"
31 #include "bindings/core/v8/ScriptValue.h" 31 #include "bindings/core/v8/ScriptValue.h"
32 #include "bindings/core/v8/ScriptWrappable.h" 32 #include "bindings/core/v8/ScriptWrappable.h"
33 #include "core/CoreExport.h" 33 #include "core/CoreExport.h"
34 #include "core/dom/DOMTypedArray.h" 34 #include "core/dom/DOMTypedArray.h"
35 #include "core/dom/TypedFlexibleArrayBufferView.h" 35 #include "core/dom/TypedFlexibleArrayBufferView.h"
36 #include "core/html/canvas/CanvasRenderingContext.h" 36 #include "core/html/canvas/CanvasRenderingContext.h"
37 #include "core/layout/LayoutBoxModelObject.h" 37 #include "core/layout/LayoutBoxModelObject.h"
38 #include "modules/offscreencanvas/OffscreenCanvasRenderingContext.h"
38 #include "modules/webgl/WebGLContextAttributes.h" 39 #include "modules/webgl/WebGLContextAttributes.h"
39 #include "modules/webgl/WebGLExtensionName.h" 40 #include "modules/webgl/WebGLExtensionName.h"
40 #include "modules/webgl/WebGLTexture.h" 41 #include "modules/webgl/WebGLTexture.h"
41 #include "modules/webgl/WebGLVertexArrayObjectBase.h" 42 #include "modules/webgl/WebGLVertexArrayObjectBase.h"
42 #include "platform/Timer.h" 43 #include "platform/Timer.h"
43 #include "platform/graphics/GraphicsTypes3D.h" 44 #include "platform/graphics/GraphicsTypes3D.h"
44 #include "platform/graphics/ImageBuffer.h" 45 #include "platform/graphics/ImageBuffer.h"
45 #include "platform/graphics/gpu/DrawingBuffer.h" 46 #include "platform/graphics/gpu/DrawingBuffer.h"
46 #include "platform/graphics/gpu/Extensions3DUtil.h" 47 #include "platform/graphics/gpu/Extensions3DUtil.h"
47 #include "platform/graphics/gpu/WebGLImageConversion.h" 48 #include "platform/graphics/gpu/WebGLImageConversion.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 // Restore DrawingBuffer if needed 135 // Restore DrawingBuffer if needed
135 if (!m_readFramebufferBinding && m_drawingBuffer) 136 if (!m_readFramebufferBinding && m_drawingBuffer)
136 m_drawingBuffer->restoreFramebufferBindings(); 137 m_drawingBuffer->restoreFramebufferBindings();
137 } 138 }
138 139
139 private: 140 private:
140 DrawingBuffer* m_drawingBuffer; 141 DrawingBuffer* m_drawingBuffer;
141 Member<WebGLFramebuffer> m_readFramebufferBinding; 142 Member<WebGLFramebuffer> m_readFramebufferBinding;
142 }; 143 };
143 144
144 class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext { 145 class MODULES_EXPORT WebGLRenderingContextBase : public CanvasRenderingContext, public OffscreenCanvasRenderingContext, public ScriptWrappable {
xlai (Olivia) 2016/04/20 20:42:16 [continued from previous comment] But then why is
xidachen 2016/04/20 20:52:09 WebGLBase has a idl and it is the actual interface
Ken Russell (switch to Gerrit) 2016/04/21 01:05:24 Based on past experience with multiple inheritance
xlai (Olivia) 2016/04/21 15:31:54 First, I agree with merging OffscreenCanvasRenderi
Ken Russell (switch to Gerrit) 2016/04/21 19:52:00 OK. Please do as you see fit with CanvasRenderingC
146 USING_GARBAGE_COLLECTED_MIXIN(WebGLRenderingContextBase);
145 public: 147 public:
146 ~WebGLRenderingContextBase() override; 148 ~WebGLRenderingContextBase() override;
147 149
148 virtual unsigned version() const = 0; 150 virtual unsigned version() const = 0;
149 virtual String contextName() const = 0; 151 virtual String contextName() const = 0;
150 virtual void registerContextExtensions() = 0; 152 virtual void registerContextExtensions() = 0;
151 153
152 virtual void initializeNewContext(); 154 virtual void initializeNewContext();
153 155
154 static unsigned getWebGLVersion(const CanvasRenderingContext*); 156 static unsigned getWebGLVersion(const CanvasRenderingContext*);
155 157
156 static PassOwnPtr<WebGraphicsContext3DProvider> createWebGraphicsContext3DPr ovider(HTMLCanvasElement*, WebGLContextAttributes, unsigned webGLVersion); 158 static PassOwnPtr<WebGraphicsContext3DProvider> createWebGraphicsContext3DPr ovider(HTMLCanvasElement*, WebGLContextAttributes, unsigned webGLVersion);
159 static PassOwnPtr<WebGraphicsContext3DProvider> createWebGraphicsContext3DPr ovider(ScriptState*, WebGLContextAttributes, unsigned webGLVersion);
157 static void forceNextWebGLContextCreationToFail(); 160 static void forceNextWebGLContextCreationToFail();
158 161
159 int drawingBufferWidth() const; 162 int drawingBufferWidth() const;
160 int drawingBufferHeight() const; 163 int drawingBufferHeight() const;
161 164
162 void activeTexture(GLenum texture); 165 void activeTexture(GLenum texture);
163 void attachShader(ScriptState*, WebGLProgram*, WebGLShader*); 166 void attachShader(ScriptState*, WebGLProgram*, WebGLShader*);
164 void bindAttribLocation(WebGLProgram*, GLuint index, const String& name); 167 void bindAttribLocation(WebGLProgram*, GLuint index, const String& name);
165 void bindBuffer(ScriptState*, GLenum target, WebGLBuffer*); 168 void bindBuffer(ScriptState*, GLenum target, WebGLBuffer*);
166 virtual void bindFramebuffer(ScriptState*, GLenum target, WebGLFramebuffer*) ; 169 virtual void bindFramebuffer(ScriptState*, GLenum target, WebGLFramebuffer*) ;
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 GLboolean isValuebufferCHROMIUM(CHROMIUMValuebuffer*); 405 GLboolean isValuebufferCHROMIUM(CHROMIUMValuebuffer*);
403 void bindValuebufferCHROMIUM(GLenum target, CHROMIUMValuebuffer*); 406 void bindValuebufferCHROMIUM(GLenum target, CHROMIUMValuebuffer*);
404 void subscribeValueCHROMIUM(GLenum target, GLenum subscription); 407 void subscribeValueCHROMIUM(GLenum target, GLenum subscription);
405 void populateSubscribedValuesCHROMIUM(GLenum target); 408 void populateSubscribedValuesCHROMIUM(GLenum target);
406 void uniformValuebufferCHROMIUM(const WebGLUniformLocation*, GLenum target, GLenum subscription); 409 void uniformValuebufferCHROMIUM(const WebGLUniformLocation*, GLenum target, GLenum subscription);
407 410
408 // Eagerly finalize WebGLRenderingContextBase in order for it 411 // Eagerly finalize WebGLRenderingContextBase in order for it
409 // to (first) be able to detach its WebGLContextObjects, before 412 // to (first) be able to detach its WebGLContextObjects, before
410 // they're later swept and finalized. 413 // they're later swept and finalized.
411 EAGERLY_FINALIZE(); 414 EAGERLY_FINALIZE();
412 DECLARE_EAGER_FINALIZATION_OPERATOR_NEW();
413 DECLARE_VIRTUAL_TRACE(); 415 DECLARE_VIRTUAL_TRACE();
414 416
415 // Returns approximate gpu memory allocated per pixel. 417 // Returns approximate gpu memory allocated per pixel.
416 int externallyAllocatedBytesPerPixel() override; 418 int externallyAllocatedBytesPerPixel() override;
417 419
418 class TextureUnitState { 420 class TextureUnitState {
419 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); 421 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW();
420 public: 422 public:
421 Member<WebGLTexture> m_texture2DBinding; 423 Member<WebGLTexture> m_texture2DBinding;
422 Member<WebGLTexture> m_textureCubeMapBinding; 424 Member<WebGLTexture> m_textureCubeMapBinding;
(...skipping 18 matching lines...) Expand all
441 friend class WebGLCompressedTextureATC; 443 friend class WebGLCompressedTextureATC;
442 friend class WebGLCompressedTextureETC1; 444 friend class WebGLCompressedTextureETC1;
443 friend class WebGLCompressedTexturePVRTC; 445 friend class WebGLCompressedTexturePVRTC;
444 friend class WebGLCompressedTextureS3TC; 446 friend class WebGLCompressedTextureS3TC;
445 friend class WebGLRenderingContextErrorMessageCallback; 447 friend class WebGLRenderingContextErrorMessageCallback;
446 friend class WebGLVertexArrayObjectBase; 448 friend class WebGLVertexArrayObjectBase;
447 friend class ScopedTexture2DRestorer; 449 friend class ScopedTexture2DRestorer;
448 friend class ScopedFramebufferRestorer; 450 friend class ScopedFramebufferRestorer;
449 451
450 WebGLRenderingContextBase(HTMLCanvasElement*, PassOwnPtr<WebGraphicsContext3 DProvider>, const WebGLContextAttributes&); 452 WebGLRenderingContextBase(HTMLCanvasElement*, PassOwnPtr<WebGraphicsContext3 DProvider>, const WebGLContextAttributes&);
453 WebGLRenderingContextBase(OffscreenCanvas*, PassOwnPtr<WebGraphicsContext3DP rovider>, const WebGLContextAttributes&);
451 PassRefPtr<DrawingBuffer> createDrawingBuffer(PassOwnPtr<WebGraphicsContext3 DProvider>); 454 PassRefPtr<DrawingBuffer> createDrawingBuffer(PassOwnPtr<WebGraphicsContext3 DProvider>);
452 void setupFlags(); 455 void setupFlags();
453 456
454 // CanvasRenderingContext implementation. 457 // CanvasRenderingContext implementation.
455 bool is3d() const override { return true; } 458 bool is3d() const override { return true; }
456 bool isAccelerated() const override { return true; } 459 bool isAccelerated() const override { return true; }
457 void setIsHidden(bool) override; 460 void setIsHidden(bool) override;
458 bool paintRenderingResultsToCanvas(SourceDrawingBuffer) override; 461 bool paintRenderingResultsToCanvas(SourceDrawingBuffer) override;
459 WebLayer* platformLayer() const override; 462 WebLayer* platformLayer() const override;
460 void stop() override; 463 void stop() override;
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 static void addToEvictedList(WebGLRenderingContextBase*); 1076 static void addToEvictedList(WebGLRenderingContextBase*);
1074 static void removeFromEvictedList(WebGLRenderingContextBase*); 1077 static void removeFromEvictedList(WebGLRenderingContextBase*);
1075 static void willDestroyContext(WebGLRenderingContextBase*); 1078 static void willDestroyContext(WebGLRenderingContextBase*);
1076 static void forciblyLoseOldestContext(const String& reason); 1079 static void forciblyLoseOldestContext(const String& reason);
1077 // Return the least recently used context's position in the active context v ector. 1080 // Return the least recently used context's position in the active context v ector.
1078 // If the vector is empty, return the maximum allowed active context number. 1081 // If the vector is empty, return the maximum allowed active context number.
1079 static WebGLRenderingContextBase* oldestContext(); 1082 static WebGLRenderingContextBase* oldestContext();
1080 static WebGLRenderingContextBase* oldestEvictedContext(); 1083 static WebGLRenderingContextBase* oldestEvictedContext();
1081 1084
1082 CrossThreadWeakPersistentThisPointer<WebGLRenderingContextBase> createWeakTh isPointer() { return CrossThreadWeakPersistentThisPointer<WebGLRenderingContextB ase>(this); } 1085 CrossThreadWeakPersistentThisPointer<WebGLRenderingContextBase> createWeakTh isPointer() { return CrossThreadWeakPersistentThisPointer<WebGLRenderingContextB ase>(this); }
1086
1087 private:
1088 WebGLRenderingContextBase(HTMLCanvasElement*, OffscreenCanvas*, PassOwnPtr<W ebGraphicsContext3DProvider>, const WebGLContextAttributes&);
1083 }; 1089 };
1084 1090
1085 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d()); 1091 DEFINE_TYPE_CASTS(WebGLRenderingContextBase, CanvasRenderingContext, context, co ntext->is3d(), context.is3d());
1086 1092
1087 } // namespace blink 1093 } // namespace blink
1088 1094
1089 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB ase::TextureUnitState); 1095 WTF_ALLOW_MOVE_INIT_AND_COMPARE_WITH_MEM_FUNCTIONS(blink::WebGLRenderingContextB ase::TextureUnitState);
1090 1096
1091 #endif // WebGLRenderingContextBase_h 1097 #endif // WebGLRenderingContextBase_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698