| 1 | /* |
| 2 | This file is part of the WebKit open source project. |
| 3 | This file has been generated by generate-bindings.pl. DO NOT MODIFY! |
| 4 | |
| 5 | This library is free software; you can redistribute it and/or |
| 6 | modify it under the terms of the GNU Library General Public |
| 7 | License as published by the Free Software Foundation; either |
| 8 | version 2 of the License, or (at your option) any later version. |
| 9 | |
| 10 | This library is distributed in the hope that it will be useful, |
| 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 | Library General Public License for more details. |
| 14 | |
| 15 | You should have received a copy of the GNU Library General Public License |
| 16 | along with this library; see the file COPYING.LIB. If not, write to |
| 17 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 | Boston, MA 02110-1301, USA. |
| 19 | */ |
| 20 | |
| 21 | #include "config.h" |
| 22 | |
| 23 | #if ENABLE(WEBGPU) |
| 24 | |
| 25 | #include "JSGPUTextureFormat.h" |
| 26 | |
| 27 | #include <JavaScriptCore/JSCInlines.h> |
| 28 | #include <JavaScriptCore/JSString.h> |
| 29 | #include <wtf/NeverDestroyed.h> |
| 30 | |
| 31 | |
| 32 | namespace WebCore { |
| 33 | using namespace JSC; |
| 34 | |
| 35 | String convertEnumerationToString(GPUTextureFormat enumerationValue) |
| 36 | { |
| 37 | static const NeverDestroyed<String> values[] = { |
| 38 | MAKE_STATIC_STRING_IMPL("rgba8unorm" ), |
| 39 | MAKE_STATIC_STRING_IMPL("rgba8uint" ), |
| 40 | MAKE_STATIC_STRING_IMPL("bgra8unorm" ), |
| 41 | MAKE_STATIC_STRING_IMPL("depth32float-stencil8" ), |
| 42 | MAKE_STATIC_STRING_IMPL("bgra8unorm-srgb" ), |
| 43 | MAKE_STATIC_STRING_IMPL("rgba16float" ), |
| 44 | }; |
| 45 | static_assert(static_cast<size_t>(GPUTextureFormat::Rgba8unorm) == 0, "GPUTextureFormat::Rgba8unorm is not 0 as expected" ); |
| 46 | static_assert(static_cast<size_t>(GPUTextureFormat::Rgba8uint) == 1, "GPUTextureFormat::Rgba8uint is not 1 as expected" ); |
| 47 | static_assert(static_cast<size_t>(GPUTextureFormat::Bgra8unorm) == 2, "GPUTextureFormat::Bgra8unorm is not 2 as expected" ); |
| 48 | static_assert(static_cast<size_t>(GPUTextureFormat::Depth32floatStencil8) == 3, "GPUTextureFormat::Depth32floatStencil8 is not 3 as expected" ); |
| 49 | static_assert(static_cast<size_t>(GPUTextureFormat::Bgra8unormSRGB) == 4, "GPUTextureFormat::Bgra8unormSRGB is not 4 as expected" ); |
| 50 | static_assert(static_cast<size_t>(GPUTextureFormat::Rgba16float) == 5, "GPUTextureFormat::Rgba16float is not 5 as expected" ); |
| 51 | ASSERT(static_cast<size_t>(enumerationValue) < WTF_ARRAY_LENGTH(values)); |
| 52 | return values[static_cast<size_t>(enumerationValue)]; |
| 53 | } |
| 54 | |
| 55 | template<> JSString* convertEnumerationToJS(ExecState& state, GPUTextureFormat enumerationValue) |
| 56 | { |
| 57 | return jsStringWithCache(&state, convertEnumerationToString(enumerationValue)); |
| 58 | } |
| 59 | |
| 60 | template<> Optional<GPUTextureFormat> parseEnumeration<GPUTextureFormat>(ExecState& state, JSValue value) |
| 61 | { |
| 62 | auto stringValue = value.toWTFString(&state); |
| 63 | if (stringValue == "rgba8unorm" ) |
| 64 | return GPUTextureFormat::Rgba8unorm; |
| 65 | if (stringValue == "rgba8uint" ) |
| 66 | return GPUTextureFormat::Rgba8uint; |
| 67 | if (stringValue == "bgra8unorm" ) |
| 68 | return GPUTextureFormat::Bgra8unorm; |
| 69 | if (stringValue == "depth32float-stencil8" ) |
| 70 | return GPUTextureFormat::Depth32floatStencil8; |
| 71 | if (stringValue == "bgra8unorm-srgb" ) |
| 72 | return GPUTextureFormat::Bgra8unormSRGB; |
| 73 | if (stringValue == "rgba16float" ) |
| 74 | return GPUTextureFormat::Rgba16float; |
| 75 | return WTF::nullopt; |
| 76 | } |
| 77 | |
| 78 | template<> const char* expectedEnumerationValues<GPUTextureFormat>() |
| 79 | { |
| 80 | return "\"rgba8unorm\", \"rgba8uint\", \"bgra8unorm\", \"depth32float-stencil8\", \"bgra8unorm-srgb\", \"rgba16float\"" ; |
| 81 | } |
| 82 | |
| 83 | } // namespace WebCore |
| 84 | |
| 85 | #endif // ENABLE(WEBGPU) |
| 86 | |