Use fill() to fill an entire image instead of setting pixels individually.
This commit is contained in:
parent
c09c4e0154
commit
c9f5d88f3a
6 changed files with 9 additions and 43 deletions
|
@ -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);
|
im.create(thumbnail_size, thumbnail_size / 2, false, Image::FORMAT_RGBA8);
|
||||||
|
|
||||||
Color bg_color(0.1, 0.1, 0.1, 1.0);
|
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.fill(bg_color);
|
||||||
im.set_pixel(i, j, bg_color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Color line_color(0.8, 0.8, 0.8, 1.0);
|
Color line_color(0.8, 0.8, 0.8, 1.0);
|
||||||
float range_y = curve.get_max_value() - curve.get_min_value();
|
float range_y = curve.get_max_value() - curve.get_min_value();
|
||||||
|
|
|
@ -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
|
bg_color.a = MAX(bg_color.a, 0.2); // some background
|
||||||
|
|
||||||
for (int i = 0; i < thumbnail_size; i++) {
|
img->fill(bg_color);
|
||||||
for (int j = 0; j < thumbnail_size; j++) {
|
|
||||||
img->set_pixel(i, j, bg_color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const int x0 = thumbnail_size / 8;
|
const int x0 = thumbnail_size / 8;
|
||||||
const int y0 = thumbnail_size / 8;
|
const int y0 = thumbnail_size / 8;
|
||||||
|
|
|
@ -775,11 +775,7 @@ LightmapperRD::BakeError LightmapperRD::bake(BakeQuality p_quality, bool p_use_d
|
||||||
} else {
|
} else {
|
||||||
panorama_tex.instantiate();
|
panorama_tex.instantiate();
|
||||||
panorama_tex->create(8, 8, false, Image::FORMAT_RGBAF);
|
panorama_tex->create(8, 8, false, Image::FORMAT_RGBAF);
|
||||||
for (int i = 0; i < 8; i++) {
|
panorama_tex->fill(Color(0, 0, 0, 1));
|
||||||
for (int j = 0; j < 8; j++) {
|
|
||||||
panorama_tex->set_pixel(i, j, Color(0, 0, 0, 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RD::TextureFormat tfp;
|
RD::TextureFormat tfp;
|
||||||
|
|
|
@ -942,11 +942,7 @@ LightmapGI::BakeError LightmapGI::bake(Node *p_from_node, String p_image_data_pa
|
||||||
c.r *= environment_custom_energy;
|
c.r *= environment_custom_energy;
|
||||||
c.g *= environment_custom_energy;
|
c.g *= environment_custom_energy;
|
||||||
c.b *= environment_custom_energy;
|
c.b *= environment_custom_energy;
|
||||||
for (int i = 0; i < 128; i++) {
|
environment_image->fill(c);
|
||||||
for (int j = 0; j < 64; j++) {
|
|
||||||
environment_image->set_pixel(i, j, c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} break;
|
} break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -545,11 +545,7 @@ Ref<Image> RendererSceneRenderRD::environment_bake_panorama(RID p_env, bool p_ba
|
||||||
Ref<Image> panorama;
|
Ref<Image> panorama;
|
||||||
panorama.instantiate();
|
panorama.instantiate();
|
||||||
panorama->create(p_size.width, p_size.height, false, Image::FORMAT_RGBAF);
|
panorama->create(p_size.width, p_size.height, false, Image::FORMAT_RGBAF);
|
||||||
for (int x = 0; x < p_size.width; x++) {
|
panorama->fill(panorama_color);
|
||||||
for (int y = 0; y < p_size.height; y++) {
|
|
||||||
panorama->set_pixel(x, y, panorama_color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return panorama;
|
return panorama;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -971,12 +971,7 @@ void RendererStorageRD::texture_2d_placeholder_initialize(RID p_texture) {
|
||||||
Ref<Image> image;
|
Ref<Image> image;
|
||||||
image.instantiate();
|
image.instantiate();
|
||||||
image->create(4, 4, false, Image::FORMAT_RGBA8);
|
image->create(4, 4, false, Image::FORMAT_RGBA8);
|
||||||
|
image->fill(Color(1, 0, 1, 1));
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
for (int j = 0; j < 4; j++) {
|
|
||||||
image->set_pixel(i, j, Color(1, 0, 1, 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
texture_2d_initialize(p_texture, image);
|
texture_2d_initialize(p_texture, image);
|
||||||
}
|
}
|
||||||
|
@ -987,12 +982,7 @@ void RendererStorageRD::texture_2d_layered_placeholder_initialize(RID p_texture,
|
||||||
Ref<Image> image;
|
Ref<Image> image;
|
||||||
image.instantiate();
|
image.instantiate();
|
||||||
image->create(4, 4, false, Image::FORMAT_RGBA8);
|
image->create(4, 4, false, Image::FORMAT_RGBA8);
|
||||||
|
image->fill(Color(1, 0, 1, 1));
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
for (int j = 0; j < 4; j++) {
|
|
||||||
image->set_pixel(i, j, Color(1, 0, 1, 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector<Ref<Image>> images;
|
Vector<Ref<Image>> images;
|
||||||
if (p_layered_type == RS::TEXTURE_LAYERED_2D_ARRAY) {
|
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;
|
Ref<Image> image;
|
||||||
image.instantiate();
|
image.instantiate();
|
||||||
image->create(4, 4, false, Image::FORMAT_RGBA8);
|
image->create(4, 4, false, Image::FORMAT_RGBA8);
|
||||||
|
image->fill(Color(1, 0, 1, 1));
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
for (int j = 0; j < 4; j++) {
|
|
||||||
image->set_pixel(i, j, Color(1, 0, 1, 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Vector<Ref<Image>> images;
|
Vector<Ref<Image>> images;
|
||||||
//cube
|
//cube
|
||||||
|
|
Loading…
Reference in a new issue