initial cursor support (just getting the image and location), not drawing correctly yet

This commit is contained in:
betzalel
2018-01-18 09:22:11 +02:00
parent 16eba765cd
commit 5cd902341d
4 changed files with 45 additions and 3 deletions

View File

@@ -45,6 +45,7 @@ const (
EncJPEGQualityLevelPseudo3 EncodingType = -30
EncJPEGQualityLevelPseudo2 EncodingType = -31
EncJPEGQualityLevelPseudo1 EncodingType = -32
EncPointerPosPseudo EncodingType = -232
EncCursorPseudo EncodingType = -239
EncXCursorPseudo EncodingType = -240
EncDesktopSizePseudo EncodingType = -223
@@ -80,7 +81,7 @@ var bPool = sync.Pool{
}
type Renderer interface {
SetTargetImage(draw.Image)
SetTargetImage(draw.Image)
}
// Encoding represents interface for vnc encoding

View File

@@ -4,6 +4,7 @@ import (
"encoding/binary"
"image/color"
"image/draw"
"vnc2video/logger"
)
type CursorPseudoEncoding struct {
@@ -27,6 +28,7 @@ func (enc *CursorPseudoEncoding) Reset() error {
func (*CursorPseudoEncoding) Type() EncodingType { return EncCursorPseudo }
func (enc *CursorPseudoEncoding) Read(c Conn, rect *Rectangle) error {
logger.Debugf("CursorPseudoEncoding.Read: got rect: %v", rect)
//rgba := make([]byte, int(rect.Height)*int(rect.Width)*int(c.PixelFormat().BPP/8))
numColors := int(rect.Height) * int(rect.Width)
colors := make([]color.Color, numColors)
@@ -53,7 +55,8 @@ func (enc *CursorPseudoEncoding) Read(c Conn, rect *Rectangle) error {
for x := 0; x < int(rect.Width); x++ {
offset := y*int(rect.Width) + x
if bitmask[y*int(scanLine)+x/8]&(1<<uint(7-x%8)) > 0 {
enc.Image.Set(x, y, colors[offset])
enc.Image.Set(x+int(rect.X), y+int(rect.Y), colors[offset])
//logger.Debugf("CursorPseudoEncoding.Read: setting pixel: (%d,%d) %v", x+int(rect.X), y+int(rect.Y), colors[offset])
}
}
}

View File

@@ -101,7 +101,7 @@ func (z *HextileEncoding) Read(r Conn, rect *Rectangle) error {
//logger.Debugf("%v %v", rBounds, bgCol)
}
rBounds := image.Rectangle{Min: image.Point{int(tx), int(ty)}, Max: image.Point{int(tx) + int(tw), int(ty) + int(th)}}
logger.Debugf("filling background rect: %v, col: %v", rBounds, bgCol)
//logger.Debugf("filling background rect: %v, col: %v", rBounds, bgCol)
FillRect(z.Image, &rBounds, bgCol)
if (subencoding & HextileForegroundSpecified) != 0 {

38
encoding_pointer_pos.go Normal file
View File

@@ -0,0 +1,38 @@
package vnc2video
import (
"image"
"image/draw"
"vnc2video/logger"
)
type CursorPosPseudoEncoding struct {
prevPosBackup draw.Image
prevPositionRect image.Rectangle
cursorImage draw.Image
Image draw.Image
}
func (*CursorPosPseudoEncoding) Supported(Conn) bool {
return true
}
func (enc *CursorPosPseudoEncoding) SetTargetImage(img draw.Image) {
enc.Image = img
}
func (enc *CursorPosPseudoEncoding) Reset() error {
return nil
}
func (*CursorPosPseudoEncoding) Type() EncodingType { return EncPointerPosPseudo }
func (enc *CursorPosPseudoEncoding) Read(c Conn, rect *Rectangle) error {
logger.Debugf("CursorPosPseudoEncoding: got cursot pos update: %v", rect)
return nil
}
func (enc *CursorPosPseudoEncoding) Write(c Conn, rect *Rectangle) error {
return nil
}