Use fill() to fill an entire image instead of setting pixels individually.

This commit is contained in:
Anilforextra 2022-01-08 17:43:15 +05:45
parent c09c4e0154
commit c9f5d88f3a
6 changed files with 9 additions and 43 deletions

View file

@ -803,11 +803,8 @@ Ref<Texture2D> CurvePreviewGenerator::generate(const Ref<Resource> &p_from, cons
im.create(thumbnail_size, thumbnail_size / 2, false, Image::FORMAT_RGBA8);
Color bg_color(0.1, 0.1, 0.1, 1.0);
for (int i = 0; i < thumbnail_size; i++) {
for (int j = 0; j < thumbnail_size / 2; j++) {
im.set_pixel(i, j, bg_color);
}
}
im.fill(bg_color);
Color line_color(0.8, 0.8, 0.8, 1.0);
float range_y = curve.get_max_value() - curve.get_min_value();

View file

@ -514,11 +514,7 @@ Ref<Texture2D> EditorScriptPreviewPlugin::generate(const RES &p_from, const Size
}
bg_color.a = MAX(bg_color.a, 0.2); // some background
for (int i = 0; i < thumbnail_size; i++) {
for (int j = 0; j < thumbnail_size; j++) {
img->set_pixel(i, j, bg_color);
}
}
img->fill(bg_color);
const int x0 = thumbnail_size / 8;
const int y0 = thumbnail_size / 8;

View file

@ -775,11 +775,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
} else {
panorama_tex.instantiate();
panorama_tex->create(8, 8, false, Image::FORMAT_RGBAF);
for (int i = 0; i < 8; i++) {
for (int j = 0; j < 8; j++) {
panorama_tex->set_pixel(i, j, Color(0, 0, 0, 1));
}
}
panorama_tex->fill(Color(0, 0, 0, 1));
}
RD::TextureFormat tfp;

View file

@ -942,11 +942,7 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa
c.r *= environment_custom_energy;
c.g *= environment_custom_energy;
c.b *= environment_custom_energy;
for (int i = 0; i < 128; i++) {
for (int j = 0; j < 64; j++) {
environment_image->set_pixel(i, j, c);
}
}
environment_image->fill(c);
} break;
}

View file

@ -545,11 +545,7 @@ Ref<Image> RendererSceneRenderRD::environment_bake_panorama(RID p_env, bool p_ba
Ref<Image> panorama;
panorama.instantiate();
panorama->create(p_size.width, p_size.height, false, Image::FORMAT_RGBAF);
for (int x = 0; x < p_size.width; x++) {
for (int y = 0; y < p_size.height; y++) {
panorama->set_pixel(x, y, panorama_color);
}
}
panorama->fill(panorama_color);
return panorama;
}

View file

@ -971,12 +971,7 @@ void RendererStorageRD::texture_2d_placeholder_initialize(RID p_texture) {
Ref<Image> image;
image.instantiate();
image->create(4, 4, false, Image::FORMAT_RGBA8);
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
image->set_pixel(i, j, Color(1, 0, 1, 1));
}
}
image->fill(Color(1, 0, 1, 1));
texture_2d_initialize(p_texture, image);
}
@ -987,12 +982,7 @@ void RendererStorageRD::texture_2d_layered_placeholder_initialize(RID p_texture,
Ref<Image> image;
image.instantiate();
image->create(4, 4, false, Image::FORMAT_RGBA8);
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
image->set_pixel(i, j, Color(1, 0, 1, 1));
}
}
image->fill(Color(1, 0, 1, 1));
Vector<Ref<Image>> images;
if (p_layered_type == RS::TEXTURE_LAYERED_2D_ARRAY) {
@ -1013,12 +1003,7 @@ void RendererStorageRD::texture_3d_placeholder_initialize(RID p_texture) {
Ref<Image> image;
image.instantiate();
image->create(4, 4, false, Image::FORMAT_RGBA8);
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
image->set_pixel(i, j, Color(1, 0, 1, 1));
}
}
image->fill(Color(1, 0, 1, 1));
Vector<Ref<Image>> images;
//cube