예제 #1
0
파일: blitter.go 프로젝트: linux-mac/gxui
func (b *blitter) blitRect(ctx *context, dstRect math.Rect, color gxui.Color, ds *drawState) {
	b.commitGlyphs(ctx)
	dstRect = dstRect.Offset(ds.OriginPixels)
	dw, dh := ctx.sizePixels.WH()
	mPos := math.CreateMat3(
		+2.0*float32(dstRect.W())/float32(dw), 0, 0,
		0, -2.0*float32(dstRect.H())/float32(dh), 0,
		-1.0+2.0*float32(dstRect.Min.X)/float32(dw),
		+1.0-2.0*float32(dstRect.Min.Y)/float32(dh), 1,
	)

	b.quad.draw(ctx, b.colorShader, uniformBindings{
		"mPos":  mPos,
		"Color": color,
	})
	b.stats.drawCallCount++
}
예제 #2
0
파일: blitter.go 프로젝트: linux-mac/gxui
func (b *blitter) blit(ctx *context, tc *textureContext, srcRect, dstRect math.Rect, ds *drawState) {
	b.commitGlyphs(ctx)

	dstRect = dstRect.Offset(ds.OriginPixels)
	sw, sh := tc.sizePixels.WH()
	dw, dh := ctx.sizePixels.WH()

	var mUV math.Mat3
	if tc.flipY {
		mUV = math.CreateMat3(
			float32(srcRect.W())/float32(sw), 0, 0,
			0, -float32(srcRect.H())/float32(sh), 0,
			float32(srcRect.Min.X)/float32(sw),
			1.0-float32(srcRect.Min.Y)/float32(sh), 1,
		)
	} else {
		mUV = math.CreateMat3(
			float32(srcRect.W())/float32(sw), 0, 0,
			0, float32(srcRect.H())/float32(sh), 0,
			float32(srcRect.Min.X)/float32(sw),
			float32(srcRect.Min.Y)/float32(sh), 1,
		)
	}
	mPos := math.CreateMat3(
		+2.0*float32(dstRect.W())/float32(dw), 0, 0,
		0, -2.0*float32(dstRect.H())/float32(dh), 0,
		-1.0+2.0*float32(dstRect.Min.X)/float32(dw),
		+1.0-2.0*float32(dstRect.Min.Y)/float32(dh), 1,
	)
	if !tc.pma {
		gl.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA)
	}
	b.quad.draw(ctx, b.copyShader, uniformBindings{
		"source": tc,
		"mUV":    mUV,
		"mPos":   mPos,
	})
	if !tc.pma {
		gl.BlendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA)
	}
	b.stats.drawCallCount++
}