Skip to content

Commit

Permalink
Remap full enum names
Browse files Browse the repository at this point in the history
  • Loading branch information
kyamagu committed Apr 21, 2020
1 parent c8b623e commit 8f34e6b
Show file tree
Hide file tree
Showing 20 changed files with 471 additions and 407 deletions.
4 changes: 2 additions & 2 deletions notebooks/Canvas-Creation.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
"- [Raster](#Raster) - CPU-only.\n",
"- [GPU](#GPU) - Skia's GPU-accelerated backend.\n",
"- PDF - PDF document creation.\n",
"- Picture - Skia's display list format.\n",
"- NullCanvas - Useful for testing only.\n",
"- [Picture](#Picture) - Skia's display list format.\n",
"- [NullCanvas](#NullCanvas) - Useful for testing only.\n",
"- XPS - Experimental XPS backend.\n",
"- SVG - Experimental SVG backend.\n",
"\n",
Expand Down
6 changes: 3 additions & 3 deletions notebooks/Canvas-Overview.ipynb

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions notebooks/Path-Overview.ipynb

Large diffs are not rendered by default.

129 changes: 66 additions & 63 deletions src/skia/Canvas.cpp

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions src/skia/Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,35 @@ void initFont(py::module &m) {
py::class_<SkFontStyle> fontstyle(m, "FontStyle");

py::enum_<SkFontStyle::Weight>(fontstyle, "Weight")
.value("kInvisible", SkFontStyle::Weight::kInvisible_Weight)
.value("kThin", SkFontStyle::Weight::kThin_Weight)
.value("kExtraLight", SkFontStyle::Weight::kExtraLight_Weight)
.value("kLight", SkFontStyle::Weight::kLight_Weight)
.value("kNormal", SkFontStyle::Weight::kNormal_Weight)
.value("kMedium", SkFontStyle::Weight::kMedium_Weight)
.value("kSemiBold", SkFontStyle::Weight::kSemiBold_Weight)
.value("kBold", SkFontStyle::Weight::kBold_Weight)
.value("kExtraBold", SkFontStyle::Weight::kExtraBold_Weight)
.value("kBlack", SkFontStyle::Weight::kBlack_Weight)
.value("kExtraBlack", SkFontStyle::Weight::kExtraBlack_Weight)
.value("kInvisible_Weight", SkFontStyle::Weight::kInvisible_Weight)
.value("kThin_Weight", SkFontStyle::Weight::kThin_Weight)
.value("kExtraLight_Weight", SkFontStyle::Weight::kExtraLight_Weight)
.value("kLight_Weight", SkFontStyle::Weight::kLight_Weight)
.value("kNormal_Weight", SkFontStyle::Weight::kNormal_Weight)
.value("kMedium_Weight", SkFontStyle::Weight::kMedium_Weight)
.value("kSemiBold_Weight", SkFontStyle::Weight::kSemiBold_Weight)
.value("kBold_Weight", SkFontStyle::Weight::kBold_Weight)
.value("kExtraBold_Weight", SkFontStyle::Weight::kExtraBold_Weight)
.value("kBlack_Weight", SkFontStyle::Weight::kBlack_Weight)
.value("kExtraBlack_Weight", SkFontStyle::Weight::kExtraBlack_Weight)
.export_values();

py::enum_<SkFontStyle::Width>(fontstyle, "Width")
.value("kUltraCondensed", SkFontStyle::Width::kUltraCondensed_Width)
.value("kExtraCondensed", SkFontStyle::Width::kExtraCondensed_Width)
.value("kCondensed", SkFontStyle::Width::kCondensed_Width)
.value("kSemiCondensed", SkFontStyle::Width::kSemiCondensed_Width)
.value("kNormal", SkFontStyle::Width::kNormal_Width)
.value("kSemiExpanded", SkFontStyle::Width::kSemiExpanded_Width)
.value("kExpanded", SkFontStyle::Width::kExpanded_Width)
.value("kExtraExpanded", SkFontStyle::Width::kExtraExpanded_Width)
.value("kUltraExpanded", SkFontStyle::Width::kUltraExpanded_Width)
.value("kUltraCondensed_Width", SkFontStyle::Width::kUltraCondensed_Width)
.value("kExtraCondensed_Width", SkFontStyle::Width::kExtraCondensed_Width)
.value("kCondensed_Width", SkFontStyle::Width::kCondensed_Width)
.value("kSemiCondensed_Width", SkFontStyle::Width::kSemiCondensed_Width)
.value("kNormal_Width", SkFontStyle::Width::kNormal_Width)
.value("kSemiExpanded_Width", SkFontStyle::Width::kSemiExpanded_Width)
.value("kExpanded_Width", SkFontStyle::Width::kExpanded_Width)
.value("kExtraExpanded_Width", SkFontStyle::Width::kExtraExpanded_Width)
.value("kUltraExpanded_Width", SkFontStyle::Width::kUltraExpanded_Width)
.export_values();

py::enum_<SkFontStyle::Slant>(fontstyle, "Slant")
.value("kUpright", SkFontStyle::Slant::kUpright_Slant)
.value("kItalic", SkFontStyle::Slant::kItalic_Slant)
.value("kOblique", SkFontStyle::Slant::kOblique_Slant)
.value("kUpright_Slant", SkFontStyle::Slant::kUpright_Slant)
.value("kItalic_Slant", SkFontStyle::Slant::kItalic_Slant)
.value("kOblique_Slant", SkFontStyle::Slant::kOblique_Slant)
.export_values();

fontstyle
Expand Down Expand Up @@ -552,16 +552,16 @@ py::enum_<SkFontMetrics::FontMetricsFlags>(fontmetrics, "FontMetricsFlags",
Fonts with embedded bitmaps may not have valid underline or strikeout
metrics.
)docstring")
.value("kUnderlineThicknessIsValid",
.value("kUnderlineThicknessIsValid_Flag",
SkFontMetrics::FontMetricsFlags::kUnderlineThicknessIsValid_Flag,
"set if fUnderlineThickness is valid")
.value("kUnderlinePositionIsValid",
.value("kUnderlinePositionIsValid_Flag",
SkFontMetrics::FontMetricsFlags::kUnderlinePositionIsValid_Flag,
"set if fUnderlinePosition is valid")
.value("kStrikeoutThicknessIsValid",
.value("kStrikeoutThicknessIsValid_Flag",
SkFontMetrics::FontMetricsFlags::kStrikeoutThicknessIsValid_Flag,
"set if fStrikeoutThickness is valid")
.value("kStrikeoutPositionIsValid",
.value("kStrikeoutPositionIsValid_Flag",
SkFontMetrics::FontMetricsFlags::kStrikeoutPositionIsValid_Flag,
"set if fStrikeoutPosition is valid")
.export_values();
Expand Down
54 changes: 35 additions & 19 deletions src/skia/GrContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ py::enum_<GrBackendApi>(m, "GrBackendApi", R"docstring(
.value("kDirect3D", GrBackendApi::kDirect3D)
.value("kDawn", GrBackendApi::kDawn)
.value("kMock", GrBackendApi::kMock,
"Mock is a backend that does not draw anything. It is used for unit "
"tests and to measure CPU overhead.")
R"docstring(
Mock is a backend that does not draw anything. It is used for unit tests
and to measure CPU overhead.
)docstring")
.value("kOpenGL_GrBackend", GrBackendApi::kOpenGL_GrBackend,
"Added here to support the legacy GrBackend enum value and clients "
"who referenced it using GrBackend::kOpenGL_GrBackend.")
R"docstring(
Added here to support the legacy GrBackend enum value and clients who
referenced it using :py:attr:`~skia.GrBackend.kOpenGL_GrBackend`.
)docstring")
.export_values();

py::enum_<GrMipMapped>(m, "GrMipMapped", R"docstring(
Expand Down Expand Up @@ -49,28 +53,40 @@ py::enum_<GrGLBackendState>(m, "GrGLBackendState", R"docstring(
These enums are specific to the GL backend and we'd add a new set for an
alternative backend.
)docstring")
.value("kRenderTarget", GrGLBackendState::kRenderTarget_GrGLBackendState)
.value("kTextureBinding",
.value("kRenderTarget_GrGLBackendState",
GrGLBackendState::kRenderTarget_GrGLBackendState)
.value("kTextureBinding_GrGLBackendState",
GrGLBackendState::kTextureBinding_GrGLBackendState)
.value("kView", GrGLBackendState::kView_GrGLBackendState)
.value("kBlend", GrGLBackendState::kBlend_GrGLBackendState)
.value("kMSAAEnable", GrGLBackendState::kMSAAEnable_GrGLBackendState)
.value("kVertex", GrGLBackendState::kVertex_GrGLBackendState)
.value("kStencil", GrGLBackendState::kStencil_GrGLBackendState)
.value("kPixelStore", GrGLBackendState::kPixelStore_GrGLBackendState)
.value("kProgram", GrGLBackendState::kProgram_GrGLBackendState)
.value("kFixedFunction", GrGLBackendState::kFixedFunction_GrGLBackendState)
.value("kMisc", GrGLBackendState::kMisc_GrGLBackendState)
.value("kPathRendering", GrGLBackendState::kPathRendering_GrGLBackendState)
.value("kALL", GrGLBackendState::kALL_GrGLBackendState)
.value("kView_GrGLBackendState",
GrGLBackendState::kView_GrGLBackendState)
.value("kBlend_GrGLBackendState",
GrGLBackendState::kBlend_GrGLBackendState)
.value("kMSAAEnable_GrGLBackendState",
GrGLBackendState::kMSAAEnable_GrGLBackendState)
.value("kVertex_GrGLBackendState",
GrGLBackendState::kVertex_GrGLBackendState)
.value("kStencil_GrGLBackendState",
GrGLBackendState::kStencil_GrGLBackendState)
.value("kPixelStore_GrGLBackendState",
GrGLBackendState::kPixelStore_GrGLBackendState)
.value("kProgram_GrGLBackendState",
GrGLBackendState::kProgram_GrGLBackendState)
.value("kFixedFunction_GrGLBackendState",
GrGLBackendState::kFixedFunction_GrGLBackendState)
.value("kMisc_GrGLBackendState",
GrGLBackendState::kMisc_GrGLBackendState)
.value("kPathRendering_GrGLBackendState",
GrGLBackendState::kPathRendering_GrGLBackendState)
.value("kALL_GrGLBackendState",
GrGLBackendState::kALL_GrGLBackendState)
.export_values();

py::enum_<GrFlushFlags>(m, "GrFlushFlags", R"docstring(
Enum used as return value when flush with semaphores so the client knows
whether the semaphores were submitted to GPU or not.
)docstring")
.value("kNone", GrFlushFlags::kNone_GrFlushFlags)
.value("kSyncCpu", GrFlushFlags::kSyncCpu_GrFlushFlag)
.value("kNone_GrFlushFlags", GrFlushFlags::kNone_GrFlushFlags)
.value("kSyncCpu_GrFlushFlag", GrFlushFlags::kSyncCpu_GrFlushFlag)
.export_values();

py::enum_<GrSemaphoresSubmitted>(m, "GrSemaphoresSubmitted")
Expand Down
10 changes: 5 additions & 5 deletions src/skia/Image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ py::enum_<SkFilterQuality>(m, "FilterQuality", R"docstring(
Controls how much filtering to be done when scaling/transforming complex
colors e.g. image.
)docstring")
.value("kNone", SkFilterQuality::kNone_SkFilterQuality,
.value("kNone_SkFilterQuality", SkFilterQuality::kNone_SkFilterQuality,
"fastest but lowest quality, typically nearest-neighbor")
.value("kLow", SkFilterQuality::kLow_SkFilterQuality,
.value("kLow_SkFilterQuality", SkFilterQuality::kLow_SkFilterQuality,
"typically bilerp")
.value("kMedium", SkFilterQuality::kMedium_SkFilterQuality,
.value("kMedium_SkFilterQuality", SkFilterQuality::kMedium_SkFilterQuality,
"typically bilerp + mipmaps for down-scaling")
.value("kHigh", SkFilterQuality::kHigh_SkFilterQuality,
.value("kHigh_SkFilterQuality", SkFilterQuality::kHigh_SkFilterQuality,
"slowest but highest quality, typically bicubic or better")
.value("kLast", SkFilterQuality::kLast_SkFilterQuality)
.value("kLast_SkFilterQuality", SkFilterQuality::kLast_SkFilterQuality)
.export_values();

py::enum_<SkTileMode>(m, "TileMode")
Expand Down
67 changes: 37 additions & 30 deletions src/skia/ImageInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,67 +2,74 @@

void initImageInfo(py::module &m) {
py::enum_<SkAlphaType>(m, "AlphaType")
.value("kUnknown", SkAlphaType::kUnknown_SkAlphaType,
.value("kUnknown_AlphaType", SkAlphaType::kUnknown_SkAlphaType,
"uninitialized")
.value("kOpaque", SkAlphaType::kOpaque_SkAlphaType,
.value("kOpaque_AlphaType", SkAlphaType::kOpaque_SkAlphaType,
"pixel is opaque")
.value("kPremul", SkAlphaType::kPremul_SkAlphaType,
.value("kPremul_AlphaType", SkAlphaType::kPremul_SkAlphaType,
"pixel components are premultiplied by alpha")
.value("kUnpremul", SkAlphaType::kUnpremul_SkAlphaType,
.value("kUnpremul_AlphaType", SkAlphaType::kUnpremul_SkAlphaType,
"pixel components are independent of alpha")
.value("kLastEnum", SkAlphaType::kLastEnum_SkAlphaType,
.value("kLastEnum_AlphaType", SkAlphaType::kLastEnum_SkAlphaType,
"last valid value")
.export_values();

py::enum_<SkColorType>(m, "ColorType")
.value("kUnknown", SkColorType::kUnknown_SkColorType, "uninitialized")
.value("kAlpha_8", SkColorType::kAlpha_8_SkColorType,
.value("kUnknown_ColorType", SkColorType::kUnknown_SkColorType,
"uninitialized")
.value("kAlpha_8_ColorType", SkColorType::kAlpha_8_SkColorType,
"pixel with alpha in 8-bit byte")
.value("kRGB_565", SkColorType::kRGB_565_SkColorType,
.value("kRGB_565_ColorType", SkColorType::kRGB_565_SkColorType,
"pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word")
.value("kARGB_4444", SkColorType::kARGB_4444_SkColorType,
.value("kARGB_4444_ColorType", SkColorType::kARGB_4444_SkColorType,
"pixel with 4 bits for alpha, red, green, blue; in 16-bit word")
.value("kRGBA_8888", SkColorType::kRGBA_8888_SkColorType,
.value("kRGBA_8888_ColorType", SkColorType::kRGBA_8888_SkColorType,
"pixel with 8 bits for red, green, blue, alpha; in 32-bit word")
.value("kRGB_888x", SkColorType::kRGB_888x_SkColorType,
.value("kRGB_888x_ColorType", SkColorType::kRGB_888x_SkColorType,
"pixel with 8 bits each for red, green, blue; in 32-bit word")
.value("kBGRA_8888", SkColorType::kBGRA_8888_SkColorType,
.value("kBGRA_8888_ColorType", SkColorType::kBGRA_8888_SkColorType,
"pixel with 8 bits for blue, green, red, alpha; in 32-bit word")
.value("kRGBA_1010102", SkColorType::kRGBA_1010102_SkColorType,
.value("kRGBA_1010102_ColorType", SkColorType::kRGBA_1010102_SkColorType,
"10 bits for red, green, blue; 2 bits for alpha; in 32-bit word")
.value("kBGRA_1010102", SkColorType::kBGRA_1010102_SkColorType,
.value("kBGRA_1010102_ColorType", SkColorType::kBGRA_1010102_SkColorType,
"10 bits for blue, green, red; 2 bits for alpha; in 32-bit word")
.value("kRGB_101010x", SkColorType::kRGB_101010x_SkColorType,
.value("kRGB_101010x_ColorType", SkColorType::kRGB_101010x_SkColorType,
"pixel with 10 bits each for red, green, blue; in 32-bit word")
.value("kBGR_101010x", SkColorType::kBGR_101010x_SkColorType,
.value("kBGR_101010x_ColorType", SkColorType::kBGR_101010x_SkColorType,
"pixel with 10 bits each for blue, green, red; in 32-bit word")
.value("kGray_8", SkColorType::kGray_8_SkColorType,
.value("kGray_8_ColorType", SkColorType::kGray_8_SkColorType,
"pixel with grayscale level in 8-bit byte")
.value("kRGBA_F16Norm", SkColorType::kRGBA_F16Norm_SkColorType,
.value("kRGBA_F16Norm_ColorType", SkColorType::kRGBA_F16Norm_SkColorType,
"pixel with half floats in [0,1] for red, green, blue, alpha; in "
"64-bit word")
.value("kRGBA_F16", SkColorType::kRGBA_F16_SkColorType,
.value("kRGBA_F16_ColorType", SkColorType::kRGBA_F16_SkColorType,
"pixel with half floats for red, green, blue, alpha; in 64-bit word")
.value("kRGBA_F32", SkColorType::kRGBA_F32_SkColorType,
.value("kRGBA_F32_ColorType", SkColorType::kRGBA_F32_SkColorType,
"pixel using C float for red, green, blue, alpha; in 128-bit word")
.value("kR8G8_unorm", SkColorType::kR8G8_unorm_SkColorType)
.value("kA16_float", SkColorType::kA16_float_SkColorType)
.value("kR16G16_float", SkColorType::kR16G16_float_SkColorType)
.value("kA16_unorm", SkColorType::kA16_unorm_SkColorType)
.value("kR8G8_unorm_ColorType", SkColorType::kR8G8_unorm_SkColorType)
.value("kA16_float_ColorType", SkColorType::kA16_float_SkColorType)
.value("kR16G16_float_ColorType", SkColorType::kR16G16_float_SkColorType)
.value("kA16_unorm_ColorType", SkColorType::kA16_unorm_SkColorType)
.export_values();

py::enum_<SkYUVColorSpace>(m, "YUVColorSpace")
.value("kJPEG", SkYUVColorSpace::kJPEG_SkYUVColorSpace,
.value("kJPEG_SkYUVColorSpace",
SkYUVColorSpace::kJPEG_SkYUVColorSpace,
"describes full range")
.value("kRec601", SkYUVColorSpace::kRec601_SkYUVColorSpace,
.value("kRec601_SkYUVColorSpace",
SkYUVColorSpace::kRec601_SkYUVColorSpace,
"describes SDTV range")
.value("kRec709", SkYUVColorSpace::kRec709_SkYUVColorSpace,
.value("kRec709_SkYUVColorSpace",
SkYUVColorSpace::kRec709_SkYUVColorSpace,
"describes HDTV range")
.value("kBT2020", SkYUVColorSpace::kBT2020_SkYUVColorSpace,
.value("kBT2020_SkYUVColorSpace",
SkYUVColorSpace::kBT2020_SkYUVColorSpace,
"describes UHDTV range, non-constant-luminance")
.value("kIdentity", SkYUVColorSpace::kIdentity_SkYUVColorSpace,
.value("kIdentity_SkYUVColorSpace",
SkYUVColorSpace::kIdentity_SkYUVColorSpace,
"maps Y->R, U->G, V->B")
.value("kLastEnum", SkYUVColorSpace::kLastEnum_SkYUVColorSpace,
.value("kLastEnum_SkYUVColorSpace",
SkYUVColorSpace::kLastEnum_SkYUVColorSpace,
"last valid value")
.export_values();

Expand Down
8 changes: 4 additions & 4 deletions src/skia/Matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ py::class_<SkMatrix> matrix(m, "Matrix", R"docstring(
)docstring");

py::enum_<SkMatrix::ScaleToFit>(matrix, "ScaleToFit")
.value("kFill", SkMatrix::ScaleToFit::kFill_ScaleToFit,
.value("kFill_ScaleToFit", SkMatrix::ScaleToFit::kFill_ScaleToFit,
"scales in x and y to fill destination SkRect")
.value("kStart", SkMatrix::ScaleToFit::kStart_ScaleToFit,
.value("kStart_ScaleToFit", SkMatrix::ScaleToFit::kStart_ScaleToFit,
"scales and aligns to left and top")
.value("kCenter", SkMatrix::ScaleToFit::kCenter_ScaleToFit,
.value("kCenter_ScaleToFit", SkMatrix::ScaleToFit::kCenter_ScaleToFit,
"scales and aligns to center")
.value("kEnd", SkMatrix::ScaleToFit::kEnd_ScaleToFit,
.value("kEnd_ScaleToFit", SkMatrix::ScaleToFit::kEnd_ScaleToFit,
"scales and aligns to right and bottom")
.export_values();

Expand Down
Loading

0 comments on commit 8f34e6b

Please sign in to comment.