Changeset 243383 in webkit
- Timestamp:
- Mar 22, 2019, 9:54:54 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 16 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/inspector/canvas/recording-2d.html (modified) (4 diffs)
-
LayoutTests/inspector/canvas/recording-bitmaprenderer.html (modified) (3 diffs)
-
LayoutTests/inspector/canvas/recording-html-2d.html (modified) (3 diffs)
-
LayoutTests/inspector/canvas/recording-webgl.html (modified) (3 diffs)
-
LayoutTests/inspector/canvas/setRecordingAutoCaptureFrameCount.html (modified) (2 diffs)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/html/HTMLCanvasElement.cpp (modified) (1 diff)
-
Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp (modified) (5 diffs)
-
Source/WebCore/html/canvas/WebGLRenderingContextBase.h (modified) (3 diffs)
-
Source/WebCore/inspector/InspectorCanvas.cpp (modified) (6 diffs)
-
Source/WebCore/inspector/InspectorCanvas.h (modified) (3 diffs)
-
Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp (modified) (31 diffs)
-
Source/WebCore/inspector/agents/InspectorCanvasAgent.h (modified) (2 diffs)
-
Source/WebCore/platform/graphics/GraphicsContext3D.h (modified) (3 diffs)
-
Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r243380 r243383 1 2019-03-22 Ryan Haddad <ryanhaddad@apple.com> 2 3 Unreviewed, rolling out r243356. 4 5 Causes assertion failures with WebGL layout tests on macOS and 6 iOS. 7 8 Reverted changeset: 9 10 "Web Inspector: Safari Canvas Inspector seems to show the 11 canvas being rendered twice per frame." 12 https://bugs.webkit.org/show_bug.cgi?id=196082 13 https://trac.webkit.org/changeset/243356 14 1 15 2019-03-22 Antti Koivisto <antti@apple.com> 2 16 -
trunk/LayoutTests/inspector/canvas/recording-2d.html
r243356 r243383 40 40 bitmap = await createImageBitmap(image); 41 41 42 document.body.appendChild(canvas); 43 42 44 ctx.save(); 43 45 cancelActions(); … … 52 54 } 53 55 54 let requestAnimationFrameId= NaN;56 let timeoutID = NaN; 55 57 let saveCount = 1; 56 58 … … 60 62 ctx.restore(); // Ensures the state is reset between test cases. 61 63 62 c ancelAnimationFrame(requestAnimationFrameId);63 requestAnimationFrameId= NaN;64 clearTimeout(timeoutID); 65 timeoutID = NaN; 64 66 65 67 ctx.save(); // Ensures the state is reset between test cases. … … 398 400 frames[index++](); 399 401 if (index < frames.length) 400 requestAnimationFrameId = requestAnimationFrame(executeFrameFunction);402 timeoutID = setTimeout(executeFrameFunction, 0); 401 403 }; 402 404 executeFrameFunction(); -
trunk/LayoutTests/inspector/canvas/recording-bitmaprenderer.html
r243356 r243383 24 24 ctx = canvas.getContext("bitmaprenderer"); 25 25 26 cancelActions();26 document.body.appendChild(canvas); 27 27 28 28 runTest(); … … 35 35 } 36 36 37 let requestAnimationFrameId= NaN;37 let timeoutID = NaN; 38 38 39 39 function cancelActions() { 40 c ancelAnimationFrame(requestAnimationFrameId);41 requestAnimationFrameId= NaN;40 clearTimeout(timeoutID); 41 timeoutID = NaN; 42 42 43 43 createImageBitmap(transparentImage).then((transparentBitmap) => { … … 69 69 frames[index++](); 70 70 if (index < frames.length) 71 requestAnimationFrameId = requestAnimationFrame(executeFrameFunction);71 timeoutID = setTimeout(executeFrameFunction, 0); 72 72 }; 73 73 executeFrameFunction(); -
trunk/LayoutTests/inspector/canvas/recording-html-2d.html
r243356 r243383 40 40 imageBitmap = await createImageBitmap(image); 41 41 42 cancelActions();42 document.body.appendChild(canvas); 43 43 44 44 context.strokeStyle = "red"; … … 57 57 } 58 58 59 let requestAnimationFrameId = NaN;60 61 59 function cancelActions() { 62 cancelAnimationFrame(requestAnimationFrameId);63 requestAnimationFrameId = NaN;64 65 context.resetTransform();66 context.beginPath();67 context.clearRect(0, 0, context.canvas.width, context.canvas.height);68 60 } 69 61 … … 106 98 frames[index++](); 107 99 if (index < frames.length) 108 requestAnimationFrameId = requestAnimationFrame(executeFrameFunction);100 timeoutID = setTimeout(executeFrameFunction, 0); 109 101 }; 110 102 executeFrameFunction(); -
trunk/LayoutTests/inspector/canvas/recording-webgl.html
r243356 r243383 50 50 texture = context.createTexture(); 51 51 52 cancelActions();52 document.body.appendChild(context.canvas); 53 53 54 54 runTest(); … … 61 61 } 62 62 63 let requestAnimationFrameId= NaN;63 let timeoutID = NaN; 64 64 65 65 function cancelActions() { 66 c ancelAnimationFrame(requestAnimationFrameId);67 requestAnimationFrameId= NaN;66 clearTimeout(timeoutID); 67 timeoutID = NaN; 68 68 69 69 context.clearColor(0.0, 0.0, 0.0, 0.0); … … 503 503 frames[index++](); 504 504 if (index < frames.length) 505 requestAnimationFrameId = requestAnimationFrame(executeFrameFunction);505 timeoutID = setTimeout(executeFrameFunction, 0); 506 506 }; 507 507 executeFrameFunction(); -
trunk/LayoutTests/inspector/canvas/setRecordingAutoCaptureFrameCount.html
r243356 r243383 7 7 window.internals.settings.setWebGLErrorsToConsoleEnabled(false); 8 8 9 let requestAnimationFrameId= NaN;9 let timeoutID = NaN; 10 10 11 11 function cancelActions() { 12 c ancelAnimationFrame(requestAnimationFrameId);13 requestAnimationFrameId= NaN;12 clearTimeout(timeoutID); 13 timeoutID = NaN; 14 14 } 15 15 … … 20 20 21 21 if (index < frames.length) 22 requestAnimationFrameId = requestAnimationFrame(executeFrameFunction);22 timeoutID = setTimeout(executeFrameFunction, 0); 23 23 else { 24 24 setTimeout(() => { -
trunk/Source/WebCore/ChangeLog
r243380 r243383 1 2019-03-22 Ryan Haddad <ryanhaddad@apple.com> 2 3 Unreviewed, rolling out r243356. 4 5 Causes assertion failures with WebGL layout tests on macOS and 6 iOS. 7 8 Reverted changeset: 9 10 "Web Inspector: Safari Canvas Inspector seems to show the 11 canvas being rendered twice per frame." 12 https://bugs.webkit.org/show_bug.cgi?id=196082 13 https://trac.webkit.org/changeset/243356 14 1 15 2019-03-22 Antti Koivisto <antti@apple.com> 2 16 -
trunk/Source/WebCore/html/HTMLCanvasElement.cpp
r243356 r243383 669 669 void HTMLCanvasElement::paint(GraphicsContext& context, const LayoutRect& r) 670 670 { 671 if (UNLIKELY(m_context && m_context->callTracingActive())) 672 InspectorInstrumentation::didFinishRecordingCanvasFrame(*m_context); 673 671 674 // Clear the dirty rect 672 675 m_dirtyRect = FloatRect(); 673 676 674 if (!context.paintingDisabled()) { 675 bool shouldPaint = true; 676 677 if (m_context) { 678 shouldPaint = paintsIntoCanvasBuffer() || document().printing(); 679 if (shouldPaint) 680 m_context->paintRenderingResultsToCanvas(); 677 if (context.paintingDisabled()) 678 return; 679 680 if (m_context) { 681 if (!paintsIntoCanvasBuffer() && !document().printing()) 682 return; 683 684 m_context->paintRenderingResultsToCanvas(); 685 } 686 687 if (hasCreatedImageBuffer()) { 688 ImageBuffer* imageBuffer = buffer(); 689 if (imageBuffer) { 690 if (m_presentedImage) { 691 ImageOrientationDescription orientationDescription; 692 #if ENABLE(CSS_IMAGE_ORIENTATION) 693 orientationDescription.setImageOrientationEnum(renderer()->style().imageOrientation()); 694 #endif 695 context.drawImage(*m_presentedImage, snappedIntRect(r), ImagePaintingOptions(orientationDescription)); 696 } else 697 context.drawImageBuffer(*imageBuffer, snappedIntRect(r)); 681 698 } 682 683 if (shouldPaint) { 684 if (hasCreatedImageBuffer()) { 685 ImageBuffer* imageBuffer = buffer(); 686 if (imageBuffer) { 687 if (m_presentedImage) { 688 ImageOrientationDescription orientationDescription; 689 #if ENABLE(CSS_IMAGE_ORIENTATION) 690 orientationDescription.setImageOrientationEnum(renderer()->style().imageOrientation()); 691 #endif 692 context.drawImage(*m_presentedImage, snappedIntRect(r), ImagePaintingOptions(orientationDescription)); 693 } else 694 context.drawImageBuffer(*imageBuffer, snappedIntRect(r)); 695 } 696 } 697 698 if (isGPUBased()) 699 downcast<GPUBasedCanvasRenderingContext>(*m_context).markLayerComposited(); 700 } 701 } 702 703 if (UNLIKELY(m_context && m_context->callTracingActive())) 704 InspectorInstrumentation::didFinishRecordingCanvasFrame(*m_context); 699 } 700 701 if (isGPUBased()) 702 downcast<GPUBasedCanvasRenderingContext>(*m_context).markLayerComposited(); 705 703 } 706 704 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.cpp
r243356 r243383 662 662 m_contextGroup->addContext(*this); 663 663 664 m_context-> addClient(*this);664 m_context->setWebGLContext(this); 665 665 666 666 m_context->getIntegerv(GraphicsContext3D::MAX_VIEWPORT_DIMS, m_maxViewportDims); … … 915 915 916 916 if (m_context) { 917 m_context->removeClient(*this);918 917 m_context->setContextLostCallback(nullptr); 919 918 m_context->setErrorMessageCallback(nullptr); … … 5044 5043 } 5045 5044 5045 void WebGLRenderingContextBase::recycleContext() 5046 { 5047 printToConsole(MessageLevel::Error, "There are too many active WebGL contexts on this page, the oldest context will be lost."); 5048 // Using SyntheticLostContext means the developer won't be able to force the restoration 5049 // of the context by calling preventDefault() in a "webglcontextlost" event handler. 5050 forceLostContext(SyntheticLostContext); 5051 destroyGraphicsContext3D(); 5052 } 5053 5046 5054 void WebGLRenderingContextBase::loseContextImpl(WebGLRenderingContextBase::LostContextMode mode) 5047 5055 { … … 6218 6226 } 6219 6227 6228 void WebGLRenderingContextBase::dispatchContextChangedEvent() 6229 { 6230 auto* canvas = htmlCanvas(); 6231 if (!canvas) 6232 return; 6233 6234 canvas->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextchangedEvent, Event::CanBubble::No, Event::IsCancelable::Yes, emptyString())); 6235 } 6236 6220 6237 void WebGLRenderingContextBase::simulateContextChanged() 6221 6238 { … … 6497 6514 } 6498 6515 6499 void WebGLRenderingContextBase::didComposite()6500 {6501 if (UNLIKELY(callTracingActive()))6502 InspectorInstrumentation::didFinishRecordingCanvasFrame(*this);6503 }6504 6505 void WebGLRenderingContextBase::forceContextLost()6506 {6507 forceLostContext(WebGLRenderingContextBase::RealLostContext);6508 }6509 6510 void WebGLRenderingContextBase::recycleContext()6511 {6512 printToConsole(MessageLevel::Error, "There are too many active WebGL contexts on this page, the oldest context will be lost.");6513 // Using SyntheticLostContext means the developer won't be able to force the restoration6514 // of the context by calling preventDefault() in a "webglcontextlost" event handler.6515 forceLostContext(SyntheticLostContext);6516 destroyGraphicsContext3D();6517 }6518 6519 void WebGLRenderingContextBase::dispatchContextChangedNotification()6520 {6521 auto* canvas = htmlCanvas();6522 if (!canvas)6523 return;6524 6525 canvas->dispatchEvent(WebGLContextEvent::create(eventNames().webglcontextchangedEvent, Event::CanBubble::No, Event::IsCancelable::Yes, emptyString()));6526 }6527 6528 6529 6516 } // namespace WebCore 6530 6517 -
trunk/Source/WebCore/html/canvas/WebGLRenderingContextBase.h
r243356 r243383 95 95 using WebGLCanvas = WTF::Variant<RefPtr<HTMLCanvasElement>, RefPtr<OffscreenCanvas>>; 96 96 97 class WebGLRenderingContextBase : public G raphicsContext3D::Client, public GPUBasedCanvasRenderingContext, private ActivityStateChangeObserver {97 class WebGLRenderingContextBase : public GPUBasedCanvasRenderingContext, private ActivityStateChangeObserver { 98 98 public: 99 99 static std::unique_ptr<WebGLRenderingContextBase> create(CanvasBase&, WebGLContextAttributes&, const String&); … … 331 331 }; 332 332 void forceLostContext(LostContextMode); 333 void recycleContext(); 333 334 void forceRestoreContext(); 334 335 void loseContextImpl(LostContextMode); 336 void dispatchContextChangedEvent(); 335 337 WEBCORE_EXPORT void simulateContextChanged(); 336 338 … … 357 359 // Used for testing only, from Internals. 358 360 WEBCORE_EXPORT void setFailNextGPUStatusCheck(); 359 360 // GraphicsContext3D::Client361 void didComposite() override;362 void forceContextLost() override;363 void recycleContext() override;364 void dispatchContextChangedNotification() override;365 361 366 362 protected: -
trunk/Source/WebCore/inspector/InspectorCanvas.cpp
r243356 r243383 90 90 HTMLCanvasElement* InspectorCanvas::canvasElement() 91 91 { 92 if (is<HTMLCanvasElement>(m_context.canvasBase())) 93 return &downcast<HTMLCanvasElement>(m_context.canvasBase()); 92 auto* canvasBase = &m_context.canvasBase(); 93 if (is<HTMLCanvasElement>(canvasBase)) 94 return downcast<HTMLCanvasElement>(canvasBase); 94 95 return nullptr; 95 96 } … … 137 138 { 138 139 if (!m_initialState) { 139 // We should only construct the initial state for the first action of the recording.140 ASSERT(!m_frames && !m_currentActions);141 142 140 m_initialState = buildInitialState(); 143 141 m_bufferUsed += m_initialState->memoryCost(); … … 174 172 } 175 173 174 RefPtr<Inspector::Protocol::Recording::InitialState>&& InspectorCanvas::releaseInitialState() 175 { 176 return WTFMove(m_initialState); 177 } 178 179 RefPtr<JSON::ArrayOf<Inspector::Protocol::Recording::Frame>>&& InspectorCanvas::releaseFrames() 180 { 181 appendActionSnapshotIfNeeded(); 182 183 return WTFMove(m_frames); 184 } 185 186 RefPtr<JSON::ArrayOf<JSON::Value>>&& InspectorCanvas::releaseData() 187 { 188 m_indexedDuplicateData.clear(); 189 return WTFMove(m_serializedDuplicateData); 190 } 191 176 192 void InspectorCanvas::finalizeFrame() 177 193 { 178 appendActionSnapshotIfNeeded();179 180 194 if (m_frames && m_frames->length() && !std::isnan(m_currentFrameStartTime)) { 181 195 auto currentFrame = static_cast<Inspector::Protocol::Recording::Frame*>(m_frames->get(m_frames->length() - 1).get()); … … 298 312 } 299 313 300 Ref<Inspector::Protocol::Recording::Recording> InspectorCanvas::releaseObjectForRecording() 301 { 302 ASSERT(!m_currentActions); 303 ASSERT(!m_actionNeedingSnapshot); 304 ASSERT(!m_frames); 305 306 // FIXME: <https://webkit.org/b/176008> Web Inspector: Record actions performed on WebGL2RenderingContext 307 308 Inspector::Protocol::Recording::Type type; 309 if (is<CanvasRenderingContext2D>(m_context)) 310 type = Inspector::Protocol::Recording::Type::Canvas2D; 311 else if (is<ImageBitmapRenderingContext>(m_context)) 312 type = Inspector::Protocol::Recording::Type::CanvasBitmapRenderer; 313 #if ENABLE(WEBGL) 314 else if (is<WebGLRenderingContext>(m_context)) 315 type = Inspector::Protocol::Recording::Type::CanvasWebGL; 316 #endif 317 else { 318 ASSERT_NOT_REACHED(); 319 type = Inspector::Protocol::Recording::Type::Canvas2D; 320 } 321 322 auto recording = Inspector::Protocol::Recording::Recording::create() 323 .setVersion(Inspector::Protocol::Recording::VERSION) 324 .setType(type) 325 .setInitialState(m_initialState.releaseNonNull()) 326 .setData(m_serializedDuplicateData.releaseNonNull()) 327 .release(); 328 329 if (!m_recordingName.isEmpty()) 330 recording->setName(m_recordingName); 331 332 resetRecordingData(); 333 334 return recording; 335 } 336 337 String InspectorCanvas::getCanvasContentAsDataURL(ErrorString& errorString) 338 { 339 // FIXME: <https://webkit.org/b/173621> Web Inspector: Support getting the content of WebMetal context; 340 if (!is<CanvasRenderingContext2D>(m_context) 341 #if ENABLE(WEBGL) 342 && !is<WebGLRenderingContextBase>(m_context) 343 #endif 344 && !is<ImageBitmapRenderingContext>(m_context)) { 345 errorString = "Unsupported canvas context type"_s; 346 return emptyString(); 347 } 348 314 void InspectorCanvas::appendActionSnapshotIfNeeded() 315 { 316 if (!m_actionNeedingSnapshot) 317 return; 318 319 m_actionNeedingSnapshot->addItem(indexForData(getCanvasContentAsDataURL())); 320 m_actionNeedingSnapshot = nullptr; 321 } 322 323 String InspectorCanvas::getCanvasContentAsDataURL() 324 { 349 325 // FIXME: <https://webkit.org/b/180833> Web Inspector: support OffscreenCanvas for Canvas related operations 326 350 327 auto* node = canvasElement(); 351 if (!node) { 352 errorString = "Context isn't related to an HTMLCanvasElement"_s; 353 return emptyString(); 354 } 328 if (!node) 329 return String(); 355 330 356 331 #if ENABLE(WEBGL) … … 366 341 #endif 367 342 368 if (result.hasException()) { 369 errorString = result.releaseException().releaseMessage(); 370 return emptyString(); 371 } 343 if (result.hasException()) 344 return String(); 372 345 373 346 return result.releaseReturnValue().string; 374 }375 376 void InspectorCanvas::appendActionSnapshotIfNeeded()377 {378 if (!m_actionNeedingSnapshot)379 return;380 381 m_bufferUsed -= m_actionNeedingSnapshot->memoryCost();382 383 ErrorString ignored;384 m_actionNeedingSnapshot->addItem(indexForData(getCanvasContentAsDataURL(ignored)));385 386 m_bufferUsed += m_actionNeedingSnapshot->memoryCost();387 388 m_actionNeedingSnapshot = nullptr;389 347 } 390 348 … … 604 562 initialStatePayload->setParameters(WTFMove(parametersPayload)); 605 563 606 ErrorString ignored; 607 initialStatePayload->setContent(getCanvasContentAsDataURL(ignored)); 564 initialStatePayload->setContent(getCanvasContentAsDataURL()); 608 565 609 566 return initialStatePayload; -
trunk/Source/WebCore/inspector/InspectorCanvas.h
r243356 r243383 45 45 class ImageData; 46 46 47 typedef String ErrorString;48 49 47 class InspectorCanvas final : public RefCounted<InspectorCanvas> { 50 48 public: … … 61 59 void recordAction(const String&, Vector<RecordCanvasActionVariant>&& = { }); 62 60 63 Ref<JSON::ArrayOf<Inspector::Protocol::Recording::Frame>> releaseFrames() { return m_frames.releaseNonNull(); } 61 RefPtr<Inspector::Protocol::Recording::InitialState>&& releaseInitialState(); 62 RefPtr<JSON::ArrayOf<Inspector::Protocol::Recording::Frame>>&& releaseFrames(); 63 RefPtr<JSON::ArrayOf<JSON::Value>>&& releaseData(); 64 64 65 65 void finalizeFrame(); 66 66 void markCurrentFrameIncomplete(); 67 67 68 const String& recordingName() const { return m_recordingName; } 68 69 void setRecordingName(const String& name) { m_recordingName = name; } 69 70 … … 76 77 77 78 Ref<Inspector::Protocol::Canvas::Canvas> buildObjectForCanvas(bool captureBacktrace); 78 Ref<Inspector::Protocol::Recording::Recording> releaseObjectForRecording();79 80 String getCanvasContentAsDataURL(ErrorString&);81 79 82 80 private: 83 81 InspectorCanvas(CanvasRenderingContext&); 84 82 void appendActionSnapshotIfNeeded(); 83 String getCanvasContentAsDataURL(); 85 84 86 85 using DuplicateDataVariant = Variant< -
trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.cpp
r243356 r243383 27 27 #include "InspectorCanvasAgent.h" 28 28 29 #include "ActiveDOMCallbackMicrotask.h"30 29 #include "CanvasRenderingContext.h" 31 30 #include "CanvasRenderingContext2D.h" … … 39 38 #include "JSExecState.h" 40 39 #include "JSImageBitmapRenderingContext.h" 41 #include "Microtasks.h"42 40 #include "OffscreenCanvas.h" 43 41 #include "ScriptState.h" … … 81 79 , m_inspectedPage(context.inspectedPage) 82 80 , m_canvasDestroyedTimer(*this, &InspectorCanvasAgent::canvasDestroyedTimerFired) 81 , m_canvasRecordingTimer(*this, &InspectorCanvasAgent::canvasRecordingTimerFired) 83 82 { 84 83 } … … 149 148 void InspectorCanvasAgent::requestNode(ErrorString& errorString, const String& canvasId, int* nodeId) 150 149 { 151 auto inspectorCanvas = assertInspectorCanvas(errorString, canvasId);150 auto* inspectorCanvas = assertInspectorCanvas(errorString, canvasId); 152 151 if (!inspectorCanvas) 153 152 return; … … 170 169 void InspectorCanvasAgent::requestContent(ErrorString& errorString, const String& canvasId, String* content) 171 170 { 172 auto inspectorCanvas = assertInspectorCanvas(errorString, canvasId); 173 if (!inspectorCanvas) 174 return; 175 176 *content = inspectorCanvas->getCanvasContentAsDataURL(errorString); 171 auto* inspectorCanvas = assertInspectorCanvas(errorString, canvasId); 172 if (!inspectorCanvas) 173 return; 174 175 // FIXME: <https://webkit.org/b/180833> Web Inspector: support OffscreenCanvas for Canvas related operations 176 177 if (auto* node = inspectorCanvas->canvasElement()) { 178 if (is<CanvasRenderingContext2D>(inspectorCanvas->context()) || is<ImageBitmapRenderingContext>(inspectorCanvas->context())) { 179 auto result = node->toDataURL("image/png"_s); 180 if (result.hasException()) { 181 errorString = result.releaseException().releaseMessage(); 182 return; 183 } 184 *content = result.releaseReturnValue().string; 185 return; 186 } 187 188 #if ENABLE(WEBGL) 189 if (is<WebGLRenderingContextBase>(inspectorCanvas->context())) { 190 WebGLRenderingContextBase& contextWebGLBase = downcast<WebGLRenderingContextBase>(inspectorCanvas->context()); 191 192 contextWebGLBase.setPreventBufferClearForInspector(true); 193 auto result = node->toDataURL("image/png"_s); 194 contextWebGLBase.setPreventBufferClearForInspector(false); 195 196 if (result.hasException()) { 197 errorString = result.releaseException().releaseMessage(); 198 return; 199 } 200 *content = result.releaseReturnValue().string; 201 return; 202 } 203 #endif 204 } 205 206 // FIXME: <https://webkit.org/b/173621> Web Inspector: Support getting the content of WebMetal context; 207 errorString = "Unsupported canvas context type"_s; 177 208 } 178 209 179 210 void InspectorCanvasAgent::requestCSSCanvasClientNodes(ErrorString& errorString, const String& canvasId, RefPtr<JSON::ArrayOf<int>>& result) 180 211 { 181 auto inspectorCanvas = assertInspectorCanvas(errorString, canvasId);212 auto* inspectorCanvas = assertInspectorCanvas(errorString, canvasId); 182 213 if (!inspectorCanvas) 183 214 return; … … 220 251 void InspectorCanvasAgent::resolveCanvasContext(ErrorString& errorString, const String& canvasId, const String* objectGroup, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result) 221 252 { 222 auto inspectorCanvas = assertInspectorCanvas(errorString, canvasId);253 auto* inspectorCanvas = assertInspectorCanvas(errorString, canvasId); 223 254 if (!inspectorCanvas) 224 255 return; … … 249 280 void InspectorCanvasAgent::startRecording(ErrorString& errorString, const String& canvasId, const int* frameCount, const int* memoryLimit) 250 281 { 251 auto inspectorCanvas = assertInspectorCanvas(errorString, canvasId);282 auto* inspectorCanvas = assertInspectorCanvas(errorString, canvasId); 252 283 if (!inspectorCanvas) 253 284 return; … … 268 299 void InspectorCanvasAgent::stopRecording(ErrorString& errorString, const String& canvasId) 269 300 { 270 auto inspectorCanvas = assertInspectorCanvas(errorString, canvasId);301 auto* inspectorCanvas = assertInspectorCanvas(errorString, canvasId); 271 302 if (!inspectorCanvas) 272 303 return; … … 283 314 { 284 315 #if ENABLE(WEBGL) 285 auto inspectorProgram = assertInspectorProgram(errorString, programId);316 auto* inspectorProgram = assertInspectorProgram(errorString, programId); 286 317 if (!inspectorProgram) 287 318 return; … … 305 336 { 306 337 #if ENABLE(WEBGL) 307 auto inspectorProgram = assertInspectorProgram(errorString, programId);338 auto* inspectorProgram = assertInspectorProgram(errorString, programId); 308 339 if (!inspectorProgram) 309 340 return; … … 336 367 { 337 368 #if ENABLE(WEBGL) 338 auto inspectorProgram = assertInspectorProgram(errorString, programId);369 auto* inspectorProgram = assertInspectorProgram(errorString, programId); 339 370 if (!inspectorProgram) 340 371 return; … … 351 382 { 352 383 #if ENABLE(WEBGL) 353 auto inspectorProgram = assertInspectorProgram(errorString, programId);384 auto* inspectorProgram = assertInspectorProgram(errorString, programId); 354 385 if (!inspectorProgram) 355 386 return; … … 394 425 } 395 426 396 auto inspectorCanvas = findInspectorCanvas(*context);427 auto* inspectorCanvas = findInspectorCanvas(*context); 397 428 ASSERT(inspectorCanvas); 398 429 if (!inspectorCanvas) … … 420 451 void InspectorCanvasAgent::didChangeCanvasMemory(CanvasRenderingContext& context) 421 452 { 422 auto inspectorCanvas = findInspectorCanvas(context);453 auto* inspectorCanvas = findInspectorCanvas(context); 423 454 ASSERT(inspectorCanvas); 424 455 if (!inspectorCanvas) … … 433 464 void InspectorCanvasAgent::recordCanvasAction(CanvasRenderingContext& canvasRenderingContext, const String& name, Vector<RecordCanvasActionVariant>&& parameters) 434 465 { 435 auto inspectorCanvas = findInspectorCanvas(canvasRenderingContext);466 auto* inspectorCanvas = findInspectorCanvas(canvasRenderingContext); 436 467 ASSERT(inspectorCanvas); 437 468 if (!inspectorCanvas) … … 442 473 return; 443 474 444 // Only enqueue a microtask for the first action of each frame. Any subsequent actions will be445 // covered by the initial microtask until the next frame.446 if (!inspectorCanvas->currentFrameHasData()) {447 if (auto* scriptExecutionContext = inspectorCanvas->context().canvasBase().scriptExecutionContext()) {448 auto& queue = MicrotaskQueue::mainThreadQueue();449 queue.append(std::make_unique<ActiveDOMCallbackMicrotask>(queue, *scriptExecutionContext, [&, protectedInspectorCanvas = inspectorCanvas.copyRef()] {450 if (auto* canvasElement = protectedInspectorCanvas->canvasElement()) {451 if (canvasElement->isDescendantOf(canvasElement->document()))452 return;453 }454 455 if (protectedInspectorCanvas->context().callTracingActive())456 didFinishRecordingCanvasFrame(protectedInspectorCanvas->context());457 }));458 }459 }460 461 475 inspectorCanvas->recordAction(name, WTFMove(parameters)); 476 477 if (!m_canvasRecordingTimer.isActive()) 478 m_canvasRecordingTimer.startOneShot(0_s); 462 479 463 480 if (!inspectorCanvas->hasBufferSpace()) … … 471 488 return; 472 489 473 auto inspectorCanvas = findInspectorCanvas(*context); 474 ASSERT(inspectorCanvas); 490 auto* inspectorCanvas = findInspectorCanvas(*context); 475 491 if (!inspectorCanvas) 476 492 return; … … 489 505 void InspectorCanvasAgent::didFinishRecordingCanvasFrame(CanvasRenderingContext& context, bool forceDispatch) 490 506 { 491 auto inspectorCanvas = findInspectorCanvas(context);507 auto* inspectorCanvas = findInspectorCanvas(context); 492 508 ASSERT(inspectorCanvas); 493 509 if (!inspectorCanvas) … … 500 516 if (forceDispatch) { 501 517 m_frontendDispatcher->recordingFinished(inspectorCanvas->identifier(), nullptr); 518 502 519 inspectorCanvas->resetRecordingData(); 503 520 } … … 515 532 return; 516 533 517 m_frontendDispatcher->recordingFinished(inspectorCanvas->identifier(), inspectorCanvas->releaseObjectForRecording()); 534 // FIXME: <https://webkit.org/b/176008> Web Inspector: Record actions performed on WebGL2RenderingContext 535 536 Inspector::Protocol::Recording::Type type; 537 if (is<CanvasRenderingContext2D>(inspectorCanvas->context())) 538 type = Inspector::Protocol::Recording::Type::Canvas2D; 539 else if (is<ImageBitmapRenderingContext>(inspectorCanvas->context())) 540 type = Inspector::Protocol::Recording::Type::CanvasBitmapRenderer; 541 #if ENABLE(WEBGL) 542 else if (is<WebGLRenderingContext>(inspectorCanvas->context())) 543 type = Inspector::Protocol::Recording::Type::CanvasWebGL; 544 #endif 545 else { 546 ASSERT_NOT_REACHED(); 547 type = Inspector::Protocol::Recording::Type::Canvas2D; 548 } 549 550 auto recording = Inspector::Protocol::Recording::Recording::create() 551 .setVersion(Inspector::Protocol::Recording::VERSION) 552 .setType(type) 553 .setInitialState(inspectorCanvas->releaseInitialState()) 554 .setData(inspectorCanvas->releaseData()) 555 .release(); 556 557 const String& name = inspectorCanvas->recordingName(); 558 if (!name.isEmpty()) 559 recording->setName(name); 560 561 m_frontendDispatcher->recordingFinished(inspectorCanvas->identifier(), WTFMove(recording)); 562 563 inspectorCanvas->resetRecordingData(); 518 564 } 519 565 520 566 void InspectorCanvasAgent::consoleStartRecordingCanvas(CanvasRenderingContext& context, JSC::ExecState& exec, JSC::JSObject* options) 521 567 { 522 auto inspectorCanvas = findInspectorCanvas(context);568 auto* inspectorCanvas = findInspectorCanvas(context); 523 569 ASSERT(inspectorCanvas); 524 570 if (!inspectorCanvas) … … 542 588 void InspectorCanvasAgent::didEnableExtension(WebGLRenderingContextBase& context, const String& extension) 543 589 { 544 auto inspectorCanvas = findInspectorCanvas(context);590 auto* inspectorCanvas = findInspectorCanvas(context); 545 591 ASSERT(inspectorCanvas); 546 592 if (!inspectorCanvas) … … 552 598 void InspectorCanvasAgent::didCreateProgram(WebGLRenderingContextBase& context, WebGLProgram& program) 553 599 { 554 auto inspectorCanvas = findInspectorCanvas(context);600 auto* inspectorCanvas = findInspectorCanvas(context); 555 601 ASSERT(inspectorCanvas); 556 602 if (!inspectorCanvas) … … 565 611 void InspectorCanvasAgent::willDeleteProgram(WebGLProgram& program) 566 612 { 567 auto inspectorProgram = findInspectorProgram(program);613 auto* inspectorProgram = findInspectorProgram(program); 568 614 if (!inspectorProgram) 569 615 return; … … 575 621 bool InspectorCanvasAgent::isShaderProgramDisabled(WebGLProgram& program) 576 622 { 577 auto inspectorProgram = findInspectorProgram(program); 578 ASSERT(inspectorProgram); 623 auto* inspectorProgram = findInspectorProgram(program); 579 624 if (!inspectorProgram) 580 625 return false; … … 585 630 bool InspectorCanvasAgent::isShaderProgramHighlighted(WebGLProgram& program) 586 631 { 587 auto inspectorProgram = findInspectorProgram(program); 588 ASSERT(inspectorProgram); 632 auto* inspectorProgram = findInspectorProgram(program); 589 633 if (!inspectorProgram) 590 634 return false; … … 631 675 } 632 676 677 void InspectorCanvasAgent::canvasRecordingTimerFired() 678 { 679 for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) { 680 if (!inspectorCanvas->context().callTracingActive()) 681 continue; 682 683 didFinishRecordingCanvasFrame(inspectorCanvas->context()); 684 } 685 } 686 633 687 void InspectorCanvasAgent::clearCanvasData() 634 688 { … … 637 691 638 692 m_identifierToInspectorCanvas.clear(); 693 m_removedCanvasIdentifiers.clear(); 639 694 #if ENABLE(WEBGL) 640 695 m_identifierToInspectorProgram.clear(); 641 m_removedCanvasIdentifiers.clear(); 642 #endif 696 #endif 697 698 if (m_canvasRecordingTimer.isActive()) 699 m_canvasRecordingTimer.stop(); 643 700 644 701 if (m_canvasDestroyedTimer.isActive()) … … 689 746 } 690 747 691 RefPtr<InspectorCanvas>InspectorCanvasAgent::assertInspectorCanvas(ErrorString& errorString, const String& identifier)692 { 693 autoinspectorCanvas = m_identifierToInspectorCanvas.get(identifier);748 InspectorCanvas* InspectorCanvasAgent::assertInspectorCanvas(ErrorString& errorString, const String& identifier) 749 { 750 RefPtr<InspectorCanvas> inspectorCanvas = m_identifierToInspectorCanvas.get(identifier); 694 751 if (!inspectorCanvas) { 695 752 errorString = "No canvas for given identifier."_s; … … 697 754 } 698 755 699 return inspectorCanvas ;700 } 701 702 RefPtr<InspectorCanvas>InspectorCanvasAgent::findInspectorCanvas(CanvasRenderingContext& context)756 return inspectorCanvas.get(); 757 } 758 759 InspectorCanvas* InspectorCanvasAgent::findInspectorCanvas(CanvasRenderingContext& context) 703 760 { 704 761 for (auto& inspectorCanvas : m_identifierToInspectorCanvas.values()) { 705 762 if (&inspectorCanvas->context() == &context) 706 return inspectorCanvas ;763 return inspectorCanvas.get(); 707 764 } 708 765 … … 719 776 } 720 777 721 RefPtr<InspectorShaderProgram>InspectorCanvasAgent::assertInspectorProgram(ErrorString& errorString, const String& identifier)722 { 723 autoinspectorProgram = m_identifierToInspectorProgram.get(identifier);778 InspectorShaderProgram* InspectorCanvasAgent::assertInspectorProgram(ErrorString& errorString, const String& identifier) 779 { 780 RefPtr<InspectorShaderProgram> inspectorProgram = m_identifierToInspectorProgram.get(identifier); 724 781 if (!inspectorProgram) { 725 782 errorString = "No shader program for given identifier."_s; … … 727 784 } 728 785 729 return inspectorProgram ;730 } 731 732 RefPtr<InspectorShaderProgram>InspectorCanvasAgent::findInspectorProgram(WebGLProgram& program)786 return inspectorProgram.get(); 787 } 788 789 InspectorShaderProgram* InspectorCanvasAgent::findInspectorProgram(WebGLProgram& program) 733 790 { 734 791 for (auto& inspectorProgram : m_identifierToInspectorProgram.values()) { 735 792 if (&inspectorProgram->program() == &program) 736 return inspectorProgram ;793 return inspectorProgram.get(); 737 794 } 738 795 -
trunk/Source/WebCore/inspector/agents/InspectorCanvasAgent.h
r243356 r243383 113 113 114 114 void canvasDestroyedTimerFired(); 115 void canvasRecordingTimerFired(); 115 116 void clearCanvasData(); 116 117 InspectorCanvas& bindCanvas(CanvasRenderingContext&, bool captureBacktrace); 117 118 String unbindCanvas(InspectorCanvas&); 118 RefPtr<InspectorCanvas>assertInspectorCanvas(ErrorString&, const String& identifier);119 RefPtr<InspectorCanvas>findInspectorCanvas(CanvasRenderingContext&);119 InspectorCanvas* assertInspectorCanvas(ErrorString&, const String& identifier); 120 InspectorCanvas* findInspectorCanvas(CanvasRenderingContext&); 120 121 #if ENABLE(WEBGL) 121 122 String unbindProgram(InspectorShaderProgram&); 122 RefPtr<InspectorShaderProgram> assertInspectorProgram(ErrorString&, const String& identifier); 123 RefPtr<InspectorShaderProgram> findInspectorProgram(WebGLProgram&); 123 InspectorShaderProgram* assertInspectorProgram(ErrorString&, const String& identifier); 124 InspectorShaderProgram* findInspectorProgram(WebGLProgram&); 125 126 HashMap<String, RefPtr<InspectorShaderProgram>> m_identifierToInspectorProgram; 124 127 #endif 125 128 … … 131 134 132 135 HashMap<String, RefPtr<InspectorCanvas>> m_identifierToInspectorCanvas; 133 #if ENABLE(WEBGL)134 HashMap<String, RefPtr<InspectorShaderProgram>> m_identifierToInspectorProgram;135 #endif136 136 Vector<String> m_removedCanvasIdentifiers; 137 138 137 Optional<size_t> m_recordingAutoCaptureFrameCount; 139 140 138 Timer m_canvasDestroyedTimer; 139 Timer m_canvasRecordingTimer; 141 140 }; 142 141 -
trunk/Source/WebCore/platform/graphics/GraphicsContext3D.h
r243356 r243383 121 121 class GraphicsContext3D : public RefCounted<GraphicsContext3D> { 122 122 public: 123 class Client {124 public:125 virtual ~Client() { }126 virtual void didComposite() = 0;127 virtual void forceContextLost() = 0;128 virtual void recycleContext() = 0;129 virtual void dispatchContextChangedNotification() = 0;130 };131 132 123 enum { 133 124 // WebGL 1 constants … … 774 765 775 766 bool makeContextCurrent(); 776 777 void addClient(Client& client) { m_clients.add(&client); } 778 void removeClient(Client& client) { m_clients.remove(&client); } 767 void setWebGLContext(WebGLRenderingContextBase* base) { m_webglContext = base; } 779 768 780 769 // With multisampling on, blit from multisampleFBO to regular FBO. … … 1519 1508 #endif 1520 1509 1521 HashSet<Client*> m_clients; 1510 // FIXME: Layering violation. 1511 WebGLRenderingContextBase* m_webglContext { nullptr }; 1522 1512 1523 1513 bool m_isForWebGL2 { false }; -
trunk/Source/WebCore/platform/graphics/opengl/GraphicsContext3DOpenGLCommon.cpp
r243356 r243383 2017 2017 { 2018 2018 m_layerComposited = true; 2019 2020 for (auto* client : m_clients)2021 client->didComposite();2022 2019 } 2023 2020 … … 2029 2026 void GraphicsContext3D::forceContextLost() 2030 2027 { 2031 for (auto* client : m_clients) 2032 client->forceContextLost(); 2028 #if ENABLE(WEBGL) 2029 if (m_webglContext) 2030 m_webglContext->forceLostContext(WebGLRenderingContextBase::RealLostContext); 2031 #endif 2033 2032 } 2034 2033 2035 2034 void GraphicsContext3D::recycleContext() 2036 2035 { 2037 for (auto* client : m_clients) 2038 client->recycleContext(); 2036 #if ENABLE(WEBGL) 2037 if (m_webglContext) 2038 m_webglContext->recycleContext(); 2039 #endif 2039 2040 } 2040 2041 2041 2042 void GraphicsContext3D::dispatchContextChangedNotification() 2042 2043 { 2043 for (auto* client : m_clients) 2044 client->dispatchContextChangedNotification(); 2044 #if ENABLE(WEBGL) 2045 if (m_webglContext) 2046 m_webglContext->dispatchContextChangedEvent(); 2047 #endif 2045 2048 } 2046 2049
Note:
See TracChangeset
for help on using the changeset viewer.