Esempio n. 1
0
void
BGLView::DirectConnected(direct_buffer_info *info)
{
	if (!fClipInfo/* && m_direct_connection_disabled*/) {
		fClipInfo = new glview_direct_info();
	}

	glview_direct_info *glviewDirectInfo = (glview_direct_info *)fClipInfo;
	direct_buffer_info *localInfo = glviewDirectInfo->direct_info;
	
	switch(info->buffer_state & B_DIRECT_MODE_MASK) { 
		case B_DIRECT_START:
			glviewDirectInfo->direct_connected = true;
			_UnlockDraw();
		case B_DIRECT_MODIFY:
		{
			_LockDraw();
			localInfo->buffer_state = info->buffer_state;
			localInfo->driver_state = info->driver_state;
			localInfo->bits = info->bits;
			localInfo->pci_bits = info->pci_bits;
			localInfo->bytes_per_row = info->bytes_per_row;
			localInfo->bits_per_pixel = info->bits_per_pixel;
			localInfo->pixel_format = info->pixel_format;
			localInfo->layout = info->layout;
			localInfo->orientation = info->orientation;
			//memcpy(&localInfo->_reserved, info->_reserved, sizeof(info->_reserved));
			//localInfo->_dd_type_ = info->_dd_type_;
			//localInfo->_dd_token_ = info->_dd_token_;

			// Collect the rects into a BRegion, then clip to the view's bounds
			BRegion region;
			for (uint32 c = 0; c < info->clip_list_count; c++)
				region.Include(info->clip_list[c]);
			BRegion boundsRegion = fBounds.OffsetByCopy(info->window_bounds.left, info->window_bounds.top);
			localInfo->window_bounds = boundsRegion.RectAtInt(0); // window_bounds are now view bounds
			region.IntersectWith(&boundsRegion);
				
			localInfo->clip_list_count = region.CountRects();
			localInfo->clip_bounds = region.FrameInt();
			
			for (uint32 c = 0; c < localInfo->clip_list_count; c++)
				localInfo->clip_list[c] = region.RectAtInt(c);
			
			_UnlockDraw();
			break; 
		}		
		case B_DIRECT_STOP: 
			glviewDirectInfo->direct_connected = false;
			_LockDraw();
			break; 
	} 
	
	if (fRenderer)
		fRenderer->DirectConnected(localInfo);
}
Esempio n. 2
0
status_t
DirectWindowInfo::SetState(direct_buffer_state bufferState,
	direct_driver_state driverState, RenderingBuffer* buffer,
	const BRect& windowFrame, const BRegion& clipRegion)
{
	if ((fBufferInfo->buffer_state & B_DIRECT_MODE_MASK) == B_DIRECT_STOP
		&& (bufferState & B_DIRECT_MODE_MASK) != B_DIRECT_START)
		return B_OK;

	fBufferInfo->buffer_state = bufferState;

	if (driverState != -1)
		fBufferInfo->driver_state = driverState;

	if ((bufferState & B_DIRECT_MODE_MASK) != B_DIRECT_STOP) {
		fBufferInfo->bits = buffer->Bits();
		fBufferInfo->pci_bits = NULL; // TODO
		fBufferInfo->bytes_per_row = buffer->BytesPerRow();

		switch (buffer->ColorSpace()) {
			case B_RGB32:
			case B_RGBA32:
			case B_RGB32_BIG:
			case B_RGBA32_BIG:
				fBufferInfo->bits_per_pixel = 32;
				break;
			case B_RGB24:
			case B_RGB24_BIG:
				fBufferInfo->bits_per_pixel = 24;
				break;
			case B_RGB16:
			case B_RGB16_BIG:
			case B_RGB15:
			case B_RGB15_BIG:
				fBufferInfo->bits_per_pixel = 16;
				break;
			case B_CMAP8:
			case B_GRAY8:
				fBufferInfo->bits_per_pixel = 8;
				break;
			default:
				syslog(LOG_ERR,
					"unknown colorspace in DirectWindowInfo::SetState()!\n");
				fBufferInfo->bits_per_pixel = 0;
				break;
		}

		fBufferInfo->pixel_format = buffer->ColorSpace();
		fBufferInfo->layout = B_BUFFER_NONINTERLEAVED;
		fBufferInfo->orientation = B_BUFFER_TOP_TO_BOTTOM;
			// TODO
		fBufferInfo->window_bounds = to_clipping_rect(windowFrame);

		const int32 kMaxClipRectsCount = (DIRECT_BUFFER_INFO_AREA_SIZE
			- sizeof(direct_buffer_info)) / sizeof(clipping_rect);

		fBufferInfo->clip_list_count = min_c(clipRegion.CountRects(),
			kMaxClipRectsCount);
		fBufferInfo->clip_bounds = clipRegion.FrameInt();

		for (uint32 i = 0; i < fBufferInfo->clip_list_count; i++)
			fBufferInfo->clip_list[i] = clipRegion.RectAtInt(i);
	}

	return _SyncronizeWithClient();
}