Mercurial > hg > orthanc-stone
comparison Framework/Scene2D/Internals/OpenGLLookupTableTextureRenderer.cpp @ 1278:29cdd73d9477 bugs/2020-02-invisible-slice
DO NOT MERGE! Added global bool that enables
dumping the loaded texture histogram.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Tue, 04 Feb 2020 12:32:15 +0100 |
parents | 2d8ab34c8c91 |
children | 8e82fdc6200e |
comparison
equal
deleted
inserted
replaced
1277:5428b8594382 | 1278:29cdd73d9477 |
---|---|
20 | 20 |
21 | 21 |
22 #include "OpenGLLookupTableTextureRenderer.h" | 22 #include "OpenGLLookupTableTextureRenderer.h" |
23 | 23 |
24 #include <Core/OrthancException.h> | 24 #include <Core/OrthancException.h> |
25 | |
26 | |
27 int OrthancStone_Internals_dump_LoadTexture_histogram = 0; | |
25 | 28 |
26 namespace OrthancStone | 29 namespace OrthancStone |
27 { | 30 { |
28 namespace Internals | 31 namespace Internals |
29 { | 32 { |
73 | 76 |
74 assert(source.GetFormat() == Orthanc::PixelFormat_Float32 && | 77 assert(source.GetFormat() == Orthanc::PixelFormat_Float32 && |
75 target.GetFormat() == Orthanc::PixelFormat_RGBA32 && | 78 target.GetFormat() == Orthanc::PixelFormat_RGBA32 && |
76 sizeof(float) == 4); | 79 sizeof(float) == 4); |
77 | 80 |
81 | |
82 std::map<uint8_t, int> debugHistogram; | |
83 if (OrthancStone_Internals_dump_LoadTexture_histogram == 1) | |
84 { | |
85 for (int i = 0; i <= 255; ++i) | |
86 { | |
87 uint8_t k = static_cast<uint8_t>(i); | |
88 debugHistogram[k] = 0; | |
89 } | |
90 } | |
91 | |
92 | |
78 for (unsigned int y = 0; y < height; y++) | 93 for (unsigned int y = 0; y < height; y++) |
79 { | 94 { |
80 const float* p = reinterpret_cast<const float*>(source.GetConstRow(y)); | 95 const float* p = reinterpret_cast<const float*>(source.GetConstRow(y)); |
81 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y)); | 96 uint8_t* q = reinterpret_cast<uint8_t*>(target.GetRow(y)); |
82 | 97 |
92 v = 255; | 107 v = 255; |
93 } | 108 } |
94 | 109 |
95 uint8_t vv = static_cast<uint8_t>(v); | 110 uint8_t vv = static_cast<uint8_t>(v); |
96 | 111 |
112 if(OrthancStone_Internals_dump_LoadTexture_histogram == 1) | |
113 debugHistogram[vv] += 1; | |
114 | |
97 q[0] = lut[4 * vv + 0]; // R | 115 q[0] = lut[4 * vv + 0]; // R |
98 q[1] = lut[4 * vv + 1]; // G | 116 q[1] = lut[4 * vv + 1]; // G |
99 q[2] = lut[4 * vv + 2]; // B | 117 q[2] = lut[4 * vv + 2]; // B |
100 q[3] = lut[4 * vv + 3]; // A | 118 q[3] = lut[4 * vv + 3]; // A |
101 | 119 |
102 p++; | 120 p++; |
103 q += 4; | 121 q += 4; |
122 } | |
123 } | |
124 | |
125 if (OrthancStone_Internals_dump_LoadTexture_histogram == 1) | |
126 { | |
127 uint8_t vv; | |
128 LOG(INFO) << "Dumping texture loaded with OpenGLLookupTableTextureRenderer::LoadTexture"; | |
129 for (int i = 0; i <= 255; ++i) | |
130 { | |
131 vv = static_cast<uint8_t>(i); | |
132 int ivv = vv; | |
133 int count = debugHistogram[vv]; | |
134 int lutr = lut[4 * vv + 0]; | |
135 int lutg = lut[4 * vv + 1]; | |
136 int lutb = lut[4 * vv + 2]; | |
137 int luta = lut[4 * vv + 3]; | |
138 | |
139 LOG(ERROR) << "This is no error! Y= " << ivv << " count= " << count | |
140 << " lut R= " << lutr << " lut G= " << lutg << " lut B= " << lutb << " lut A= " << luta; | |
104 } | 141 } |
105 } | 142 } |
106 } | 143 } |
107 | 144 |
108 context_.MakeCurrent(); | 145 context_.MakeCurrent(); |