void VGraphicPath::_ComputeBounds() { if (fComputeBoundsAccurate) { if (fPathMin == GP_BOUNDS_MIN_DEFAULT || fPathMax == GP_BOUNDS_MAX_DEFAULT) fBounds = VRect(0,0,0,0); else fBounds.SetCoords( (GReal)fPathMin.x, (GReal)fPathMin.y, (GReal)(fPathMax.x-fPathMin.x), (GReal)(fPathMax.y-fPathMin.y)); } else { #if ENABLE_D2D if (fPathD2D != NULL) { if (fGeomSink == NULL) { D2D1_RECT_F bounds; fPathD2D->GetBounds( NULL, &bounds); fBounds.SetCoords( bounds.left, bounds.top, bounds.right-bounds.left, bounds.bottom-bounds.top); return; } } #endif #if !GRAPHIC_MIXED_GDIPLUS_D2D if (!VWinD2DGraphicContext::IsAvailable()) { #endif Gdiplus::RectF bounds; fPath->GetBounds( &bounds); fBounds = VRect ( bounds.GetLeft(), bounds.GetTop(), bounds.GetRight()-bounds.GetLeft(), bounds.GetBottom()-bounds.GetTop()); #if !GRAPHIC_MIXED_GDIPLUS_D2D } #endif } }
void Sprite::Invalidate() { // 0指针访问 不挂是因为x64系统一个bug 记得打开调试中的Win32异常断点 HostWindow *wnd = GetHostWindow(); if (wnd) { RECT rc; Gdiplus::RectF rf = GetAbsRect(); rc.left = (LONG)(rf.GetLeft() - 0.5f); rc.top = (LONG)(rf.GetTop() - 0.5f); // TODO FIXME 这个值是试出来的 不知其所以然 rc.right = (LONG)(rf.GetRight() + 1.5f); // 缩小窗口TabCtrl会有拖影 这里改成2 就可以消除拖影现象 rc.bottom = (LONG)(rf.GetBottom() + 1.5f); // 很诡异 可能是因为GdiPlus认为x取大的 width也取大的 ::InvalidateRect(wnd->GetHWND(), &rc, TRUE); } }