Loading services/camera/virtualcamera/util/EglUtil.cc +18 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <cstring> #include "EglDisplayContext.h" #include "GLES/gl.h" #include "log/log.h" Loading @@ -27,6 +28,9 @@ namespace android { namespace companion { namespace virtualcamera { // Lower bound for maximum supported texture size is at least 2048x2048 constexpr int kDefaultMaxTextureSize = 2048; bool checkEglError(const char* operation) { GLenum err = glGetError(); if (err == GL_NO_ERROR) { Loading @@ -45,6 +49,20 @@ bool isGlExtensionSupported(const char* extension) { return strstr(extensions, extension) != nullptr; } int getMaximumTextureSize() { static const int kMaxTextureSize = [] { EglDisplayContext displayContext; displayContext.makeCurrent(); int maxTextureSize = -1; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); return maxTextureSize; }(); if (kMaxTextureSize <= 0) { return kDefaultMaxTextureSize; } return kMaxTextureSize; } } // namespace virtualcamera } // namespace companion } // namespace android services/camera/virtualcamera/util/EglUtil.h +2 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ bool checkEglError(const char* operation = "EGL operation"); // Returns true if the GL extension is supported, false otherwise. bool isGlExtensionSupported(const char* extension); int getMaximumTextureSize(); } // namespace virtualcamera } // namespace companion } // namespace android Loading services/camera/virtualcamera/util/Util.cc +4 −7 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <cstdint> #include <memory> #include "EglUtil.h" #include "android/hardware_buffer.h" #include "jpeglib.h" #include "ui/GraphicBuffer.h" Loading @@ -35,11 +36,6 @@ namespace virtualcamera { using ::aidl::android::companion::virtualcamera::Format; using ::aidl::android::hardware::common::NativeHandle; // Lower bound for maximal supported texture size is at least 2048x2048 // but on most platforms will be more. // TODO(b/301023410) - Query actual max texture size. constexpr int kMaxTextureSize = 2048; constexpr int kLibJpegDctSize = DCTSIZE; constexpr int kMaxFpsUpperLimit = 60; constexpr std::array<Format, 2> kSupportedFormats{Format::YUV_420_888, Loading Loading @@ -141,8 +137,9 @@ bool isFormatSupportedForInput(const int width, const int height, return false; } if (width <= 0 || height <= 0 || width > kMaxTextureSize || height > kMaxTextureSize) { int maxTextureSize = getMaximumTextureSize(); if (width <= 0 || height <= 0 || width > maxTextureSize || height > maxTextureSize) { return false; } Loading Loading
services/camera/virtualcamera/util/EglUtil.cc +18 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ #include <cstring> #include "EglDisplayContext.h" #include "GLES/gl.h" #include "log/log.h" Loading @@ -27,6 +28,9 @@ namespace android { namespace companion { namespace virtualcamera { // Lower bound for maximum supported texture size is at least 2048x2048 constexpr int kDefaultMaxTextureSize = 2048; bool checkEglError(const char* operation) { GLenum err = glGetError(); if (err == GL_NO_ERROR) { Loading @@ -45,6 +49,20 @@ bool isGlExtensionSupported(const char* extension) { return strstr(extensions, extension) != nullptr; } int getMaximumTextureSize() { static const int kMaxTextureSize = [] { EglDisplayContext displayContext; displayContext.makeCurrent(); int maxTextureSize = -1; glGetIntegerv(GL_MAX_TEXTURE_SIZE, &maxTextureSize); return maxTextureSize; }(); if (kMaxTextureSize <= 0) { return kDefaultMaxTextureSize; } return kMaxTextureSize; } } // namespace virtualcamera } // namespace companion } // namespace android
services/camera/virtualcamera/util/EglUtil.h +2 −0 Original line number Diff line number Diff line Loading @@ -27,6 +27,8 @@ bool checkEglError(const char* operation = "EGL operation"); // Returns true if the GL extension is supported, false otherwise. bool isGlExtensionSupported(const char* extension); int getMaximumTextureSize(); } // namespace virtualcamera } // namespace companion } // namespace android Loading
services/camera/virtualcamera/util/Util.cc +4 −7 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ #include <cstdint> #include <memory> #include "EglUtil.h" #include "android/hardware_buffer.h" #include "jpeglib.h" #include "ui/GraphicBuffer.h" Loading @@ -35,11 +36,6 @@ namespace virtualcamera { using ::aidl::android::companion::virtualcamera::Format; using ::aidl::android::hardware::common::NativeHandle; // Lower bound for maximal supported texture size is at least 2048x2048 // but on most platforms will be more. // TODO(b/301023410) - Query actual max texture size. constexpr int kMaxTextureSize = 2048; constexpr int kLibJpegDctSize = DCTSIZE; constexpr int kMaxFpsUpperLimit = 60; constexpr std::array<Format, 2> kSupportedFormats{Format::YUV_420_888, Loading Loading @@ -141,8 +137,9 @@ bool isFormatSupportedForInput(const int width, const int height, return false; } if (width <= 0 || height <= 0 || width > kMaxTextureSize || height > kMaxTextureSize) { int maxTextureSize = getMaximumTextureSize(); if (width <= 0 || height <= 0 || width > maxTextureSize || height > maxTextureSize) { return false; } Loading