예제 #1
0
bool
StateBrush_Context::build_transform_stack(
	Canvas::Handle canvas,
	Layer::Handle layer,
	CanvasView::Handle canvas_view,
	TransformStack& transform_stack )
{
	int count = 0;
	for(Canvas::iterator i = canvas->begin(); i != canvas->end() ;++i)
	{
		if(*i == layer) return true;

		if((*i)->active())
		{
			Transform::Handle trans((*i)->get_transform());
			if(trans) { transform_stack.push(trans); count++; }
		}

		// If this is a paste canvas layer, then we need to
		// descend into it
		if(etl::handle<Layer_PasteCanvas> layer_pastecanvas = etl::handle<Layer_PasteCanvas>::cast_dynamic(*i))
		{
			transform_stack.push_back(
				new Transform_Matrix(
						layer_pastecanvas->get_guid(),
					layer_pastecanvas->get_summary_transformation().get_matrix()
				)
			);
			if (build_transform_stack(layer_pastecanvas->get_sub_canvas(), layer, canvas_view, transform_stack))
				return true;
			transform_stack.pop();
		}
	}
	while(count-- > 0) transform_stack.pop();
	return false;
}
예제 #2
0
    void scheduleDrawOp(DrawOp op)
    {
        if (clipRectStack.clippedWorldAway())
            return;

        #ifdef GOSU_IS_IPHONE
        // No triangles, no lines supported
        assert (op.verticesOrBlockIndex == 4);
        #endif

        op.renderState.transform = &transformStack.current();
        if (const ClipRect* cr = clipRectStack.maybeEffectiveRect())
            op.renderState.clipRect = *cr;
        ops.push_back(op);
    }
예제 #3
0
    void scheduleGL(std::tr1::function<void()> glBlock, ZPos z)
    {
        // TODO: Document this case: Clipped-away GL blocks are *not* being run.
        if (clipRectStack.clippedWorldAway())
            return;

        int complementOfBlockIndex = ~(int)glBlocks.size();
        glBlocks.push_back(glBlock);

        DrawOp op;
        op.verticesOrBlockIndex = complementOfBlockIndex;
        op.renderState.transform = &transformStack.current();
        if (const ClipRect* cr = clipRectStack.maybeEffectiveRect())
            op.renderState.clipRect = *cr;
        op.z = z;
        ops.push_back(op);
    }
예제 #4
0
    void beginClipping(double x, double y, double width, double height, double screenHeight)
    {
        // Apply current transformation.

        double left = x, right = x + width;
        double top = y, bottom = y + height;

        applyTransform(transformStack.current(), left, top);
        applyTransform(transformStack.current(), right, bottom);

        double physX = std::min(left, right);
        double physY = std::min(top, bottom);
        double physWidth = std::abs(left - right);
        double physHeight = std::abs(top - bottom);

        // Adjust for OpenGL having the wrong idea of where y=0 is.
        // TODO: This should really happen *right before* setting up
        // the glScissor.
        physY = screenHeight - physY - physHeight;

        clipRectStack.beginClipping(physX, physY, physWidth, physHeight);
    }
예제 #5
0
 void popTransform()
 {
     transformStack.pop();
 }
예제 #6
0
 void pushTransform(const Transform& transform)
 {
     transformStack.push(transform);
 }
예제 #7
0
 void setBaseTransform(const Transform& baseTransform)
 {
     transformStack.setBaseTransform(baseTransform);
 }
예제 #8
0
 // This clears the queue and starts with new stacks. This must not be called
 // when endClipping/popTransform calls might still be pending.
 void reset()
 {
     transformStack.reset();
     clipRectStack.clear();
     clearQueue();
 }