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:
authorPablo Dobarro <pablodp606@gmail.com>2019-06-28 02:31:04 +0300
committerPablo Dobarro <pablodp606@gmail.com>2019-06-28 02:31:04 +0300
commitfa916b74706dd6c09b90848f7930567c3e1c8216 (patch)
treef7e868090e2d1148f68791d8142c4cb814eb0401 /source/blender/gpu
parent8d17efaf7b71afa6cee252fa81b9e49016dbc118 (diff)
parent5dd8c3f0cb83db22e9570119ba35715a4d222a9f (diff)
Merge branch 'master' into sculpt-mode-features
Diffstat (limited to 'source/blender/gpu')
-rw-r--r--source/blender/gpu/GPU_texture.h7
-rw-r--r--source/blender/gpu/intern/gpu_draw.c3
-rw-r--r--source/blender/gpu/intern/gpu_texture.c51
3 files changed, 23 insertions, 38 deletions
diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index d5e763987cb..2b61d99e852 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -214,10 +214,6 @@ void GPU_texture_update_sub(GPUTexture *tex,
int depth);
void *GPU_texture_read(GPUTexture *tex, eGPUDataFormat gpu_data_format, int miplvl);
-void GPU_texture_read_rect(GPUTexture *tex,
- eGPUDataFormat gpu_data_format,
- const struct rcti *rect,
- void *r_buf);
void GPU_invalid_tex_init(void);
void GPU_invalid_tex_bind(int mode);
@@ -245,6 +241,9 @@ int GPU_texture_detach_framebuffer(GPUTexture *tex, struct GPUFrameBuffer *fb);
int GPU_texture_target(const GPUTexture *tex);
int GPU_texture_width(const GPUTexture *tex);
int GPU_texture_height(const GPUTexture *tex);
+int GPU_texture_orig_width(const GPUTexture *tex);
+int GPU_texture_orig_height(const GPUTexture *tex);
+void GPU_texture_orig_size_set(GPUTexture *tex, int w, int h);
int GPU_texture_layers(const GPUTexture *tex);
eGPUTextureFormat GPU_texture_format(const GPUTexture *tex);
int GPU_texture_samples(const GPUTexture *tex);
diff --git a/source/blender/gpu/intern/gpu_draw.c b/source/blender/gpu/intern/gpu_draw.c
index 9a341631833..d1d5e1d89a2 100644
--- a/source/blender/gpu/intern/gpu_draw.c
+++ b/source/blender/gpu/intern/gpu_draw.c
@@ -501,6 +501,9 @@ GPUTexture *GPU_texture_from_blender(Image *ima, ImageUser *iuser, int textarget
BKE_image_release_ibuf(ima, ibuf, NULL);
*tex = GPU_texture_from_bindcode(textarget, bindcode);
+
+ GPU_texture_orig_size_set(*tex, ibuf->x, ibuf->y);
+
return *tex;
}
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index 58d0dd5576f..6a92832d1e5 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -68,6 +68,7 @@ typedef enum eGPUTextureFormatFlag {
/* GPUTexture */
struct GPUTexture {
int w, h, d; /* width/height/depth */
+ int orig_w, orig_h; /* width/height (of source data), optional. */
int number; /* number for multitexture binding */
int refcount; /* reference count */
GLenum target; /* GL_TEXTURE_* */
@@ -1484,40 +1485,6 @@ void *GPU_texture_read(GPUTexture *tex, eGPUDataFormat gpu_data_format, int mipl
return buf;
}
-void GPU_texture_read_rect(GPUTexture *tex,
- eGPUDataFormat gpu_data_format,
- const rcti *rect,
- void *r_buf)
-{
- gpu_validate_data_format(tex->format, gpu_data_format);
-
- GPUFrameBuffer *cur_fb = GPU_framebuffer_active_get();
- GPUFrameBuffer *tmp_fb = GPU_framebuffer_create();
- GPU_framebuffer_texture_attach(tmp_fb, tex, 0, 0);
-
- GPU_framebuffer_bind(tmp_fb);
- glReadBuffer(GL_COLOR_ATTACHMENT0);
-
- GLenum data_format = gpu_get_gl_dataformat(tex->format, &tex->format_flag);
- GLenum data_type = gpu_get_gl_datatype(gpu_data_format);
-
- glReadPixels(rect->xmin,
- rect->ymin,
- BLI_rcti_size_x(rect),
- BLI_rcti_size_y(rect),
- data_format,
- data_type,
- r_buf);
-
- if (cur_fb) {
- GPU_framebuffer_bind(cur_fb);
- }
- else {
- GPU_framebuffer_restore();
- }
- GPU_framebuffer_free(tmp_fb);
-}
-
void GPU_texture_update(GPUTexture *tex, eGPUDataFormat data_format, const void *pixels)
{
GPU_texture_update_sub(tex, data_format, pixels, 0, 0, 0, tex->w, tex->h, tex->d);
@@ -1778,6 +1745,22 @@ int GPU_texture_height(const GPUTexture *tex)
return tex->h;
}
+int GPU_texture_orig_width(const GPUTexture *tex)
+{
+ return tex->orig_w;
+}
+
+int GPU_texture_orig_height(const GPUTexture *tex)
+{
+ return tex->orig_h;
+}
+
+void GPU_texture_orig_size_set(GPUTexture *tex, int w, int h)
+{
+ tex->orig_w = w;
+ tex->orig_h = h;
+}
+
int GPU_texture_layers(const GPUTexture *tex)
{
return tex->d;