44 DCHECK(!update_state_.is_active);
46 if (update_state_.is_active) {
47 LOG(ERROR) <<
"Attempt to re-activate update process.";
58 texture_state_.size =
make_int2(texture_width, texture_height);
61 if (!driver_->update_begin(
params, texture_width, texture_height)) {
62 LOG(ERROR) <<
"PathTraceDisplay implementation could not begin update.";
66 update_state_.is_active =
true;
95 const half4 *rgba_pixels,
int texture_x,
int texture_y,
int pixels_width,
int pixels_height)
97 DCHECK(update_state_.is_active);
99 if (!update_state_.is_active) {
100 LOG(ERROR) <<
"Attempt to copy pixels data outside of PathTraceDisplay update.";
104 mark_texture_updated();
113 if (!mapped_rgba_pixels) {
117 const int texture_width = texture_state_.size.x;
118 const int texture_height = texture_state_.size.y;
120 if (texture_x == 0 && texture_y == 0 && pixels_width == texture_width &&
121 pixels_height == texture_height)
123 const size_t size_in_bytes =
sizeof(
half4) * texture_width * texture_height;
124 memcpy(mapped_rgba_pixels, rgba_pixels, size_in_bytes);
127 const half4 *rgba_row = rgba_pixels;
128 half4 *mapped_rgba_row = mapped_rgba_pixels + texture_y * texture_width + texture_x;
129 for (
int y = 0; y < pixels_height;
130 ++
y, rgba_row += pixels_width, mapped_rgba_row += texture_width)
132 memcpy(mapped_rgba_row, rgba_row,
sizeof(
half4) * pixels_width);
145 DCHECK(!texture_buffer_state_.is_mapped);
146 DCHECK(update_state_.is_active);
148 if (texture_buffer_state_.is_mapped) {
149 LOG(ERROR) <<
"Attempt to re-map an already mapped texture buffer.";
153 if (!update_state_.is_active) {
154 LOG(ERROR) <<
"Attempt to copy pixels data outside of PathTraceDisplay update.";
158 half4 *mapped_rgba_pixels = driver_->map_texture_buffer();
160 if (mapped_rgba_pixels) {
161 texture_buffer_state_.is_mapped =
true;
164 return mapped_rgba_pixels;