@@ -42,8 +42,7 @@ void CClientVectorGraphicDisplay::Render()
42
42
if (HasUpdated ())
43
43
{
44
44
m_pVectorGraphic->OnUpdate ();
45
- }
46
-
45
+ }
47
46
}
48
47
49
48
void CClientVectorGraphicDisplay::UpdateTexture ()
@@ -52,46 +51,41 @@ void CClientVectorGraphicDisplay::UpdateTexture()
52
51
return ;
53
52
54
53
Document* svgDocument = m_pVectorGraphic->GetSVGDocument ();
55
-
56
- if (svgDocument == nullptr )
54
+ if (!svgDocument)
57
55
return ;
58
56
59
57
CVectorGraphicItem* pVectorGraphicItem = m_pVectorGraphic->GetRenderItem ();
60
-
61
58
if (!pVectorGraphicItem)
62
59
return ;
63
60
64
61
IDirect3DSurface9* surface = m_pVectorGraphic->GetRenderItem ()->m_pD3DRenderTargetSurface ;
65
-
66
62
if (!surface)
67
63
return ;
68
64
69
- IDirect3DDevice9* device = pVectorGraphicItem->m_pDevice ;
70
-
71
- uint width = pVectorGraphicItem->m_uiSizeX ;
72
- uint height = pVectorGraphicItem->m_uiSizeY ;
73
-
74
- Bitmap bitmap = svgDocument->renderToBitmap (width, height);
65
+ Bitmap bitmap = svgDocument->renderToBitmap (pVectorGraphicItem->m_uiSizeX , pVectorGraphicItem->m_uiSizeY );
66
+ if (!bitmap.valid ())
67
+ return ;
75
68
76
69
// Lock surface
77
70
D3DLOCKED_RECT LockedRect;
78
- surface->LockRect (&LockedRect, nullptr , 0 );
71
+ if (SUCCEEDED (surface->LockRect (&LockedRect, nullptr , D3DLOCK_DISCARD)))
72
+ {
73
+ auto surfaceData = static_cast <byte*>(LockedRect.pBits );
74
+ auto sourceData = static_cast <const byte*>(bitmap.data ());
79
75
80
- auto surfaceData = static_cast <byte*>(LockedRect.pBits );
81
- auto sourceData = static_cast <const byte*>(bitmap.data ());
76
+ for (uint32_t y = 0 ; y < bitmap.height (); ++y)
77
+ {
78
+ memcpy (surfaceData, sourceData, bitmap.width () * 4 ); // 4 bytes per pixel
82
79
83
- for (uint32_t y = 0 ; y < bitmap.height (); ++y)
84
- {
85
- memcpy (surfaceData, sourceData, bitmap.width () * 4 ); // 4 bytes per pixel
80
+ // advance row pointers
81
+ sourceData += bitmap.stride ();
82
+ surfaceData += LockedRect.Pitch ;
83
+ }
86
84
87
- // advance row pointers
88
- sourceData += bitmap.stride ();
89
- surfaceData += LockedRect.Pitch ;
85
+ // Unlock surface
86
+ surface->UnlockRect ();
90
87
}
91
88
92
- // Unlock surface
93
- surface->UnlockRect ();
94
-
95
89
m_bHasUpdated = false ;
96
90
}
97
91
@@ -101,25 +95,22 @@ void CClientVectorGraphicDisplay::ClearTexture()
101
95
return ;
102
96
103
97
CVectorGraphicItem* pVectorGraphicItem = m_pVectorGraphic->GetRenderItem ();
104
-
105
98
if (!pVectorGraphicItem)
106
99
return ;
107
100
108
101
IDirect3DSurface9* surface = pVectorGraphicItem->m_pD3DRenderTargetSurface ;
109
-
110
102
if (!surface)
111
103
return ;
112
104
113
- IDirect3DDevice9* device = pVectorGraphicItem->m_pDevice ;
114
-
115
105
// Lock surface
116
106
D3DLOCKED_RECT LockedRect;
117
- surface->LockRect (&LockedRect, nullptr , 0 );
118
-
119
- device-> ColorFill (surface, nullptr , D3DCOLOR_ARGB ( 0 , 0 , 0 , 0 ) );
107
+ if ( SUCCEEDED ( surface->LockRect (&LockedRect, nullptr , D3DLOCK_DISCARD)))
108
+ {
109
+ std::memset (LockedRect. pBits , 0x0 , LockedRect. Pitch * pVectorGraphicItem-> m_uiSurfaceSizeY );
120
110
121
- // Unlock surface
122
- surface->UnlockRect ();
111
+ // Unlock surface
112
+ surface->UnlockRect ();
113
+ }
123
114
124
115
m_bIsCleared = true ;
125
116
}
0 commit comments