Add Chromium-only Blender WebEngine parity work

This commit is contained in:
mes123456
2026-08-12 04:47:48 -04:00
commit 9fd26010f6
18225 changed files with 11622124 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
/* SPDX-FileCopyrightText: 2020 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef OPENSUBDIV_BASE_MEMORY_H_
#define OPENSUBDIV_BASE_MEMORY_H_
#include "MEM_guardedalloc.h"
namespace blender::opensubdiv {
} // namespace blender::opensubdiv
#endif // OPENSUBDIV_BASE_MEMORY_H_

View File

@@ -0,0 +1,39 @@
/* SPDX-FileCopyrightText: 2013 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "opensubdiv_capi.hh"
#include "opensubdiv/version.h"
#ifdef _MSC_VER
# include <iso646.h>
#endif
void openSubdiv_init() {}
void openSubdiv_cleanup() {}
int openSubdiv_getVersionHex()
{
#if defined(OPENSUBDIV_VERSION_NUMBER)
return OPENSUBDIV_VERSION_NUMBER;
#elif defined(OPENSUBDIV_VERSION_MAJOR)
return OPENSUBDIV_VERSION_MAJOR * 10000 + OPENSUBDIV_VERSION_MINOR * 100 +
OPENSUBDIV_VERSION_PATCH;
#elif defined(OPENSUBDIV_VERSION)
const char *version = STRINGIFY(OPENSUBDIV_VERSION);
if (version[0] == 'v') {
version += 1;
}
int major = 0, minor = 0, patch = 0;
vector<string> tokens;
blender::opensubdiv::stringSplit(&tokens, version, "_", true);
if (tokens.size() == 3) {
major = atoi(tokens[0].c_str());
minor = atoi(tokens[1].c_str());
patch = atoi(tokens[2].c_str());
}
return major * 10000 + minor * 100 + patch;
#else
return 0;
#endif
}

View File

@@ -0,0 +1,93 @@
/* SPDX-FileCopyrightText: 2018 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Author: Sergey Sharybin. */
#ifdef _MSC_VER
# include <iso646.h>
#endif
#include "internal/base/type_convert.h"
#include <cassert>
#include <opensubdiv/sdc/crease.h>
namespace blender::opensubdiv {
OpenSubdiv::Sdc::SchemeType getSchemeTypeFromCAPI(OpenSubdiv_SchemeType type)
{
switch (type) {
case OSD_SCHEME_BILINEAR:
return OpenSubdiv::Sdc::SCHEME_BILINEAR;
case OSD_SCHEME_CATMARK:
return OpenSubdiv::Sdc::SCHEME_CATMARK;
case OSD_SCHEME_LOOP:
return OpenSubdiv::Sdc::SCHEME_LOOP;
}
assert(!"Unknown scheme type passed via C-API");
return OpenSubdiv::Sdc::SCHEME_CATMARK;
}
OpenSubdiv::Sdc::Options::FVarLinearInterpolation getFVarLinearInterpolationFromCAPI(
OpenSubdiv_FVarLinearInterpolation linear_interpolation)
{
using Options = OpenSubdiv::Sdc::Options;
switch (linear_interpolation) {
case OSD_FVAR_LINEAR_INTERPOLATION_NONE:
return Options::FVAR_LINEAR_NONE;
case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY:
return Options::FVAR_LINEAR_CORNERS_ONLY;
case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS1:
return Options::FVAR_LINEAR_CORNERS_PLUS1;
case OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS2:
return Options::FVAR_LINEAR_CORNERS_PLUS2;
case OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES:
return Options::FVAR_LINEAR_BOUNDARIES;
case OSD_FVAR_LINEAR_INTERPOLATION_ALL:
return Options::FVAR_LINEAR_ALL;
}
assert(!"Unknown fvar linear interpolation passed via C-API");
return Options::FVAR_LINEAR_NONE;
}
OpenSubdiv_FVarLinearInterpolation getCAPIFVarLinearInterpolationFromOSD(
OpenSubdiv::Sdc::Options::FVarLinearInterpolation linear_interpolation)
{
using Options = OpenSubdiv::Sdc::Options;
switch (linear_interpolation) {
case Options::FVAR_LINEAR_NONE:
return OSD_FVAR_LINEAR_INTERPOLATION_NONE;
case Options::FVAR_LINEAR_CORNERS_ONLY:
return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_ONLY;
case Options::FVAR_LINEAR_CORNERS_PLUS1:
return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS1;
case Options::FVAR_LINEAR_CORNERS_PLUS2:
return OSD_FVAR_LINEAR_INTERPOLATION_CORNERS_PLUS2;
case Options::FVAR_LINEAR_BOUNDARIES:
return OSD_FVAR_LINEAR_INTERPOLATION_BOUNDARIES;
case Options::FVAR_LINEAR_ALL:
return OSD_FVAR_LINEAR_INTERPOLATION_ALL;
}
assert(!"Unknown fvar linear interpolation passed via C-API");
return OSD_FVAR_LINEAR_INTERPOLATION_NONE;
}
OpenSubdiv::Sdc::Options::VtxBoundaryInterpolation getVtxBoundaryInterpolationFromCAPI(
OpenSubdiv_VtxBoundaryInterpolation boundary_interpolation)
{
using OpenSubdiv::Sdc::Options;
switch (boundary_interpolation) {
case OSD_VTX_BOUNDARY_NONE:
return Options::VTX_BOUNDARY_NONE;
case OSD_VTX_BOUNDARY_EDGE_ONLY:
return Options::VTX_BOUNDARY_EDGE_ONLY;
case OSD_VTX_BOUNDARY_EDGE_AND_CORNER:
return Options::VTX_BOUNDARY_EDGE_AND_CORNER;
}
assert(!"Unknown veretx boundary interpolation.");
return Options::VTX_BOUNDARY_EDGE_ONLY;
}
} // namespace blender::opensubdiv

