Merge DrawContext into UIContext.

This commit is contained in:
Henrik Rydgard committed 2013-05-28 00:32:00 +02:00
1 parent cbf1b2d29d
commit f075c8fd56
13 files changed
+145 -184

No files matched your search

+28
View File
@@ -68,4 +68,32 @@ void UIContext::End()
{
UIEnd();
Flush();
}
// TODO: Support transformed bounds using stencil
void UIContext::PushScissor(const Bounds &bounds) {
Flush();
scissorStack_.push_back(bounds);
ActivateTopScissor();
}
void UIContext::PopScissor() {
Flush();
scissorStack_.pop_back();
ActivateTopScissor();
}
void UIContext::ActivateTopScissor() {
if (scissorStack_.size()) {
const Bounds &bounds = scissorStack_.back();
int x = g_dpi_scale * bounds.x;
int y = g_dpi_scale * (dp_yres - bounds.y2());
int w = g_dpi_scale * bounds.w;
int h = g_dpi_scale * bounds.h;
glstate.scissorRect.set(x,y,w,h);
glstate.scissorTest.enable();
} else {
glstate.scissorTest.disable();
}
}