diff options
author | Nicholas Bishop <nicholasbishop@gmail.com> | 2015-02-08 18:03:20 +0300 |
---|---|---|
committer | Nicholas Bishop <nicholasbishop@gmail.com> | 2015-02-08 18:05:12 +0300 |
commit | ca9d86b2ea8dfb6fbae28f6b6982aeed1bb0caae (patch) | |
tree | 2e6a32270844bf84564fbc085c44ed1d40f5f8cb | |
parent | a9994506cfee819230fa2942d88286f7bc649901 (diff) |
Naming cleanup: better consistency in extern/ptex
-rw-r--r-- | extern/ptex/BPX_packed_layout.h (renamed from extern/ptex/ptex_packed_layout.h) | 8 | ||||
-rw-r--r-- | extern/ptex/BPX_ptex.h (renamed from extern/ptex/BPX_pack.h) | 31 | ||||
-rw-r--r-- | extern/ptex/CMakeLists.txt | 4 | ||||
-rw-r--r-- | extern/ptex/bpx_c_api.cpp | 50 | ||||
-rw-r--r-- | intern/cycles/render/image.cpp | 8 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/bke_ptex.c | 20 | ||||
-rw-r--r-- | source/blender/imbuf/IMB_imbuf.h | 6 | ||||
-rw-r--r-- | source/blender/imbuf/intern/imb_ptex.c | 12 |
8 files changed, 70 insertions, 69 deletions
diff --git a/extern/ptex/ptex_packed_layout.h b/extern/ptex/BPX_packed_layout.h index a72c4355501..03af5f04aa4 100644 --- a/extern/ptex/ptex_packed_layout.h +++ b/extern/ptex/BPX_packed_layout.h @@ -1,5 +1,5 @@ -#ifndef __PTEX_PACKED_LAYOUT_H__ -#define __PTEX_PACKED_LAYOUT_H__ +#ifndef __BPX_PACKED_LAYOUT_H__ +#define __BPX_PACKED_LAYOUT_H__ #include <algorithm> #include <cassert> @@ -15,7 +15,7 @@ // // TODO(nicholasbishop): not sure if it's worth aiming for // power-of-two output texture? -struct PtexPackedLayout { +struct BPXPackedLayout { struct Item { Item(const int u_res, const int v_res) : u_res(u_res), v_res(v_res), id(-1), x(-1), y(-1) @@ -31,7 +31,7 @@ struct PtexPackedLayout { typedef std::vector<Item> Items; - PtexPackedLayout(const int count) + BPXPackedLayout(const int count) : width(0), height(0), u_max_res(0), v_max_res(0) { items.reserve(count); diff --git a/extern/ptex/BPX_pack.h b/extern/ptex/BPX_ptex.h index 11a0af267e1..8a902b198e3 100644 --- a/extern/ptex/BPX_pack.h +++ b/extern/ptex/BPX_ptex.h @@ -1,5 +1,5 @@ -#ifndef __BPX_PACK_H__ -#define __BPX_PACK_H__ +#ifndef __BPX_PTEX_H__ +#define __BPX_PTEX_H__ #ifdef __cplusplus extern "C"{ @@ -120,27 +120,26 @@ bool TODO_test_write(BPXImageBuf *bpx_buf, const char *path); bool BPX_image_buf_transform(BPXImageBuf *bpx_buf); -int BPX_packed_layout_num_regions(const struct PtexPackedLayout *layout); +int BPX_packed_layout_num_regions(const struct BPXPackedLayout *layout); typedef BPXImageBuf* (*BPXImageBufFromLayout) - (const struct PtexPackedLayout *layout, void *context); + (const struct BPXPackedLayout *layout, void *context); BPXImageBuf *BPX_image_buf_ptex_pack(BPXImageInput *bpx_src, BPXImageBufFromLayout dst_create_func, void *dst_create_context); -// TODO: naming -struct PtexPackedLayout; -struct PtexPackedLayout *ptex_packed_layout_new(int count); -void ptex_packed_layout_add(struct PtexPackedLayout *layout, - int u_res, int v_res, int id); -void ptex_packed_layout_finalize(struct PtexPackedLayout *layout); -int ptex_packed_layout_width(const struct PtexPackedLayout *layout); -int ptex_packed_layout_height(const struct PtexPackedLayout *layout); -bool ptex_packed_layout_item(const struct PtexPackedLayout *layout, - int id, int *x, int *y, - int *width, int *height); -void ptex_packed_layout_delete(struct PtexPackedLayout *layout); +struct BPXPackedLayout; +struct BPXPackedLayout *BPX_packed_layout_new(int count); +void BPX_packed_layout_add(struct BPXPackedLayout *layout, + int u_res, int v_res, int id); +void BPX_packed_layout_finalize(struct BPXPackedLayout *layout); +int BPX_packed_layout_width(const struct BPXPackedLayout *layout); +int BPX_packed_layout_height(const struct BPXPackedLayout *layout); +bool BPX_packed_layout_item(const struct BPXPackedLayout *layout, + int id, int *x, int *y, + int *width, int *height); +void BPX_packed_layout_delete(struct BPXPackedLayout *layout); #ifdef __cplusplus } /* extern "C" */ diff --git a/extern/ptex/CMakeLists.txt b/extern/ptex/CMakeLists.txt index 0de66961e77..8e53f431c0e 100644 --- a/extern/ptex/CMakeLists.txt +++ b/extern/ptex/CMakeLists.txt @@ -31,7 +31,9 @@ set(INC_SYS ) set(SRC - BPX_pack.h + BPX_ptex.h + BPX_packed_layout.h + bpx_c_api.cpp ) diff --git a/extern/ptex/bpx_c_api.cpp b/extern/ptex/bpx_c_api.cpp index 81730de7de8..7a2a41ae0ed 100644 --- a/extern/ptex/bpx_c_api.cpp +++ b/extern/ptex/bpx_c_api.cpp @@ -3,8 +3,8 @@ #include <OpenImageIO/imagebuf.h> #include <OpenImageIO/imagebufalgo.h> -#include "BPX_pack.h" -#include "ptex_packed_layout.h" +#include "BPX_packed_layout.h" +#include "BPX_ptex.h" OIIO_NAMESPACE_USING @@ -792,7 +792,7 @@ static bool bpx_ptex_file_mesh_edges(BPXMeshEdges &edges, return true; } -static BPXRect bpx_rect_from_layout_item(const PtexPackedLayout::Item &item) +static BPXRect bpx_rect_from_layout_item(const BPXPackedLayout::Item &item) { BPXRect rect; rect.xbegin = item.x; @@ -970,14 +970,14 @@ static bool bpx_ptex_mesh_init(BPXPtexMesh &mesh, ImageInput &src) static bool bpx_ptex_filter_borders_update_from_file(ImageBuf &dst, ImageInput &src, - PtexPackedLayout &layout) + BPXPackedLayout &layout) { BPXPtexMesh mesh; if (!bpx_ptex_mesh_init(mesh, src)) { return false; } - const PtexPackedLayout::Items &items = layout.get_items(); + const BPXPackedLayout::Items &items = layout.get_items(); int cur_layout_item = 0; for (int face_index = 0; face_index < mesh.num_faces; face_index++) { @@ -986,7 +986,7 @@ static bool bpx_ptex_filter_borders_update_from_file(ImageBuf &dst, return false; } - const PtexPackedLayout::Item &item = items[cur_layout_item]; + const BPXPackedLayout::Item &item = items[cur_layout_item]; const BPXRect dst_rect = bpx_rect_from_layout_item(item); // TODO @@ -1005,7 +1005,7 @@ static bool bpx_ptex_filter_borders_update_from_file(ImageBuf &dst, { return false; } - const PtexPackedLayout::Item &adj_item = items[adj_layout_item]; + const BPXPackedLayout::Item &adj_item = items[adj_layout_item]; adj_rect[side] = bpx_rect_from_layout_item(adj_item); } @@ -1067,12 +1067,12 @@ static bool bpx_ptex_face_vector(BPXPtexFaceSpecVec &vec, ImageInput &src) return true; } -int BPX_packed_layout_num_regions(const PtexPackedLayout *layout) +int BPX_packed_layout_num_regions(const BPXPackedLayout *layout) { return layout->get_items().size(); } -static bool bpx_image_buf_ptex_layout(PtexPackedLayout &layout, ImageInput &in, +static bool bpx_image_buf_ptex_layout(BPXPackedLayout &layout, ImageInput &in, const BPXPtexFaceSpecVec &face_specs) { ImageSpec spec = in.spec(); @@ -1084,11 +1084,11 @@ static bool bpx_image_buf_ptex_layout(PtexPackedLayout &layout, ImageInput &in, const BPXPtexFaceSpec &pfs = face_specs.at(subimage); if (pfs.subface) { - layout.add_item(PtexPackedLayout::Item(pfs.w, pfs.h)); + layout.add_item(BPXPackedLayout::Item(pfs.w, pfs.h)); } else { for (int i = 0; i < QUAD_NUM_SIDES; i++) { - layout.add_item(PtexPackedLayout::Item(pfs.qw[i], pfs.qh[i])); + layout.add_item(BPXPackedLayout::Item(pfs.qw[i], pfs.qh[i])); } } @@ -1105,7 +1105,7 @@ static bool bpx_image_buf_ptex_layout(PtexPackedLayout &layout, ImageInput &in, } static bool bpx_image_buf_fill_from_layout(ImageBuf &all_dst, - const PtexPackedLayout &layout, + const BPXPackedLayout &layout, const BPXPtexFaceSpecVec &face_specs, ImageInput &src) { @@ -1124,7 +1124,7 @@ static bool bpx_image_buf_fill_from_layout(ImageBuf &all_dst, src.read_image(src.spec().format, tmp.localpixels()); if (pfs.subface) { - const PtexPackedLayout::Item &item = + const BPXPackedLayout::Item &item = layout.get_items().at(face_id); const int xbegin = item.x; const int ybegin = item.y; @@ -1148,7 +1148,7 @@ static bool bpx_image_buf_fill_from_layout(ImageBuf &all_dst, ROI dst_roi[QUAD_NUM_SIDES]; for (int i = 0; i < QUAD_NUM_SIDES; i++) { - const PtexPackedLayout::Item &item = + const BPXPackedLayout::Item &item = layout.get_items().at(face_id); ImageSpec spec2 = spec; spec2.width = pfs.qw[i]; @@ -1188,7 +1188,7 @@ BPXImageBuf *BPX_image_buf_ptex_pack(BPXImageInput *bpx_src, return NULL; } - PtexPackedLayout layout(face_specs.size()); + BPXPackedLayout layout(face_specs.size()); if (!bpx_image_buf_ptex_layout(layout, in, face_specs)) { return NULL; } @@ -1210,39 +1210,39 @@ BPXImageBuf *BPX_image_buf_ptex_pack(BPXImageInput *bpx_src, return bpx_dst; } -PtexPackedLayout *ptex_packed_layout_new(const int count) +BPXPackedLayout *BPX_packed_layout_new(const int count) { - return new PtexPackedLayout(count); + return new BPXPackedLayout(count); } -void ptex_packed_layout_add(PtexPackedLayout * const layout, +void BPX_packed_layout_add(BPXPackedLayout * const layout, const int u_res, const int v_res, const int id) { - layout->add_item(PtexPackedLayout::Item(u_res, v_res)); + layout->add_item(BPXPackedLayout::Item(u_res, v_res)); } -void ptex_packed_layout_finalize(PtexPackedLayout * const layout) +void BPX_packed_layout_finalize(BPXPackedLayout * const layout) { layout->finalize(); } -int ptex_packed_layout_width(const PtexPackedLayout * const layout) +int BPX_packed_layout_width(const BPXPackedLayout * const layout) { return layout->get_width(); } -int ptex_packed_layout_height(const PtexPackedLayout * const layout) +int BPX_packed_layout_height(const BPXPackedLayout * const layout) { return layout->get_height(); } -bool ptex_packed_layout_item(const PtexPackedLayout * const layout, +bool BPX_packed_layout_item(const BPXPackedLayout * const layout, const int item_id, int *x, int *y, int *width, int *height) { if (layout && x && y && width && height) { - const PtexPackedLayout::Items &items = layout->get_items(); + const BPXPackedLayout::Items &items = layout->get_items(); if (item_id >= 0 && item_id < items.size()) { (*x) = items[item_id].x; (*y) = items[item_id].y; @@ -1254,7 +1254,7 @@ bool ptex_packed_layout_item(const PtexPackedLayout * const layout, return false; } -void ptex_packed_layout_delete(PtexPackedLayout *layout) +void BPX_packed_layout_delete(BPXPackedLayout *layout) { delete layout; } diff --git a/intern/cycles/render/image.cpp b/intern/cycles/render/image.cpp index 25ed364d55e..2651c8656f3 100644 --- a/intern/cycles/render/image.cpp +++ b/intern/cycles/render/image.cpp @@ -391,12 +391,12 @@ struct PtexPackUcharContext { int slot; }; -static BPXImageBuf *ptex_pack_uchar_cb(const struct PtexPackedLayout *layout, +static BPXImageBuf *ptex_pack_uchar_cb(const struct BPXPackedLayout *layout, void *c) { PtexPackUcharContext &context = *static_cast<PtexPackUcharContext*>(c); - const int width = ptex_packed_layout_width(layout); - const int height = ptex_packed_layout_height(layout); + const int width = BPX_packed_layout_width(layout); + const int height = BPX_packed_layout_height(layout); const int depth = 1; (*context.pixels) = (uchar*)context.tex_img.resize(width, height, depth); @@ -407,7 +407,7 @@ static BPXImageBuf *ptex_pack_uchar_cb(const struct PtexPackedLayout *layout, for (int i = 0; i < num_regions; i++) { int x, y, w, h; - if (ptex_packed_layout_item(layout, i, &x, &y, &w, &h)) { + if (BPX_packed_layout_item(layout, i, &x, &y, &w, &h)) { regions[i][0] = x; regions[i][1] = y; regions[i][2] = w; diff --git a/source/blender/blenkernel/intern/bke_ptex.c b/source/blender/blenkernel/intern/bke_ptex.c index b82a6fe35ff..6c80d3ca41a 100644 --- a/source/blender/blenkernel/intern/bke_ptex.c +++ b/source/blender/blenkernel/intern/bke_ptex.c @@ -42,7 +42,7 @@ #include "BKE_mesh.h" #include "BKE_subsurf.h" -#include "BPX_pack.h" +#include "BPX_ptex.h" #endif /* Like MPtexLogRes, but actual values instead of log */ @@ -495,7 +495,7 @@ static bool ptex_pack_loops(Image **image, Mesh *me, MLoopPtex *loop_ptex) { BPXImageBuf *bpx_dst; const int num_loops = me->totloop; - struct PtexPackedLayout *layout = NULL; + struct BPXPackedLayout *layout = NULL; struct ImBuf *ibuf; MPtexTexelInfo texel_info; BPXTypeDesc type_desc; @@ -511,19 +511,19 @@ static bool ptex_pack_loops(Image **image, Mesh *me, MLoopPtex *loop_ptex) } /* Create layout */ - layout = ptex_packed_layout_new(num_loops); + layout = BPX_packed_layout_new(num_loops); for (i = 0; i < num_loops; i++) { - ptex_packed_layout_add(layout, - ptex_res_from_rlog2(loop_ptex[i].logres.u), - ptex_res_from_rlog2(loop_ptex[i].logres.v), - i); + BPX_packed_layout_add(layout, + ptex_res_from_rlog2(loop_ptex[i].logres.u), + ptex_res_from_rlog2(loop_ptex[i].logres.v), + i); } - ptex_packed_layout_finalize(layout); + BPX_packed_layout_finalize(layout); /* Create ImBuf destination, this will get the region info too so * the layout can then be deleted */ ibuf = IMB_alloc_from_ptex_layout(layout); - ptex_packed_layout_delete(layout); + BPX_packed_layout_delete(layout); if (!ibuf) { return false; } @@ -532,7 +532,7 @@ static bool ptex_pack_loops(Image **image, Mesh *me, MLoopPtex *loop_ptex) bpx_dst = IMB_imbuf_as_bpx_image_buf(ibuf); if (!bpx_dst) { IMB_freeImBuf(ibuf); - ptex_packed_layout_delete(layout); + BPX_packed_layout_delete(layout); return false; } diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 5dce31818c0..52dd97476c8 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -552,7 +552,7 @@ const char *IMB_ffmpeg_last_error(void); /* ptex */ struct BPXImageBuf; -struct PtexPackedLayout; +struct BPXPackedLayout; /* Create a new BPXImageBuf that wraps an ImBuf * @@ -565,8 +565,8 @@ struct PtexPackedLayout; * needed. */ struct BPXImageBuf *IMB_imbuf_as_bpx_image_buf(struct ImBuf *ibuf); -/* Create an ImBuf from a finalized PtexPackedLayout */ -struct ImBuf *IMB_alloc_from_ptex_layout(const struct PtexPackedLayout *layout); +/* Create an ImBuf from a finalized BPXPackedLayout */ +struct ImBuf *IMB_alloc_from_ptex_layout(const struct BPXPackedLayout *layout); #endif diff --git a/source/blender/imbuf/intern/imb_ptex.c b/source/blender/imbuf/intern/imb_ptex.c index a6c9b3c8d5d..622f29a1a89 100644 --- a/source/blender/imbuf/intern/imb_ptex.c +++ b/source/blender/imbuf/intern/imb_ptex.c @@ -8,7 +8,7 @@ #include "BLI_string.h" #include "MEM_guardedalloc.h" -#include "BPX_pack.h" +#include "BPX_ptex.h" /* TODO(nicholasbishop): color space stuff */ @@ -23,10 +23,10 @@ int imb_is_a_ptex_filepath(const char *name) return BLI_str_endswith(name, ".ptx"); } -ImBuf *IMB_alloc_from_ptex_layout(const struct PtexPackedLayout *layout) +ImBuf *IMB_alloc_from_ptex_layout(const struct BPXPackedLayout *layout) { - ImBuf *ibuf = IMB_allocImBuf(ptex_packed_layout_width(layout), - ptex_packed_layout_height(layout), + ImBuf *ibuf = IMB_allocImBuf(BPX_packed_layout_width(layout), + BPX_packed_layout_height(layout), /* TODO? */ 32, /* TODO */ @@ -42,7 +42,7 @@ ImBuf *IMB_alloc_from_ptex_layout(const struct PtexPackedLayout *layout) for (i = 0; i < ibuf->num_ptex_regions; i++) { ImPtexRegion *dst_region = &ibuf->ptex_regions[i]; - if (!ptex_packed_layout_item(layout, i, &dst_region->x, + if (!BPX_packed_layout_item(layout, i, &dst_region->x, &dst_region->y, &dst_region->width, &dst_region->height)) { @@ -56,7 +56,7 @@ ImBuf *IMB_alloc_from_ptex_layout(const struct PtexPackedLayout *layout) return ibuf; } -static BPXImageBuf *imb_alloc_from_ptex_layout_cb(const struct PtexPackedLayout *layout, +static BPXImageBuf *imb_alloc_from_ptex_layout_cb(const struct BPXPackedLayout *layout, void *vcontext) { ImBuf **ibuf = vcontext; |