Changeset 286065 in webkit
- Timestamp:
- Nov 19, 2021 9:42:38 AM (8 months ago)
- Location:
- trunk/Source
- Files:
-
- 22 edited
-
WTF/ChangeLog (modified) (1 diff)
-
WTF/wtf/PlatformEnableCocoa.h (modified) (1 diff)
-
WebCore/ChangeLog (modified) (1 diff)
-
WebCore/Modules/model-element/HTMLModelElement.cpp (modified) (1 diff)
-
WebCore/Modules/model-element/HTMLModelElement.h (modified) (1 diff)
-
WebCore/Modules/model-element/HTMLModelElement.idl (modified) (1 diff)
-
WebCore/Modules/model-element/ModelPlayer.h (modified) (1 diff)
-
WebCore/Modules/model-element/dummy/DummyModelPlayer.cpp (modified) (1 diff)
-
WebCore/Modules/model-element/dummy/DummyModelPlayer.h (modified) (1 diff)
-
WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.h (modified) (1 diff)
-
WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.mm (modified) (1 diff)
-
WebCore/PAL/ChangeLog (modified) (1 diff)
-
WebCore/PAL/pal/spi/ios/SystemPreviewSPI.h (modified) (1 diff)
-
WebCore/PAL/pal/spi/mac/SystemPreviewSPI.h (modified) (1 diff)
-
WebKit/ChangeLog (modified) (1 diff)
-
WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm (modified) (1 diff)
-
WebKit/UIProcess/ModelElementController.h (modified) (1 diff)
-
WebKit/UIProcess/WebPageProxy.cpp (modified) (1 diff)
-
WebKit/UIProcess/WebPageProxy.h (modified) (1 diff)
-
WebKit/UIProcess/WebPageProxy.messages.in (modified) (1 diff)
-
WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.h (modified) (1 diff)
-
WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.mm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WTF/ChangeLog
r286062 r286065 1 2021-11-19 Antoine Quint <graouts@webkit.org> 2 3 [Model] add audio support 4 https://bugs.webkit.org/show_bug.cgi?id=233365 5 <rdar://problem/85428982> 6 7 Reviewed by Wenson Hsieh. 8 9 Add a new compile-time flag for the new autio-related ARQL SPIs we are using. 10 11 * wtf/PlatformEnableCocoa.h: 12 1 13 2021-11-19 Alex Christensen <achristensen@webkit.org> 2 14 -
trunk/Source/WTF/wtf/PlatformEnableCocoa.h
r286048 r286065 748 748 #define ENABLE_ARKIT_INLINE_PREVIEW_CAMERA_TRANSFORM 1 749 749 #define ENABLE_ARKIT_INLINE_PREVIEW_ANIMATIONS_CONTROL 1 750 #endif 750 #define ENABLE_ARKIT_INLINE_PREVIEW_AUDIO_CONTROL 1 751 #endif -
trunk/Source/WebCore/ChangeLog
r286064 r286065 1 2021-11-19 Antoine Quint <graouts@webkit.org> 2 3 [Model] add audio support 4 https://bugs.webkit.org/show_bug.cgi?id=233365 5 <rdar://problem/85428982> 6 7 Reviewed by Wenson Hsieh. 8 9 We add three new promise-based methods to the HTMLModelElement IDL to control the audio state 10 of the animation built into the USDZ asset: hasAudio(), isMuted() and setIsMuted(). 11 All these methods are promise-based. 12 13 * Modules/model-element/HTMLModelElement.cpp: 14 (WebCore::HTMLModelElement::hasAudio): 15 (WebCore::HTMLModelElement::isMuted): 16 (WebCore::HTMLModelElement::setIsMuted): 17 * Modules/model-element/HTMLModelElement.h: 18 * Modules/model-element/HTMLModelElement.idl: 19 * Modules/model-element/ModelPlayer.h: 20 * Modules/model-element/dummy/DummyModelPlayer.cpp: 21 (WebCore::DummyModelPlayer::hasAudio): 22 (WebCore::DummyModelPlayer::isMuted): 23 (WebCore::DummyModelPlayer::setIsMuted): 24 * Modules/model-element/dummy/DummyModelPlayer.h: 25 * Modules/model-element/scenekit/SceneKitModelPlayer.h: 26 * Modules/model-element/scenekit/SceneKitModelPlayer.mm: 27 (WebCore::SceneKitModelPlayer::hasAudio): 28 (WebCore::SceneKitModelPlayer::isMuted): 29 (WebCore::SceneKitModelPlayer::setIsMuted): 30 1 31 2021-11-19 Antti Koivisto <antti@apple.com> 2 32 -
trunk/Source/WebCore/Modules/model-element/HTMLModelElement.cpp
r286048 r286065 438 438 } 439 439 440 // MARK: - Audio support. 441 442 void HTMLModelElement::hasAudio(HasAudioPromise&& promise) 443 { 444 if (!m_modelPlayer) { 445 promise.reject(); 446 return; 447 } 448 449 m_modelPlayer->isPlayingAnimation([promise = WTFMove(promise)] (std::optional<bool> hasAudio) mutable { 450 if (!hasAudio) 451 promise.reject(); 452 else 453 promise.resolve(*hasAudio); 454 }); 455 } 456 457 void HTMLModelElement::isMuted(IsMutedPromise&& promise) 458 { 459 if (!m_modelPlayer) { 460 promise.reject(); 461 return; 462 } 463 464 m_modelPlayer->isPlayingAnimation([promise = WTFMove(promise)] (std::optional<bool> isMuted) mutable { 465 if (!isMuted) 466 promise.reject(); 467 else 468 promise.resolve(*isMuted); 469 }); 470 } 471 472 void HTMLModelElement::setIsMuted(bool isMuted, DOMPromiseDeferred<void>&& promise) 473 { 474 if (!m_modelPlayer) { 475 promise.reject(); 476 return; 477 } 478 479 m_modelPlayer->setIsMuted(isMuted, [promise = WTFMove(promise)] (bool success) mutable { 480 if (success) 481 promise.resolve(); 482 else 483 promise.reject(); 484 }); 485 } 486 440 487 } 441 488 -
trunk/Source/WebCore/Modules/model-element/HTMLModelElement.h
r286048 r286065 81 81 void pauseAnimation(DOMPromiseDeferred<void>&&); 82 82 83 using HasAudioPromise = DOMPromiseDeferred<IDLBoolean>; 84 void hasAudio(HasAudioPromise&&); 85 using IsMutedPromise = DOMPromiseDeferred<IDLBoolean>; 86 void isMuted(IsMutedPromise&&); 87 void setIsMuted(bool, DOMPromiseDeferred<void>&&); 88 83 89 bool isDraggableIgnoringAttributes() const final { return true; } 84 90 -
trunk/Source/WebCore/Modules/model-element/HTMLModelElement.idl
r286048 r286065 41 41 Promise<undefined> playAnimation(); 42 42 Promise<undefined> pauseAnimation(); 43 44 Promise<boolean> hasAudio(); 45 Promise<boolean> isMuted(); 46 Promise<undefined> setIsMuted(boolean isMuted); 43 47 }; -
trunk/Source/WebCore/Modules/model-element/ModelPlayer.h
r286048 r286065 54 54 virtual void isPlayingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) = 0; 55 55 virtual void setAnimationIsPlaying(bool, CompletionHandler<void(bool success)>&&) = 0; 56 virtual void hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&) = 0; 57 virtual void isMuted(CompletionHandler<void(std::optional<bool>&&)>&&) = 0; 58 virtual void setIsMuted(bool, CompletionHandler<void(bool success)>&&) = 0; 56 59 }; 57 60 -
trunk/Source/WebCore/Modules/model-element/dummy/DummyModelPlayer.cpp
r286048 r286065 87 87 } 88 88 89 void DummyModelPlayer::hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&) 90 { 89 91 } 92 93 void DummyModelPlayer::isMuted(CompletionHandler<void(std::optional<bool>&&)>&&) 94 { 95 } 96 97 void DummyModelPlayer::setIsMuted(bool, CompletionHandler<void(bool success)>&&) 98 { 99 } 100 101 } -
trunk/Source/WebCore/Modules/model-element/dummy/DummyModelPlayer.h
r286048 r286065 52 52 void isPlayingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) override; 53 53 void setAnimationIsPlaying(bool, CompletionHandler<void(bool success)>&&) override; 54 void hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&) override; 55 void isMuted(CompletionHandler<void(std::optional<bool>&&)>&&) override; 56 void setIsMuted(bool, CompletionHandler<void(bool success)>&&) override; 54 57 55 58 WeakPtr<ModelPlayerClient> m_client; -
trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.h
r286048 r286065 66 66 void isPlayingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) override; 67 67 void setAnimationIsPlaying(bool, CompletionHandler<void(bool success)>&&) override; 68 void hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&) override; 69 void isMuted(CompletionHandler<void(std::optional<bool>&&)>&&) override; 70 void setIsMuted(bool, CompletionHandler<void(bool success)>&&) override; 68 71 69 72 // SceneKitModelLoaderClient overrides. -
trunk/Source/WebCore/Modules/model-element/scenekit/SceneKitModelPlayer.mm
r286048 r286065 105 105 } 106 106 107 void SceneKitModelPlayer::hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&) 108 { 109 } 110 111 void SceneKitModelPlayer::isMuted(CompletionHandler<void(std::optional<bool>&&)>&&) 112 { 113 } 114 115 void SceneKitModelPlayer::setIsMuted(bool, CompletionHandler<void(bool success)>&&) 116 { 117 } 118 107 119 // MARK: - SceneKitModelLoaderClient overrides. 108 120 -
trunk/Source/WebCore/PAL/ChangeLog
r286048 r286065 1 2021-11-19 Antoine Quint <graouts@webkit.org> 2 3 [Model] add audio support 4 https://bugs.webkit.org/show_bug.cgi?id=233365 5 <rdar://problem/85428982> 6 7 Reviewed by Wenson Hsieh. 8 9 Add the new ARQL SPIs we are using for audio control. 10 11 * pal/spi/ios/SystemPreviewSPI.h: 12 * pal/spi/mac/SystemPreviewSPI.h: 13 1 14 2021-11-18 Antoine Quint <graouts@webkit.org> 2 15 -
trunk/Source/WebCore/PAL/pal/spi/ios/SystemPreviewSPI.h
r286048 r286065 113 113 - (void)setIsPlaying:(BOOL)isPlaying reply:(ASVSetIsPlayingReplyBlock)reply; 114 114 115 @property (nonatomic, readonly) BOOL hasAudio; 116 @property (nonatomic, readwrite) BOOL isMuted; 117 115 118 @end 116 119 -
trunk/Source/WebCore/PAL/pal/spi/mac/SystemPreviewSPI.h
r286048 r286065 63 63 - (void)setIsPlaying:(BOOL)isPlaying reply:(ASVSetIsPlayingReplyBlock)reply; 64 64 65 @property (nonatomic, readonly) BOOL hasAudio; 66 @property (nonatomic, readwrite) BOOL isMuted; 67 65 68 @end 66 69 -
trunk/Source/WebKit/ChangeLog
r286048 r286065 1 2021-11-19 Antoine Quint <graouts@webkit.org> 2 3 [Model] add audio support 4 https://bugs.webkit.org/show_bug.cgi?id=233365 5 <rdar://problem/85428982> 6 7 Reviewed by Wenson Hsieh. 8 9 Expose new WebPageProxy messages to let the WebProcess message the UIProcess 10 to call into ASVInlinePreview methods to get and set the muted state and get 11 whehter the model contains audio. 12 13 * UIProcess/Cocoa/ModelElementControllerCocoa.mm: 14 (WebKit::previewHasAudioSupport): 15 (WebKit::ModelElementController::hasAudioForModelElement): 16 (WebKit::ModelElementController::isMutedForModelElement): 17 (WebKit::ModelElementController::setIsMutedForModelElement): 18 * UIProcess/ModelElementController.h: 19 * UIProcess/WebPageProxy.cpp: 20 (WebKit::WebPageProxy::modelElementHasAudio): 21 (WebKit::WebPageProxy::modelElementIsMuted): 22 (WebKit::WebPageProxy::modelElementSetIsMuted): 23 * UIProcess/WebPageProxy.h: 24 * UIProcess/WebPageProxy.messages.in: 25 * WebProcess/Model/ARKitInlinePreviewModelPlayer.h: 26 * WebProcess/Model/ARKitInlinePreviewModelPlayer.mm: 27 (WebKit::ARKitInlinePreviewModelPlayer::hasAudio): 28 (WebKit::ARKitInlinePreviewModelPlayer::isMuted): 29 (WebKit::ARKitInlinePreviewModelPlayer::setIsMuted): 30 1 31 2021-11-18 Antoine Quint <graouts@webkit.org> 2 32 -
trunk/Source/WebKit/UIProcess/Cocoa/ModelElementControllerCocoa.mm
r286048 r286065 360 360 } 361 361 362 #endif 363 364 } 365 366 #endif 362 static bool previewHasAudioSupport(ASVInlinePreview *preview) 363 { 364 #if ENABLE(ARKIT_INLINE_PREVIEW_AUDIO_CONTROL) 365 return [preview respondsToSelector:@selector(hasAudio)]; 366 #else 367 return false; 368 #endif 369 } 370 371 void ModelElementController::hasAudioForModelElement(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&& completionHandler) 372 { 373 auto* preview = previewForModelIdentifier(modelIdentifier); 374 if (!previewHasAudioSupport(preview)) { 375 completionHandler(makeUnexpected(WebCore::ResourceError { WebCore::ResourceError::Type::General })); 376 return; 377 } 378 379 #if ENABLE(ARKIT_INLINE_PREVIEW_AUDIO_CONTROL) 380 completionHandler([preview hasAudio]); 381 #else 382 ASSERT_NOT_REACHED(); 383 #endif 384 } 385 386 void ModelElementController::isMutedForModelElement(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&& completionHandler) 387 { 388 auto* preview = previewForModelIdentifier(modelIdentifier); 389 if (!previewHasAudioSupport(preview)) { 390 completionHandler(makeUnexpected(WebCore::ResourceError { WebCore::ResourceError::Type::General })); 391 return; 392 } 393 394 #if ENABLE(ARKIT_INLINE_PREVIEW_AUDIO_CONTROL) 395 completionHandler([preview isMuted]); 396 #else 397 ASSERT_NOT_REACHED(); 398 #endif 399 } 400 401 void ModelElementController::setIsMutedForModelElement(ModelIdentifier modelIdentifier, bool isMuted, CompletionHandler<void(bool)>&& completionHandler) 402 { 403 auto* preview = previewForModelIdentifier(modelIdentifier); 404 if (!previewHasAudioSupport(preview)) { 405 completionHandler(false); 406 return; 407 } 408 409 #if ENABLE(ARKIT_INLINE_PREVIEW_AUDIO_CONTROL) 410 preview.isMuted = isMuted; 411 completionHandler(true); 412 #else 413 ASSERT_NOT_REACHED(); 414 #endif 415 } 416 417 #endif 418 419 } 420 421 #endif -
trunk/Source/WebKit/UIProcess/ModelElementController.h
r286048 r286065 57 57 void isPlayingAnimationForModelElement(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&); 58 58 void setAnimationIsPlayingForModelElement(ModelIdentifier, bool, CompletionHandler<void(bool)>&&); 59 void hasAudioForModelElement(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&); 60 void isMutedForModelElement(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&); 61 void setIsMutedForModelElement(ModelIdentifier, bool, CompletionHandler<void(bool)>&&); 59 62 #endif 60 63 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS) -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r286048 r286065 10853 10853 modelElementController()->setAnimationIsPlayingForModelElement(modelIdentifier, isPlaying, WTFMove(completionHandler)); 10854 10854 } 10855 10856 void WebPageProxy::modelElementHasAudio(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<bool, ResourceError>)>&& completionHandler) 10857 { 10858 modelElementController()->hasAudioForModelElement(modelIdentifier, WTFMove(completionHandler)); 10859 } 10860 10861 void WebPageProxy::modelElementIsMuted(ModelIdentifier modelIdentifier, CompletionHandler<void(Expected<bool, ResourceError>)>&& completionHandler) 10862 { 10863 modelElementController()->isMutedForModelElement(modelIdentifier, WTFMove(completionHandler)); 10864 } 10865 10866 void WebPageProxy::modelElementSetIsMuted(ModelIdentifier modelIdentifier, bool isMuted, CompletionHandler<void(bool)>&& completionHandler) 10867 { 10868 modelElementController()->setIsMutedForModelElement(modelIdentifier, isMuted, WTFMove(completionHandler)); 10869 } 10855 10870 #endif 10856 10871 -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r286048 r286065 593 593 void modelElementIsPlayingAnimation(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&); 594 594 void modelElementSetAnimationIsPlaying(ModelIdentifier, bool, CompletionHandler<void(bool)>&&); 595 void modelElementHasAudio(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&); 596 void modelElementIsMuted(ModelIdentifier, CompletionHandler<void(Expected<bool, WebCore::ResourceError>)>&&); 597 void modelElementSetIsMuted(ModelIdentifier, bool, CompletionHandler<void(bool)>&&); 595 598 #endif 596 599 #if ENABLE(ARKIT_INLINE_PREVIEW_IOS) -
trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in
r286048 r286065 600 600 ModelElementIsPlayingAnimation(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<bool, WebCore::ResourceError> result) Async 601 601 ModelElementSetAnimationIsPlaying(struct WebKit::ModelIdentifier modelIdentifier, bool isPlaying) -> (bool success) Async 602 ModelElementHasAudio(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<bool, WebCore::ResourceError> result) Async 603 ModelElementIsMuted(struct WebKit::ModelIdentifier modelIdentifier) -> (Expected<bool, WebCore::ResourceError> result) Async 604 ModelElementSetIsMuted(struct WebKit::ModelIdentifier modelIdentifier, bool isMuted) -> (bool success) Async 602 605 #endif 603 606 -
trunk/Source/WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.h
r286048 r286065 58 58 void isPlayingAnimation(CompletionHandler<void(std::optional<bool>&&)>&&) override; 59 59 void setAnimationIsPlaying(bool, CompletionHandler<void(bool success)>&&) override; 60 void hasAudio(CompletionHandler<void(std::optional<bool>&&)>&&) override; 61 void isMuted(CompletionHandler<void(std::optional<bool>&&)>&&) override; 62 void setIsMuted(bool, CompletionHandler<void(bool success)>&&) override; 60 63 61 64 WeakPtr<WebPage> m_page; -
trunk/Source/WebKit/WebProcess/Model/ARKitInlinePreviewModelPlayer.mm
r286048 r286065 150 150 } 151 151 152 void ARKitInlinePreviewModelPlayer::hasAudio(CompletionHandler<void(std::optional<bool>&&)>&& completionHandler) 153 { 154 auto modelIdentifier = this->modelIdentifier(); 155 if (!modelIdentifier) { 156 completionHandler(std::nullopt); 157 return; 158 } 159 160 RefPtr strongPage = m_page.get(); 161 if (!strongPage) { 162 completionHandler(std::nullopt); 163 return; 164 } 165 166 CompletionHandler<void(Expected<bool, WebCore::ResourceError>)> remoteCompletionHandler = [completionHandler = WTFMove(completionHandler)] (Expected<bool, WebCore::ResourceError> result) mutable { 167 if (!result) { 168 completionHandler(std::nullopt); 169 return; 170 } 171 172 completionHandler(*result); 173 }; 174 175 strongPage->sendWithAsyncReply(Messages::WebPageProxy::ModelElementHasAudio(*modelIdentifier), WTFMove(remoteCompletionHandler)); 176 } 177 178 void ARKitInlinePreviewModelPlayer::isMuted(CompletionHandler<void(std::optional<bool>&&)>&& completionHandler) 179 { 180 auto modelIdentifier = this->modelIdentifier(); 181 if (!modelIdentifier) { 182 completionHandler(std::nullopt); 183 return; 184 } 185 186 RefPtr strongPage = m_page.get(); 187 if (!strongPage) { 188 completionHandler(std::nullopt); 189 return; 190 } 191 192 CompletionHandler<void(Expected<bool, WebCore::ResourceError>)> remoteCompletionHandler = [completionHandler = WTFMove(completionHandler)] (Expected<bool, WebCore::ResourceError> result) mutable { 193 if (!result) { 194 completionHandler(std::nullopt); 195 return; 196 } 197 198 completionHandler(*result); 199 }; 200 201 strongPage->sendWithAsyncReply(Messages::WebPageProxy::ModelElementIsMuted(*modelIdentifier), WTFMove(remoteCompletionHandler)); 202 } 203 204 void ARKitInlinePreviewModelPlayer::setIsMuted(bool isMuted, CompletionHandler<void(bool success)>&& completionHandler) 205 { 206 auto modelIdentifier = this->modelIdentifier(); 207 if (!modelIdentifier) { 208 completionHandler(false); 209 return; 210 } 211 212 RefPtr strongPage = m_page.get(); 213 if (!strongPage) { 214 completionHandler(false); 215 return; 216 } 217 218 CompletionHandler<void(bool)> remoteCompletionHandler = [completionHandler = WTFMove(completionHandler)] (bool success) mutable { 219 completionHandler(success); 220 }; 221 222 strongPage->sendWithAsyncReply(Messages::WebPageProxy::ModelElementSetIsMuted(*modelIdentifier, isMuted), WTFMove(remoteCompletionHandler)); 223 } 224 152 225 } 153 226
Note: See TracChangeset
for help on using the changeset viewer.