Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nanocolor: fix namespace and symbol leaks #3281

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions pxr/base/gf/nc/nanocolor.c
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,7 @@ NcM33f NcGetXYZToRGBMatrix(const NcColorSpace* cs) {
return NcM3ffInvert(NcGetRGBToXYZMatrix(cs));
}

NcM33f GetRGBtoRGBMatrix(const NcColorSpace* src, const NcColorSpace* dst) {
static NcM33f GetRGBtoRGBMatrix(const NcColorSpace* src, const NcColorSpace* dst) {
NcM33f t = NcM33fMultiply(NcM3ffInvert(NcGetRGBToXYZMatrix(src)),
NcGetXYZToRGBMatrix(dst));
return t;
Expand Down Expand Up @@ -803,7 +803,7 @@ void NcTransformColorsWithAlpha(const NcColorSpace* dst, const NcColorSpace* src
}
}

NcRGB NcNormalizeLuminance(const NcColorSpace* cs, NcRGB rgb, float luminance) {
static NcRGB NcNormalizeLuminance(const NcColorSpace* cs, NcRGB rgb, float luminance) {
if (!cs)
return rgb;

Expand Down Expand Up @@ -945,7 +945,7 @@ typedef struct {
float v;
} NcYuvPrime;

NcYxy _NcYuv2Yxy(NcYuvPrime c) {
static NcYxy _NcYuv2Yxy(NcYuvPrime c) {
float d = 6.f * c.u - 16.f * c.v + 12.f;
return (NcYxy) {
c.Y,
Expand All @@ -969,7 +969,7 @@ NcYxy NcKelvinToYxy(float T, float luminance) {
return _NcYuv2Yxy((NcYuvPrime) {luminance, u, 3.f * v / 2.f });
}

NcYxy NcNormalizeYxy(NcYxy c) {
static NcYxy NcNormalizeYxy(NcYxy c) {
return (NcYxy) {
c.Y,
c.Y * c.x / c.y,
Expand Down
7 changes: 3 additions & 4 deletions pxr/base/gf/nc/nanocolor.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
#include <stdbool.h>
#include <stddef.h>

#include "pxr/pxr.h"

// NCNAMESPACE is allows the introduction of a namespace to the symbols so that
// multiple libraries can include the nanocolor library without symbol
// conflicts. The default is nc_1_0_ to indicate the 1.0 version of Nanocolor.
//
// pxr: note that the PXR namespace macros are in pxr/pxr.h which
// is a C++ only header; so the generated namespace prefixes can't be
// used here.
#ifndef NCNAMESPACE
#define NCNAMESPACE pxr_nc_1_0_
#define NCNAMESPACE PXR_NS
#endif

// The NCCONCAT macro is used to apply a namespace to the symbols in the public
Expand Down
4 changes: 4 additions & 0 deletions pxr/pxr.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@
#define PXR_INTERNAL_NS @PXR_INTERNAL_NAMESPACE@__pxrReserved__
#define PXR_NS_GLOBAL ::PXR_NS

#ifdef __cplusplus

namespace PXR_INTERNAL_NS { }

// The root level namespace for all source in the USD distribution.
namespace PXR_NS {
using namespace PXR_INTERNAL_NS;
}

#endif

#define PXR_NAMESPACE_OPEN_SCOPE namespace PXR_INTERNAL_NS {
#define PXR_NAMESPACE_CLOSE_SCOPE }
#define PXR_NAMESPACE_USING_DIRECTIVE using namespace PXR_NS;
Expand Down