Qt: much faster DCSetPixel when painter is QImage or QPixmap. issue #29256

git-svn-id: trunk@51040 -
This commit is contained in:
zeljko 2015-12-26 16:30:37 +00:00
parent b8d42c3a62
commit 60c709a66b

View File

@ -1233,14 +1233,29 @@ end;
procedure TQtWidgetSet.DCSetPixel(CanvasHandle: HDC; X, Y: integer; AColor: TGraphicsColor);
var
Color: TQColor;
AQColor: QColorH;
ColorRef: TColorRef;
Pen: QPenH;
Painter: QPainterH;
ADevType: Integer;
begin
if IsValidDC(CanvasHandle) then
begin
// WriteLn('TQtWidgetSet.DCSetPixel X=',X,' Y=',Y, ' AColor=',dbghex(AColor),' rgb ? ',dbgHex(ColorToRGB(AColor)));
Painter := TQtDeviceContext(CanvasHandle).Widget;
ADevType := QPaintDevice_devType(QPaintEngine_paintDevice(QPainter_paintEngine(Painter)));
{qt private PaintDeviceFlags 2 = QPixmap 3 = QImage. issue #29256}
if ((ADevType = 2) or (ADevType = 3)) and
(TQtDeviceContext(CanvasHandle).vImage <> nil) and
(TQtDeviceContext(CanvasHandle).vImage.Handle <> nil) then
begin
ColorRef := TColorRef(ColorToRGB(AColor));
QColor_fromRgb(@Color, Red(ColorRef), Green(ColorRef), Blue(ColorRef));
AQColor := QColor_create(PQColor(@Color));
QImage_setPixel(TQtDeviceContext(CanvasHandle).vImage.Handle, X, Y, QColor_rgb(AQColor));
QColor_destroy(AQColor);
end else
begin
{Save current pen.Better save copy of pen instead of
using painter save/restore, or saved Pen in devicecontext which
may be null. Issue #27620}
@ -1256,6 +1271,7 @@ begin
end;
end;
end;
end;
procedure TQtWidgetSet.DCRedraw(CanvasHandle: HDC);
begin