Ejemplo n.º 1
0
//-----------------------------------------------------------------------------
void D2DDrawContext::endDraw ()
{
	if (renderTarget)
	{
		if (currentClip.isEmpty () == false)
		{
			getRenderTarget ()->PopAxisAlignedClip ();
			currentClip = CRect ();
		}
		renderTarget->Flush ();
		HRESULT result = renderTarget->EndDraw ();
		if (result == D2DERR_RECREATE_TARGET)
		{
			releaseRenderTarget ();
			createRenderTarget ();
		}
		else
		{
			vstgui_assert (result == S_OK);
		}
		if (bitmap)
		{
			D2DBitmap* d2dBitmap = dynamic_cast<D2DBitmap*> (bitmap->getPlatformBitmap ());
			D2DBitmapCache::instance ()->removeBitmap (d2dBitmap);
		}
	}
}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------
void D2DDrawContext::createRenderTarget ()
{
	if (window)
	{
		RECT rc;
		GetClientRect (window, &rc);

		D2D1_SIZE_U size = D2D1::SizeU (rc.right - rc.left, rc.bottom - rc.top);
		ID2D1HwndRenderTarget* hwndRenderTarget = 0;
		D2D1_PIXEL_FORMAT pixelFormat = D2D1::PixelFormat (DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED);
		HRESULT hr = getD2DFactory ()->CreateHwndRenderTarget (D2D1::RenderTargetProperties (gRenderTargetType, pixelFormat), D2D1::HwndRenderTargetProperties (window, size, D2D1_PRESENT_OPTIONS_RETAIN_CONTENTS), &hwndRenderTarget);
		if (SUCCEEDED (hr))
		{
			UINT dpix = 96;
			UINT dpiy = 96;
			hwndRenderTarget->SetDpi (static_cast<FLOAT> (dpix), static_cast<FLOAT> (dpiy));
			renderTarget = hwndRenderTarget;
		}
	}
	else if (bitmap)
	{
		D2DBitmap* d2dBitmap = dynamic_cast<D2DBitmap*> (bitmap->getPlatformBitmap ());
		if (d2dBitmap)
		{
			D2D1_RENDER_TARGET_TYPE targetType = D2D1_RENDER_TARGET_TYPE_SOFTWARE;
			D2D1_PIXEL_FORMAT pixelFormat = D2D1::PixelFormat (DXGI_FORMAT_UNKNOWN, D2D1_ALPHA_MODE_PREMULTIPLIED);
			getD2DFactory ()->CreateWicBitmapRenderTarget (d2dBitmap->getBitmap (), D2D1::RenderTargetProperties (targetType, pixelFormat), &renderTarget);
		}
	}
	vstgui_assert (renderTarget);
	init ();
}
Ejemplo n.º 3
0
//-----------------------------------------------------------------------------
bool CBitmap::addBitmap (IPlatformBitmap* platformBitmap)
{
	double scaleFactor = platformBitmap->getScaleFactor ();
	CPoint size (getWidth (), getHeight ());
	CPoint bitmapSize = platformBitmap->getSize ();
	bitmapSize.x /= scaleFactor;
	bitmapSize.y /= scaleFactor;
	if (size != bitmapSize)
	{
		vstgui_assert (size == bitmapSize, "wrong bitmap size");
		return false;
	}
	VSTGUI_RANGE_BASED_FOR_LOOP (BitmapVector, bitmaps, BitmapPointer, bitmap)
		if (bitmap->getScaleFactor () == scaleFactor || bitmap == platformBitmap)
		{
			vstgui_assert (bitmap->getScaleFactor () != scaleFactor && bitmap != platformBitmap);
			return false;
		}
	VSTGUI_RANGE_BASED_FOR_LOOP_END
	bitmaps.push_back (platformBitmap);
	return true;
}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------
bool CFrame::attached (CView* parent)
{
	if (isAttached ())
		return false;
	vstgui_assert (parent == this);
	if (CView::attached (parent))
	{
		pParentView = 0;

		FOREACHSUBVIEW
			pV->attached (this);
		ENDFOREACHSUBVIEW
		
		return true;
	}
	return false;
}
Ejemplo n.º 5
0
//-----------------------------------------------------------------------------
void CFrame::checkMouseViews (const CPoint& where, const CButtonState& buttons)
{
	if (mouseDownView)
		return;
	CPoint lp;
	CView* mouseView = getViewAt (where, GetViewOptions (GetViewOptions::kDeep|GetViewOptions::kMouseEnabled|GetViewOptions::kIncludeViewContainer));
	CView* currentMouseView = pMouseViews.empty () == false ? pMouseViews.back () : 0;
	if (currentMouseView == mouseView)
		return; // no change

	if (pTooltips)
	{
		if (currentMouseView)
			pTooltips->onMouseExited (currentMouseView);
		if (mouseView && mouseView != this)
			pTooltips->onMouseEntered (mouseView);
	}

	if (mouseView == 0 || mouseView == this)
	{
		clearMouseViews (where, buttons);
		return;
	}
	CViewContainer* vc = currentMouseView ? dynamic_cast<CViewContainer*> (currentMouseView) : 0;
	// if the currentMouseView is not a view container, we know that the new mouseView won't be a child of it and that all other
	// views in the list are viewcontainers
	if (vc == 0 && currentMouseView)
	{
		lp = where;
		currentMouseView->frameToLocal (lp);
		currentMouseView->onMouseExited (lp, buttons);
		callMouseObserverMouseExited (currentMouseView);
	#if DEBUG_MOUSE_VIEWS
		DebugPrint ("mouseExited : %p\n", currentMouseView);
	#endif
		currentMouseView->forget ();
		pMouseViews.remove (currentMouseView);
	}
	ViewList::reverse_iterator it = pMouseViews.rbegin ();
	while (it != pMouseViews.rend ())
	{
		vc = static_cast<CViewContainer*> ((*it));
		if (vc == mouseView)
			return;
		if (vc->isChild (mouseView, true) == false)
		{
			lp = where;
			vc->frameToLocal (lp);
			vc->onMouseExited (lp, buttons);
			callMouseObserverMouseExited (vc);
		#if DEBUG_MOUSE_VIEWS
			DebugPrint ("mouseExited : %p\n", vc);
		#endif
			vc->forget ();
			pMouseViews.erase (--it.base ());
		}
		else
			break;
	}
	vc = pMouseViews.empty () == false ? dynamic_cast<CViewContainer*> (pMouseViews.back ()) : 0;
	if (vc)
	{
		ViewList::iterator it2 = pMouseViews.end ();
		it2--;
		CView* container = mouseView;
		while ((vc = static_cast<CViewContainer*> (container->getParentView ())) != *it2)
		{
			pMouseViews.push_back (vc);
			vc->remember ();
			container = vc;
		}
		pMouseViews.push_back (mouseView);
		mouseView->remember ();
		it2++;
		while (it2 != pMouseViews.end ())
		{
			lp = where;
			(*it2)->frameToLocal (lp);
			(*it2)->onMouseEntered (lp, buttons);
			callMouseObserverMouseEntered ((*it2));
		#if DEBUG_MOUSE_VIEWS
			DebugPrint ("mouseEntered : %p\n", (*it2));
		#endif
			it2++;
		}
	}
	else
	{
		// must be pMouseViews.size () == 0
		vstgui_assert (pMouseViews.empty ());
		pMouseViews.push_back (mouseView);
		mouseView->remember ();
		while ((vc = static_cast<CViewContainer*> (mouseView->getParentView ())) != this)
		{
			pMouseViews.push_front (vc);
			vc->remember ();
			mouseView = vc;
		}
		ViewList::iterator it2 = pMouseViews.begin ();
		while (it2 != pMouseViews.end ())
		{
			lp = where;
			(*it2)->frameToLocal (lp);
			(*it2)->onMouseEntered (lp, buttons);
			callMouseObserverMouseEntered ((*it2));
		#if DEBUG_MOUSE_VIEWS
			DebugPrint ("mouseEntered : %p\n", (*it2));
		#endif
			it2++;
		}
	}
}
Ejemplo n.º 6
0
	void unuse ()
	{
		vstgui_assert (useCount > 0);
		if (--useCount == 0)
			releaseFactory ();
	}