修复flutter win7系统下放置一段时间后卡死问题

bool FlutterWindowWin32::OnBitmapSurfaceUpdated(const void* allocation,
                                                size_t row_bytes,
                                                size_t height) {
  HWND hwnd = std::get<HWND>(GetRenderTarget());
  HDC dc = ::GetDC(hwnd);
  BITMAPINFO bmi;
  memset(&bmi, 0, sizeof(bmi));
  bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
  bmi.bmiHeader.biWidth = row_bytes / 4;
  bmi.bmiHeader.biHeight = -height;
  bmi.bmiHeader.biPlanes = 1;
  bmi.bmiHeader.biBitCount = 32;
  bmi.bmiHeader.biCompression = BI_RGB;
  bmi.bmiHeader.biSizeImage = 0;
  int ret = SetDIBitsToDevice(dc, 0, 0, row_bytes / 4, height, 0, 0, 0, height,
                              allocation, &bmi, DIB_RGB_COLORS);

  ReleaseDC(hwnd, dc);//原来没有调用releaseDC,加上就可以了
  return ret != 0;
}

直接上代码,重新编译flutter_windows.dll 

转载注明出处,from 博客园HemJohn

posted on 2023-01-09 16:20  HemJohn  阅读(91)  评论(0编辑  收藏  举报

导航