@@ -219,20 +219,40 @@ void CWebView::UpdateTexture()
219
219
// Update changed state
220
220
m_RenderData.changed = false ;
221
221
222
- if (m_RenderData. dirtyRects . size () > 0 && m_RenderData. dirtyRects [ 0 ]. width == m_RenderData. width && m_RenderData. dirtyRects [ 0 ]. height == m_RenderData. height )
222
+ if (m_pWebBrowserRenderItem-> m_IsARGB )
223
223
{
224
- // Update whole texture
225
- memcpy (surfaceData, sourceData, m_RenderData.width * m_RenderData.height * 4 );
224
+ if (m_RenderData.dirtyRects .size () > 0 && m_RenderData.dirtyRects [0 ].width == m_RenderData.width && m_RenderData.dirtyRects [0 ].height == m_RenderData.height )
225
+ {
226
+ // Update whole texture
227
+ memcpy (surfaceData, sourceData, m_RenderData.width * m_RenderData.height * 4 );
228
+ }
229
+ else
230
+ {
231
+ // Update dirty rects
232
+ for (auto & rect : m_RenderData.dirtyRects )
233
+ {
234
+ for (int y = rect.y ; y < rect.y + rect.height ; ++y)
235
+ {
236
+ int index = y * pitch + rect.x * 4 ;
237
+ memcpy (&surfaceData[index], &sourceData[index], rect.width * 4 );
238
+ }
239
+ }
240
+ }
226
241
}
227
242
else
228
243
{
229
- // Update dirty rects
230
244
for (auto & rect : m_RenderData.dirtyRects )
231
245
{
232
246
for (int y = rect.y ; y < rect.y + rect.height ; ++y)
233
247
{
234
- int index = y * pitch + rect.x * 4 ;
235
- memcpy (&surfaceData[index], &sourceData[index], rect.width * 4 );
248
+ for (int x = rect.x ; x < rect.x + rect.width ; ++x)
249
+ {
250
+ int index = y * pitch + x * 4 ;
251
+ const uint32_t sourcePixel = *reinterpret_cast <const std::uint32_t *>(&sourceData[index]);
252
+
253
+ // Convert ABGR to ARGB
254
+ *reinterpret_cast <std::uint32_t *>(&surfaceData[index]) = (sourcePixel & 0xFF00FF00 ) | ((sourcePixel & 0x00FF0000 ) >> 16 ) | ((sourcePixel & 0x000000FF ) << 16 );
255
+ }
236
256
}
237
257
}
238
258
}
@@ -247,10 +267,24 @@ void CWebView::UpdateTexture()
247
267
auto popupPitch = m_RenderData.popupRect .width * 4 ;
248
268
for (int y = 0 ; y < m_RenderData.popupRect .height ; ++y)
249
269
{
250
- int sourceIndex = y * popupPitch;
251
- int destIndex = (y + m_RenderData.popupRect .y ) * pitch + m_RenderData.popupRect .x * 4 ;
270
+ if (m_pWebBrowserRenderItem->m_IsARGB )
271
+ {
272
+ int sourceIndex = y * popupPitch;
273
+ int destIndex = (y + m_RenderData.popupRect .y ) * pitch + m_RenderData.popupRect .x * 4 ;
252
274
253
- memcpy (&surfaceData[destIndex], &m_RenderData.popupBuffer [sourceIndex], popupPitch);
275
+ memcpy (&surfaceData[destIndex], &m_RenderData.popupBuffer [sourceIndex], popupPitch);
276
+ }
277
+ else
278
+ {
279
+ for (int x = 0 ; x < m_RenderData.popupRect .width ; ++x)
280
+ {
281
+ int sourceIndex = y * popupPitch + x * 4 ;
282
+ int destIndex = (y + m_RenderData.popupRect .y ) * pitch + (m_RenderData.popupRect .x + x) * 4 ;
283
+ const uint32_t sourcePixel = *reinterpret_cast <const std::uint32_t *>(&m_RenderData.popupBuffer [sourceIndex]);
284
+
285
+ *reinterpret_cast <std::uint32_t *>(&surfaceData[destIndex]) = (sourcePixel & 0xFF00FF00 ) | ((sourcePixel & 0x00FF0000 ) >> 16 ) | ((sourcePixel & 0x000000FF ) << 16 );
286
+ }
287
+ }
254
288
}
255
289
}
256
290
0 commit comments