RectList DDClipper::GetRectangles(const RectList &rect_list) const { RectList rects; for( int i=0; i!=rect_list.size(); ++i) { RectList rcs = GetRectangles( rect_list[i] ); for( int k=0; k!=rcs.size(); ++k ) rects.push_back( rcs[k] ); } return rects; }
/** * Merges any clipping rectangles that overlap to try and reduce * the total number of clip rectangles. */ void MergeClipRect() { if (s_rectList.size() <= 1) return; RectList::iterator rOuter, rInner; for (rOuter = s_rectList.begin(); rOuter != s_rectList.end(); ++rOuter) { rInner = rOuter; while (++rInner != s_rectList.end()) { if (LooseIntersectRectangle(*rOuter, *rInner)) { // these two rectangles overlap or // are next to each other - merge them UnionRectangle(*rOuter, *rOuter, *rInner); // remove the inner rect from the list s_rectList.erase(rInner); // move back to beginning of list rInner = rOuter; } } } }
DDClipper::DDClipper(const RectList &rect_list): _dd_clipper(NULL) { int i,j,num,size =num= rect_list.size(); for ( j=0; j!=size; ++j ) { if (!rect_list[j]) --num; } if (num > 0) { DDraw7Ptr dd = DDCreator::GetDirectDraw(); dd->CreateClipper(0, &_dd_clipper, NULL); MemBlock region_buffer( sizeof(RGNDATAHEADER) + sizeof(RECT)*num ); LPRGNDATA regn = (LPRGNDATA)( region_buffer.GetPtr() ); regn->rdh.dwSize = sizeof(RGNDATAHEADER); regn->rdh.iType = RDH_RECTANGLES; regn->rdh.nCount = num; regn->rdh.nRgnSize = sizeof(RECT); LPRECT rc = (LPRECT)(regn->Buffer); Rect bound( rect_list[0] ); g_SizeLastRegion = 0; for(j=0, i=0; j!=size; ++j) { if (!rect_list[j]) { continue; } rc[i].left = rect_list[j].GetX1(); rc[i].top = rect_list[j].GetY1(); rc[i].right = rect_list[j].GetX2(); rc[i].bottom= rect_list[j].GetY2(); #ifdef DEBUG_REGION g_LastRegion[ g_SizeLastRegion++ ] = rc[i]; #endif bound |= rect_list[j]; ++i; } assert( i == num ); regn->rdh.rcBound.left = bound.GetX1(); regn->rdh.rcBound.top = bound.GetY1(); regn->rdh.rcBound.right = bound.GetX2(); regn->rdh.rcBound.bottom= bound.GetY2(); #ifdef DEBUG_REGION g_LastRegion[ g_SizeLastRegion++ ] = regn->rdh.rcBound; #endif if ( _dd_clipper->SetClipList(regn,0) != DD_OK ) { DDClipper_ERROR( Useless::Error("DDClipper::DDClipper() :SetClipList() failed") ); } } }
void BrowserClient::OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, int width, int height) { if (type == PET_VIEW && dirtyRects.size() > 0) { _image->setImage( width, height, 1, 4, GL_BGRA, GL_UNSIGNED_BYTE, (unsigned char*)(buffer), osg::Image::NO_DELETE ); } else if (type == PET_POPUP) { _popupImage->setImage( width, height, 1, 4, GL_BGRA, GL_UNSIGNED_BYTE, (unsigned char*)(buffer), osg::Image::NO_DELETE ); } }
void BrowserClient::OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, int width, int height) { if (type == PET_VIEW && dirtyRects.size() > 0) { if (_width != width || _height != height) { OE_DEBUG << LC << "[OnPaint] Dimensions do not match: " << width << " x " << height << " vs. " << _width << " x " << _height << std::endl; return; } _image->setImage( width, height, 1, 4, GL_BGRA, GL_UNSIGNED_BYTE, (unsigned char*)(buffer), osg::Image::NO_DELETE ); } else if (type == PET_POPUP) { _popupImage->setImage( width, height, 1, 4, GL_BGRA, GL_UNSIGNED_BYTE, (unsigned char*)(buffer), osg::Image::NO_DELETE ); } }
void RenderHandler::OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, int width, int height) { FUpdateTextureRegion2D * updateRegions = static_cast<FUpdateTextureRegion2D*>(FMemory::Malloc(sizeof(FUpdateTextureRegion2D) * dirtyRects.size())); int current = 0; for (auto dirtyRect : dirtyRects) { updateRegions[current].DestX = updateRegions[current].SrcX = dirtyRect.x; updateRegions[current].DestY = updateRegions[current].SrcY = dirtyRect.y; updateRegions[current].Height = dirtyRect.height; updateRegions[current].Width = dirtyRect.width; current++; } // Trigger our parent UIs Texture to update parentUI->TextureUpdate(buffer, updateRegions, dirtyRects.size()); }
void Surface::MultiBlit ( const Surface &surf, const PointList &p, const RectList &r, const Surf::BlitFX &fx ) { int ir, rsize = r.size(); int ip, psize = p.size(); for( ir=0, ip=0; ir!=rsize && ip!=psize; ++ir, ++ip ) { if (!r[ir]) continue; Pos ps = p[ip]; Rect rc = r[ir]; Blit( ps.x, ps.y , surf, rc, fx ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void SrcCefOSRRenderer::OnPaint(CefRefPtr<CefBrowser> browser, PaintElementType type, const RectList& dirtyRects, const void* buffer, int width, int height) { if( !m_pBrowser || !m_pBrowser->GetPanel() ) { Warning("SrcCefOSRRenderer::OnPaint: No browser or vgui panel yet\n"); return; } int channels = 4; if( type != PET_VIEW ) { Warning("SrcCefOSRRenderer::OnPaint: Unsupported paint type\n"); return; } Assert( dirtyRects.size() > 0 ); int dirtyx, dirtyy, dirtyxend, dirtyyend; dirtyx = width; dirtyy = height; dirtyxend = 0; dirtyyend = 0; //AUTO_LOCK( s_BufferMutex ); // Update image buffer size if needed if( m_iWidth != width || m_iHeight != height ) { if( m_pTextureBuffer != NULL ) { free( m_pTextureBuffer ); m_pTextureBuffer = NULL; } DevMsg("Texture buffer size changed from %dh %dw to %dw %dh\n", m_iWidth, m_iHeight, width, height ); m_iWidth = width; m_iHeight = height; m_pTextureBuffer = (unsigned char*) malloc( m_iWidth * m_iHeight * channels ); // Full dirty dirtyx = 0; dirtyy = 0; dirtyxend = m_iWidth; dirtyyend = m_iHeight; } const unsigned char *imagebuffer = (const unsigned char *)buffer; // Update dirty rects CefRenderHandler::RectList::const_iterator i = dirtyRects.begin(); for (; i != dirtyRects.end(); ++i) { const CefRect& rect = *i; for( int y = rect.y; y < rect.y + rect.height; y++ ) { memcpy( m_pTextureBuffer + (y * m_iWidth * channels) + (rect.x * channels), // Our current row + x offset imagebuffer + (y * m_iWidth * channels) + (rect.x * channels), // Source offset rect.width * channels // size of row we want to copy ); } // Update max dirty area dirtyx = Min( rect.x, dirtyx ); dirtyy = Min( rect.y, dirtyy ); dirtyxend = Max( rect.x + rect.width, dirtyxend ); dirtyyend = Max( rect.y + rect.height, dirtyyend ); } m_pBrowser->GetPanel()->MarkTextureDirty( dirtyx, dirtyy, dirtyxend, dirtyyend ); }