Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/makesrna')
-rw-r--r--source/blender/makesrna/intern/rna_image.c94
-rw-r--r--source/blender/makesrna/intern/rna_image_api.c23
-rw-r--r--source/blender/makesrna/intern/rna_main_api.c5
-rw-r--r--source/blender/makesrna/intern/rna_space.c19
4 files changed, 116 insertions, 25 deletions
diff --git a/source/blender/makesrna/intern/rna_image.c b/source/blender/makesrna/intern/rna_image.c
index 1759eb812e6..36aed870f04 100644
--- a/source/blender/makesrna/intern/rna_image.c
+++ b/source/blender/makesrna/intern/rna_image.c
@@ -59,6 +59,7 @@ static const EnumPropertyItem image_source_items[] = {
{IMA_SRC_MOVIE, "MOVIE", 0, "Movie", "Movie file"},
{IMA_SRC_GENERATED, "GENERATED", 0, "Generated", "Generated image"},
{IMA_SRC_VIEWER, "VIEWER", 0, "Viewer", "Compositing node viewer"},
+ {IMA_SRC_TILED, "TILED", 0, "Tiled", "Tiled image texture"},
{0, NULL, 0, NULL, NULL}
};
@@ -190,6 +191,7 @@ static const EnumPropertyItem *rna_Image_source_itemf(bContext *UNUSED(C), Point
RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_SEQUENCE);
RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_MOVIE);
RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_GENERATED);
+ RNA_enum_items_add_value(&item, &totitem, image_source_items, IMA_SRC_TILED);
}
RNA_enum_item_end(&item, &totitem);
@@ -279,13 +281,6 @@ static void rna_Image_resolution_set(PointerRNA *ptr, const float *values)
BKE_image_release_ibuf(im, ibuf, lock);
}
-static int rna_Image_bindcode_get(PointerRNA *ptr)
-{
- Image *ima = (Image *)ptr->data;
- GPUTexture *tex = ima->gputexture[TEXTARGET_TEXTURE_2D];
- return (tex) ? GPU_texture_opengl_bindcode(tex) : 0;
-}
-
static int rna_Image_depth_get(PointerRNA *ptr)
{
Image *im = (Image *)ptr->data;
@@ -491,6 +486,23 @@ static void rna_render_slots_active_index_range(PointerRNA *ptr, int *min, int *
*max = max_ii(0, BLI_listbase_count(&image->renderslots) - 1);
}
+static ImageTile *rna_ImageTile_new(Image *image, int tile_number, const char *label)
+{
+ ImageTile *tile = BKE_image_add_tile(image, tile_number, label);
+
+ WM_main_add_notifier(NC_IMAGE | ND_DRAW, NULL);
+
+ return tile;
+}
+
+static void rna_ImageTile_remove(ID *id, ImageTile *tile)
+{
+ Image *image = (Image *)id;
+ BKE_image_remove_tile(image, tile);
+
+ WM_main_add_notifier(NC_IMAGE | ND_DRAW, NULL);
+}
+
#else
static void rna_def_imageuser(BlenderRNA *brna)
@@ -555,6 +567,11 @@ static void rna_def_imageuser(BlenderRNA *brna)
RNA_def_property_int_sdna(prop, NULL, "view");
RNA_def_property_clear_flag(prop, PROP_EDITABLE); /* image_multi_cb */
RNA_def_property_ui_text(prop, "View", "View in multilayer image");
+
+ prop = RNA_def_property(srna, "tile", PROP_INT, PROP_UNSIGNED);
+ RNA_def_property_int_sdna(prop, NULL, "tile");
+ RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
+ RNA_def_property_ui_text(prop, "Tile", "Tile in tiled image");
}
/* image.packed_files */
@@ -632,6 +649,56 @@ static void rna_def_render_slots(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_function_return(func, parm);
}
+static void rna_def_image_tile(BlenderRNA *brna)
+{
+ StructRNA *srna;
+ FunctionRNA *func;
+ PropertyRNA *prop;
+ srna = RNA_def_struct(brna, "ImageTile", NULL);
+ RNA_def_struct_ui_text(srna, "Image Tile", "Properties of the image tile");
+
+ prop = RNA_def_property(srna, "label", PROP_STRING, PROP_NONE);
+ RNA_def_property_string_sdna(prop, NULL, "label");
+ RNA_def_property_ui_text(prop, "Label", "Tile label");
+ RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
+
+ prop = RNA_def_property(srna, "tile_number", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "tile_number");
+ RNA_def_property_ui_text(prop, "Tile Number", "Number of the position that this tile covers");
+ RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
+ func = RNA_def_function(srna, "remove", "rna_ImageTile_remove");
+ RNA_def_function_ui_description(func, "Remove this tile from the image");
+ RNA_def_function_flag(func, FUNC_USE_SELF_ID);
+}
+
+static void rna_def_image_tiles(BlenderRNA *brna, PropertyRNA *cprop)
+{
+ StructRNA *srna;
+ FunctionRNA *func;
+ PropertyRNA *parm;
+
+ RNA_def_property_srna(cprop, "ImageTiles");
+ srna = RNA_def_struct(brna, "ImageTiles", NULL);
+ RNA_def_struct_sdna(srna, "Image");
+ RNA_def_struct_ui_text(srna, "Image Tiles", "Collection of the image tiles");
+
+ func = RNA_def_function(srna, "new", "rna_ImageTile_new");
+ RNA_def_function_ui_description(func, "Add a tile to the image");
+ parm = RNA_def_int(func, "tile_number", 1, 1, INT_MAX, "", "Number of the newly created tile", 1, 100);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_string(func, "label", NULL, 0, "", "Optional label for the tile");
+ parm = RNA_def_pointer(func, "result", "ImageTile", "", "Newly created image tile");
+ RNA_def_function_return(func, parm);
+
+ func = RNA_def_function(srna, "get", "BKE_image_get_tile");
+ RNA_def_function_ui_description(func, "Get a tile based on its tile number");
+ parm = RNA_def_int(func, "tile_number", 0, 0, INT_MAX, "", "Number of the tile", 1, 100);
+ RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+ parm = RNA_def_pointer(func, "result", "ImageTile", "", "The tile");
+ RNA_def_function_return(func, parm);
+}
+
static void rna_def_image(BlenderRNA *brna)
{
StructRNA *srna;
@@ -782,18 +849,18 @@ static void rna_def_image(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Display Aspect", "Display Aspect for this image, does not affect rendering");
RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
- prop = RNA_def_property(srna, "bindcode", PROP_INT, PROP_UNSIGNED);
- RNA_def_property_int_funcs(prop, "rna_Image_bindcode_get", NULL, NULL);
- RNA_def_property_clear_flag(prop, PROP_EDITABLE);
- RNA_def_property_ui_text(prop, "Bindcode", "OpenGL bindcode");
- RNA_def_property_update(prop, NC_IMAGE | ND_DISPLAY, NULL);
-
prop = RNA_def_property(srna, "render_slots", PROP_COLLECTION, PROP_NONE);
RNA_def_property_struct_type(prop, "RenderSlot");
RNA_def_property_collection_sdna(prop, NULL, "renderslots", NULL);
RNA_def_property_ui_text(prop, "Render Slots", "Render slots of the image");
rna_def_render_slots(brna, prop);
+ prop = RNA_def_property(srna, "tiles", PROP_COLLECTION, PROP_NONE);
+ RNA_def_property_struct_type(prop, "ImageTile");
+ RNA_def_property_collection_sdna(prop, NULL, "tiles", NULL);
+ RNA_def_property_ui_text(prop, "Image Tiles", "Tiles of the image");
+ rna_def_image_tiles(brna, prop);
+
/*
* Image.has_data and Image.depth are temporary,
* Update import_obj.py when they are replaced (Arystan)
@@ -875,6 +942,7 @@ static void rna_def_image(BlenderRNA *brna)
void RNA_def_image(BlenderRNA *brna)
{
rna_def_render_slot(brna);
+ rna_def_image_tile(brna);
rna_def_image(brna);
rna_def_imageuser(brna);
rna_def_image_packed_files(brna);
diff --git a/source/blender/makesrna/intern/rna_image_api.c b/source/blender/makesrna/intern/rna_image_api.c
index c7a3e103281..7030ec865ef 100644
--- a/source/blender/makesrna/intern/rna_image_api.c
+++ b/source/blender/makesrna/intern/rna_image_api.c
@@ -181,8 +181,8 @@ static void rna_Image_unpack(Image *image, Main *bmain, ReportList *reports, int
if (!BKE_image_has_packedfile(image)) {
BKE_report(reports, RPT_ERROR, "Image not packed");
}
- else if (BKE_image_is_animated(image)) {
- BKE_report(reports, RPT_ERROR, "Unpacking movies or image sequences not supported");
+ else if (BKE_image_has_multiple_ibufs(image)) {
+ BKE_report(reports, RPT_ERROR, "Unpacking movies, image sequences and tiled images not supported");
return;
}
else {
@@ -220,9 +220,10 @@ static void rna_Image_scale(Image *image, ReportList *reports, int width, int he
}
}
-static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int filter, int mag)
+static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int tile_number, int filter, int mag)
{
- GPUTexture *tex = image->gputexture[TEXTARGET_TEXTURE_2D];
+ ImageTile *tile = BKE_image_get_tile(image, tile_number);
+ GPUTexture *tex = tile->gputexture[TEXTARGET_TEXTURE_2D];
int error = GL_NO_ERROR;
if (tex)
@@ -231,6 +232,7 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int f
ImageUser iuser = {NULL};
iuser.framenr = frame;
iuser.ok = true;
+ iuser.tile = tile_number;
void *lock;
ImBuf *ibuf = BKE_image_acquire_ibuf(image, &iuser, &lock);
@@ -259,7 +261,7 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int f
glDeleteTextures(1, (GLuint *)&bindcode);
}
else {
- image->gputexture[TEXTARGET_TEXTURE_2D] = GPU_texture_from_bindcode(GL_TEXTURE_2D, bindcode);
+ tile->gputexture[TEXTARGET_TEXTURE_2D] = GPU_texture_from_bindcode(GL_TEXTURE_2D, bindcode);
}
BKE_image_release_ibuf(image, ibuf, lock);
@@ -267,14 +269,15 @@ static int rna_Image_gl_load(Image *image, ReportList *reports, int frame, int f
return error;
}
-static int rna_Image_gl_touch(Image *image, ReportList *reports, int frame, int filter, int mag)
+static int rna_Image_gl_touch(Image *image, ReportList *reports, int frame, int tile_number, int filter, int mag)
{
int error = GL_NO_ERROR;
BKE_image_tag_time(image);
- if (image->gputexture[TEXTARGET_TEXTURE_2D] == NULL)
- error = rna_Image_gl_load(image, reports, frame, filter, mag);
+ ImageTile *tile = BKE_image_get_tile(image, tile_number);
+ if (tile->gputexture[TEXTARGET_TEXTURE_2D] == NULL)
+ error = rna_Image_gl_load(image, reports, frame, tile_number, filter, mag);
return error;
}
@@ -359,6 +362,8 @@ void RNA_api_image(StructRNA *srna)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_int(func, "frame", 0, 0, INT_MAX, "Frame",
"Frame of image sequence or movie", 0, INT_MAX);
+ RNA_def_int(func, "tile_number", 0, 0, INT_MAX, "Tile",
+ "Tile of a tiled image", 0, INT_MAX);
RNA_def_int(func, "filter", GL_LINEAR_MIPMAP_NEAREST, -INT_MAX, INT_MAX, "Filter",
"The texture minifying function to use if the image wasn't loaded", -INT_MAX, INT_MAX);
RNA_def_int(func, "mag", GL_LINEAR, -INT_MAX, INT_MAX, "Magnification",
@@ -372,6 +377,8 @@ void RNA_api_image(StructRNA *srna)
RNA_def_function_flag(func, FUNC_USE_REPORTS);
RNA_def_int(func, "frame", 0, 0, INT_MAX, "Frame",
"Frame of image sequence or movie", 0, INT_MAX);
+ RNA_def_int(func, "tile_number", 0, 0, INT_MAX, "Tile",
+ "Tile of a tiled image", 0, INT_MAX);
RNA_def_int(func, "filter", GL_LINEAR_MIPMAP_NEAREST, -INT_MAX, INT_MAX, "Filter",
"The texture minifying function", -INT_MAX, INT_MAX);
RNA_def_int(func, "mag", GL_LINEAR, -INT_MAX, INT_MAX, "Magnification",
diff --git a/source/blender/makesrna/intern/rna_main_api.c b/source/blender/makesrna/intern/rna_main_api.c
index febe74f63c9..974503bfaab 100644
--- a/source/blender/makesrna/intern/rna_main_api.c
+++ b/source/blender/makesrna/intern/rna_main_api.c
@@ -330,13 +330,13 @@ static Lamp *rna_Main_lights_new(Main *bmain, const char *name, int type)
return lamp;
}
-static Image *rna_Main_images_new(Main *bmain, const char *name, int width, int height, bool alpha, bool float_buffer, bool stereo3d)
+static Image *rna_Main_images_new(Main *bmain, const char *name, int width, int height, bool alpha, bool float_buffer, bool stereo3d, bool tiled)
{
char safe_name[MAX_ID_NAME - 2];
rna_idname_validate(name, safe_name);
float color[4] = {0.0, 0.0, 0.0, 1.0};
- Image *image = BKE_image_add_generated(bmain, width, height, safe_name, alpha ? 32 : 24, float_buffer, 0, color, stereo3d);
+ Image *image = BKE_image_add_generated(bmain, width, height, safe_name, alpha ? 32 : 24, float_buffer, 0, color, stereo3d, tiled);
id_us_min(&image->id);
return image;
}
@@ -1004,6 +1004,7 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
RNA_def_boolean(func, "alpha", 0, "Alpha", "Use alpha channel");
RNA_def_boolean(func, "float_buffer", 0, "Float Buffer", "Create an image with floating point color");
RNA_def_boolean(func, "stereo3d", 0, "Stereo 3D", "Create left and right views");
+ RNA_def_boolean(func, "tiled", 0, "Tiled", "Create a tiled image");
/* return type */
parm = RNA_def_pointer(func, "image", "Image", "", "New image data-block");
RNA_def_function_return(func, parm);
diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c
index 2f009238851..1bdaa569604 100644
--- a/source/blender/makesrna/intern/rna_space.c
+++ b/source/blender/makesrna/intern/rna_space.c
@@ -1069,7 +1069,7 @@ static const EnumPropertyItem *rna_SpaceImageEditor_draw_channels_itemf(
void *lock;
int zbuf, alpha, totitem = 0;
- ibuf = ED_space_image_acquire_buffer(sima, &lock);
+ ibuf = ED_space_image_acquire_buffer(sima, &lock, 0);
alpha = ibuf && (ibuf->channels == 4);
zbuf = ibuf && (ibuf->zbuf || ibuf->zbuf_float || (ibuf->channels == 1));
@@ -1174,7 +1174,8 @@ static void rna_SpaceImageEditor_scopes_update(struct bContext *C, struct Pointe
ImBuf *ibuf;
void *lock;
- ibuf = ED_space_image_acquire_buffer(sima, &lock);
+ /* TODO(lukas): Support tiles in scopes? */
+ ibuf = ED_space_image_acquire_buffer(sima, &lock, 0);
if (ibuf) {
ED_space_image_scopes_update(C, sima, ibuf, true);
WM_main_add_notifier(NC_IMAGE, sima->image);
@@ -2235,6 +2236,14 @@ static void rna_def_space_image_uv(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Draw Modified Edges", "Draw edges after modifiers are applied");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
+ prop = RNA_def_property(srna, "tile_grid_shape", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "tile_grid_shape");
+ RNA_def_property_array(prop, 2);
+ RNA_def_property_int_default(prop, 1);
+ RNA_def_property_range(prop, 1, 10);
+ RNA_def_property_ui_text(prop, "Tile Grid Shape", "How many tiles will be shown in the background");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
+
prop = RNA_def_property(srna, "show_other_objects", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_OTHER);
RNA_def_property_ui_text(prop, "Draw Other Objects", "Draw other selected objects that share the same image");
@@ -3376,6 +3385,12 @@ static void rna_def_space_image(BlenderRNA *brna)
RNA_def_property_float_funcs(prop, "rna_SpaceImageEditor_zoom_get", NULL, NULL);
RNA_def_property_ui_text(prop, "Zoom", "Zoom factor");
+ prop = RNA_def_property(srna, "current_tile", PROP_INT, PROP_NONE);
+ RNA_def_property_int_sdna(prop, NULL, "curtile");
+ RNA_def_property_range(prop, 0, 1000);
+ RNA_def_property_ui_text(prop, "Current Tile", "The currently selected tile");
+ RNA_def_property_update(prop, NC_SPACE | ND_SPACE_IMAGE, NULL);
+
/* image draw */
prop = RNA_def_property(srna, "show_repeat", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", SI_DRAW_TILE);