View File

@@ -0,0 +1,40 @@
/* SPDX-FileCopyrightText: 2018 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* Author: Sergey Sharybin. */
#ifndef OPENSUBDIV_BASE_TYPE_CONVERT_H_
#define OPENSUBDIV_BASE_TYPE_CONVERT_H_
#ifdef _MSC_VER
# include <iso646.h>
#endif
#include <opensubdiv/sdc/options.h>
#include <opensubdiv/sdc/types.h>
#include "opensubdiv_capi_type.hh"
struct OpenSubdiv_Converter;
namespace blender::opensubdiv {
// Convert scheme type from C-API enum to an OpenSubdiv native enum.
OpenSubdiv::Sdc::SchemeType getSchemeTypeFromCAPI(OpenSubdiv_SchemeType type);
// Convert face-varying interpolation type from C-API to an OpenSubdiv
// native enum.
OpenSubdiv::Sdc::Options::FVarLinearInterpolation getFVarLinearInterpolationFromCAPI(
OpenSubdiv_FVarLinearInterpolation linear_interpolation);
// Similar to above, just other way around.
OpenSubdiv_FVarLinearInterpolation getCAPIFVarLinearInterpolationFromOSD(
OpenSubdiv::Sdc::Options::FVarLinearInterpolation linear_interpolation);
OpenSubdiv::Sdc::Options::VtxBoundaryInterpolation getVtxBoundaryInterpolationFromCAPI(
OpenSubdiv_VtxBoundaryInterpolation boundary_interpolation);
} // namespace blender::opensubdiv
#endif // OPENSUBDIV_BASE_TYPE_CONVERT_H_

View File

@@ -0,0 +1,41 @@
/* SPDX-FileCopyrightText: 2013 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#include "internal/base/util.h"
namespace blender::opensubdiv {
void stringSplit(std::vector<std::string> *tokens,
const std::string &str,
const std::string &separators,
bool skip_empty)
{
size_t token_start = 0, token_length = 0;
for (size_t i = 0; i < str.length(); ++i) {
const char ch = str[i];
if (separators.find(ch) == std::string::npos) {
// Append non-separator char to a token.
++token_length;
}
else {
// Append current token to the list (if any).
if (token_length > 0 || !skip_empty) {
std::string token = str.substr(token_start, token_length);
tokens->push_back(token);
}
// Re-set token pointers.
token_start = i + 1;
token_length = 0;
}
}
// Append token which might be at the end of the std::string.
if ((token_length != 0) || (!skip_empty && token_start > 0 &&
separators.find(str[token_start - 1]) != std::string::npos))
{
std::string token = str.substr(token_start, token_length);
tokens->push_back(token);
}
}
} // namespace blender::opensubdiv

View File

@@ -0,0 +1,20 @@
/* SPDX-FileCopyrightText: 2013 Blender Foundation
*
* SPDX-License-Identifier: GPL-2.0-or-later */
#ifndef OPENSUBDIV_BASE_UTIL_H_
#define OPENSUBDIV_BASE_UTIL_H_
#include <string>
#include <vector>
namespace blender::opensubdiv {
void stringSplit(std::vector<std::string> *tokens,
const std::string &str,
const std::string &separators,
bool skip_empty);
} // namespace blender::opensubdiv
#endif // OPENSUBDIV_BASE_UTIL_H_