IWithFallbackTextureData.cs 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // Copyright (c) 2024 Vuplex Inc. All rights reserved.
  2. //
  3. // Licensed under the Vuplex Commercial Software Library License, you may
  4. // not use this file except in compliance with the License. You may obtain
  5. // a copy of the License at
  6. //
  7. // https://vuplex.com/commercial-library-license
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. using System.Threading.Tasks;
  15. namespace Vuplex.WebView {
  16. /// <summary>
  17. /// Implemented by AndroidWebView to provide an alternative to IWebView.GetRawTextureData() that
  18. /// works without the graphics extensions that 3D WebView normally requires on Android
  19. /// (the OpenGL GL_OES_EGL_image_external extension or Vulkan VK_ANDROID_external_memory_android_hardware_buffer extension).
  20. /// </summary>
  21. /// <example>
  22. /// <code>
  23. /// await webViewPrefab.WaitUntilInitialized();
  24. /// var webViewWithFallbackTextureData = webViewPrefab.WebView as IWithFallbackTextureData;
  25. /// if (webViewWithFallbackTextureData == null) {
  26. /// Debug.Log("This 3D WebView plugin doesn't yet support IWithFallbackTextureData: " + webViewPrefab.WebView.PluginType);
  27. /// return;
  28. /// }
  29. /// var textureData = await webViewWithFallbackTextureData.GetFallbackTextureData();
  30. /// var texture = new Texture2D(
  31. /// webViewPrefab.WebView.Size.x,
  32. /// webViewPrefab.WebView.Size.y,
  33. /// TextureFormat.RGBA32,
  34. /// false,
  35. /// false
  36. /// );
  37. /// texture.LoadRawTextureData(textureData);
  38. /// texture.Apply();
  39. /// </code>
  40. /// </example>
  41. public interface IWithFallbackTextureData {
  42. /// <summary>
  43. /// Like IWebView.GetRawTextureData(), except it has the following differences: <br/>
  44. /// - It works without the graphics extensions that 3D WebView normally requires on Android
  45. /// (the OpenGL GL_OES_EGL_image_external extension or Vulkan VK_ANDROID_external_memory_android_hardware_buffer extension). <br/>
  46. /// - It doesn't capture hardware accelerated content like video or WebGL.
  47. /// </summary>
  48. Task<byte[]> GetFallbackTextureData();
  49. }
  50. }