Changeset View
Changeset View
Standalone View
Standalone View
source/blender/compositor/intern/COM_MemoryBuffer.cc
| Show First 20 Lines • Show All 399 Lines • ▼ Show 20 Lines | if (x >= this->m_rect.xmin && x < this->m_rect.xmax && y >= this->m_rect.ymin && | ||||
| float *dst = &this->m_buffer[offset]; | float *dst = &this->m_buffer[offset]; | ||||
| const float *src = color; | const float *src = color; | ||||
| for (int i = 0; i < this->m_num_channels; i++, dst++, src++) { | for (int i = 0; i < this->m_num_channels; i++, dst++, src++) { | ||||
| *dst += *src; | *dst += *src; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| static void read_ewa_elem(void *userdata, int x, int y, float result[4]) | |||||
| { | |||||
| const MemoryBuffer *buffer = static_cast<const MemoryBuffer *>(userdata); | |||||
| buffer->read_elem_checked(x, y, result); | |||||
| } | |||||
| void MemoryBuffer::read_elem_filtered( | |||||
| const float x, const float y, float dx[2], float dy[2], float *out) const | |||||
| { | |||||
| BLI_assert(this->m_datatype == DataType::Color); | |||||
| const float deriv[2][2] = {{dx[0], dx[1]}, {dy[0], dy[1]}}; | |||||
| float inv_width = 1.0f / (float)this->getWidth(), inv_height = 1.0f / (float)this->getHeight(); | |||||
| /* TODO(sergey): Render pipeline uses normalized coordinates and derivatives, | |||||
| * but compositor uses pixel space. For now let's just divide the values and | |||||
| * switch compositor to normalized space for EWA later. | |||||
| */ | |||||
| float uv_normal[2] = {get_relative_x(x) * inv_width, get_relative_y(y) * inv_height}; | |||||
| float du_normal[2] = {deriv[0][0] * inv_width, deriv[0][1] * inv_height}; | |||||
| float dv_normal[2] = {deriv[1][0] * inv_width, deriv[1][1] * inv_height}; | |||||
| BLI_ewa_filter(this->getWidth(), | |||||
| this->getHeight(), | |||||
| false, | |||||
| true, | |||||
| uv_normal, | |||||
| du_normal, | |||||
| dv_normal, | |||||
| read_ewa_elem, | |||||
| const_cast<MemoryBuffer *>(this), | |||||
| out); | |||||
| } | |||||
| /* TODO(manzanilla): to be removed with tiled implementation. */ | |||||
| static void read_ewa_pixel_sampled(void *userdata, int x, int y, float result[4]) | static void read_ewa_pixel_sampled(void *userdata, int x, int y, float result[4]) | ||||
| { | { | ||||
| MemoryBuffer *buffer = (MemoryBuffer *)userdata; | MemoryBuffer *buffer = (MemoryBuffer *)userdata; | ||||
| buffer->read(result, x, y); | buffer->read(result, x, y); | ||||
| } | } | ||||
| /* TODO(manzanilla): to be removed with tiled implementation. */ | |||||
| void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivatives[2][2]) | void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivatives[2][2]) | ||||
| { | { | ||||
| if (m_is_a_single_elem) { | if (m_is_a_single_elem) { | ||||
| memcpy(result, m_buffer, sizeof(float) * this->m_num_channels); | memcpy(result, m_buffer, sizeof(float) * this->m_num_channels); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_assert(this->m_datatype == DataType::Color); | BLI_assert(this->m_datatype == DataType::Color); | ||||
| float inv_width = 1.0f / (float)this->getWidth(), inv_height = 1.0f / (float)this->getHeight(); | float inv_width = 1.0f / (float)this->getWidth(), inv_height = 1.0f / (float)this->getHeight(); | ||||
| ▲ Show 20 Lines • Show All 88 Lines • Show Last 20 Lines | |||||