diff options
author | Neil <nyamatongwe@gmail.com> | 2021-03-25 12:38:31 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2021-03-25 12:38:31 +1100 |
commit | 92c9516b7b6e63f1bc15758232beb87d118570c3 (patch) | |
tree | e8cd7cc6aa729448167f17df4eb6865e0fe1ae91 | |
parent | b025ffaf21228dad59af262b523cf991f26190dc (diff) | |
download | scintilla-mirror-92c9516b7b6e63f1bc15758232beb87d118570c3.tar.gz |
Remove old Surface methods that have been replaced.
-rw-r--r-- | cocoa/PlatCocoa.h | 17 | ||||
-rw-r--r-- | cocoa/PlatCocoa.mm | 292 | ||||
-rwxr-xr-x | gtk/PlatGTK.cxx | 218 | ||||
-rw-r--r-- | qt/ScintillaEditBase/PlatQt.cpp | 143 | ||||
-rw-r--r-- | qt/ScintillaEditBase/PlatQt.h | 29 | ||||
-rw-r--r-- | src/Platform.h | 15 | ||||
-rw-r--r-- | win32/PlatWin.cxx | 382 |
7 files changed, 2 insertions, 1094 deletions
diff --git a/cocoa/PlatCocoa.h b/cocoa/PlatCocoa.h index 83b724df9..70a9b68f1 100644 --- a/cocoa/PlatCocoa.h +++ b/cocoa/PlatCocoa.h @@ -42,8 +42,6 @@ namespace Scintilla { class SurfaceImpl : public Surface { private: SurfaceMode mode; - float x; - float y; CGContextRef gc; @@ -58,7 +56,6 @@ private: int bitmapHeight; /** Set the CGContext's fill colour to the specified desired colour. */ - void FillColour(const ColourDesired &back); void FillColour(ColourAlpha fill); void PenColourAlpha(ColourAlpha fore); @@ -80,7 +77,6 @@ public: void Init(WindowID wid) override; void Init(SurfaceID sid, WindowID wid) override; - void InitPixMap(int width, int height, Surface *surface_, WindowID wid) override; std::unique_ptr<Surface> AllocatePixMap(int width, int height) override; std::unique_ptr<SurfaceImpl> AllocatePixMapImplementation(int width, int height); CGContextRef GetContext() { return gc; } @@ -90,7 +86,6 @@ public: void Release() noexcept override; int Supports(int feature) noexcept override; bool Initialised() override; - void PenColour(ColourDesired fore) override; /** Returns a CGImageRef that represents the surface. Returns NULL if this is not possible. */ CGImageRef CreateImage(); @@ -99,27 +94,18 @@ public: int LogPixelsY() override; int PixelDivisions() override; int DeviceHeightFont(int points) override; - void MoveTo(int x_, int y_) override; - void LineTo(int x_, int y_) override; void LineDraw(Point start, Point end, Stroke stroke) override; void PolyLine(const Point *pts, size_t npts, Stroke stroke) override; - void Polygon(Scintilla::Point *pts, size_t npts, ColourDesired fore, ColourDesired back) override; void Polygon(const Scintilla::Point *pts, size_t npts, FillStroke fillStroke) override; - void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) override; void RectangleDraw(PRectangle rc, FillStroke fillStroke) override; void RectangleFrame(PRectangle rc, Stroke stroke) override; - void FillRectangle(PRectangle rc, ColourDesired back) override; void FillRectangle(PRectangle rc, Fill fill) override; void FillRectangleAligned(PRectangle rc, Fill fill) override; void FillRectangle(PRectangle rc, Surface &surfacePattern) override; - void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) override; void RoundedRectangle(PRectangle rc, FillStroke fillStroke) override; - void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, - ColourDesired outline, int alphaOutline, int flags) override; void AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke) override; void GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options) override; void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) override; - void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) override; void Ellipse(PRectangle rc, FillStroke fillStroke) override; void Stadium(PRectangle rc, FillStroke fillStroke, Ends ends) override; void Copy(PRectangle rc, Scintilla::Point from, Surface &surfaceSource) override; @@ -152,9 +138,6 @@ public: void FlushCachedState() override; void FlushDrawing() override; - void SetUnicodeMode(bool unicodeMode_) override; - void SetDBCSMode(int codePage_) override; - void SetBidiR2L(bool bidiR2L_) override; }; // SurfaceImpl class } // Scintilla namespace diff --git a/cocoa/PlatCocoa.mm b/cocoa/PlatCocoa.mm index d509145d2..0e1897438 100644 --- a/cocoa/PlatCocoa.mm +++ b/cocoa/PlatCocoa.mm @@ -352,8 +352,6 @@ const int SupportsCocoa[] = { //----------------- SurfaceImpl -------------------------------------------------------------------- SurfaceImpl::SurfaceImpl() { - x = 0; - y = 0; gc = NULL; textLayout.reset(new QuartzTextLayout()); @@ -367,8 +365,6 @@ SurfaceImpl::SurfaceImpl() { } SurfaceImpl::SurfaceImpl(const SurfaceImpl *surface, int width, int height) { - x = 0; - y = 0; textLayout.reset(new QuartzTextLayout()); @@ -439,8 +435,6 @@ void SurfaceImpl::Clear() { bitmapWidth = 0; bitmapHeight = 0; - x = 0; - y = 0; } //-------------------------------------------------------------------------------------------------- @@ -476,58 +470,6 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID) { CGContextSetLineWidth(gc, 1.0); } -//-------------------------------------------------------------------------------------------------- - -void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID /* wid */) { - Release(); - - // Create a new bitmap context, along with the RAM for the bitmap itself - bitmapWidth = width; - bitmapHeight = height; - - const int bitmapBytesPerRow = (width * BYTES_PER_PIXEL); - const int bitmapByteCount = (bitmapBytesPerRow * height); - - // Create an RGB color space. - CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); - if (colorSpace == NULL) - return; - - // Create the bitmap. - bitmapData.reset(new uint8_t[bitmapByteCount]); - // create the context - gc = CGBitmapContextCreate(bitmapData.get(), - width, - height, - BITS_PER_COMPONENT, - bitmapBytesPerRow, - colorSpace, - kCGImageAlphaPremultipliedLast); - - if (gc == NULL) { - // the context couldn't be created for some reason, - // and we have no use for the bitmap without the context - bitmapData.reset(); - } - - // the context retains the color space, so we can release it - CGColorSpaceRelease(colorSpace); - - if (gc && bitmapData) { - // "Erase" to white. - CGContextClearRect(gc, CGRectMake(0, 0, width, height)); - CGContextSetRGBFillColor(gc, 1.0, 1.0, 1.0, 1.0); - CGContextFillRect(gc, CGRectMake(0, 0, width, height)); - } - - if (surface_) { - SurfaceImpl *psurfOther = static_cast<SurfaceImpl *>(surface_); - mode = psurfOther->mode; - } else { - mode.codePage = SC_CP_UTF8; - } -} - std::unique_ptr<Surface> SurfaceImpl::AllocatePixMap(int width, int height) { return std::make_unique<SurfaceImpl>(this, width, height); } @@ -554,18 +496,6 @@ int SurfaceImpl::Supports(int feature) noexcept { //-------------------------------------------------------------------------------------------------- -void SurfaceImpl::PenColour(ColourDesired fore) { - if (gc) { - ColourDesired colour(fore.AsInteger()); - - // Set the Stroke color to match - CGContextSetRGBStrokeColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0, - colour.GetBlue() / 255.0, 1.0); - } -} - -//-------------------------------------------------------------------------------------------------- - void SurfaceImpl::FillColour(ColourAlpha fill) { // Set the Fill color to match CGContextSetRGBFillColor(gc, @@ -577,18 +507,6 @@ void SurfaceImpl::FillColour(ColourAlpha fill) { //-------------------------------------------------------------------------------------------------- -void SurfaceImpl::FillColour(const ColourDesired &back) { - if (gc) { - ColourDesired colour(back.AsInteger()); - - // Set the Fill color to match - CGContextSetRGBFillColor(gc, colour.GetRed() / 255.0, colour.GetGreen() / 255.0, - colour.GetBlue() / 255.0, 1.0); - } -} - -//-------------------------------------------------------------------------------------------------- - void SurfaceImpl::PenColourAlpha(ColourAlpha fore) { // Set the Stroke color to match CGContextSetRGBStrokeColor(gc, @@ -699,30 +617,6 @@ int SurfaceImpl::DeviceHeightFont(int points) { //-------------------------------------------------------------------------------------------------- -void SurfaceImpl::MoveTo(int x_, int y_) { - x = x_; - y = y_; -} - -//-------------------------------------------------------------------------------------------------- - -void SurfaceImpl::LineTo(int x_, int y_) { - CGContextBeginPath(gc); - - // Because Quartz is based on floating point, lines are drawn with half their colour - // on each side of the line. Integer coordinates specify the INTERSECTION of the pixel - // division lines. If you specify exact pixel values, you get a line that - // is twice as thick but half as intense. To get pixel aligned rendering, - // we render the "middle" of the pixels by adding 0.5 to the coordinates. - CGContextMoveToPoint(gc, x + 0.5, y + 0.5); - CGContextAddLineToPoint(gc, x_ + 0.5, y_ + 0.5); - CGContextStrokePath(gc); - x = x_; - y = y_; -} - -//-------------------------------------------------------------------------------------------------- - void SurfaceImpl::LineDraw(Point start, Point end, Stroke stroke) { PenColourAlpha(stroke.colour); CGContextSetLineWidth(gc, stroke.width); @@ -756,33 +650,6 @@ void SurfaceImpl::PolyLine(const Point *pts, size_t npts, Stroke stroke) { //-------------------------------------------------------------------------------------------------- -void SurfaceImpl::Polygon(Scintilla::Point *pts, size_t npts, ColourDesired fore, - ColourDesired back) { - // Allocate memory for the array of points. - std::vector<CGPoint> points(npts); - - for (size_t i = 0; i < npts; i++) { - // Quartz floating point issues: plot the MIDDLE of the pixels - points[i].x = pts[i].x + 0.5; - points[i].y = pts[i].y + 0.5; - } - - CGContextBeginPath(gc); - - // Set colours - FillColour(back); - PenColour(fore); - - // Draw the polygon - CGContextAddLines(gc, points.data(), npts); - - // Explicitly close the path, so it is closed for stroking AND filling (implicit close = filling only) - CGContextClosePath(gc); - CGContextDrawPath(gc, kCGPathFillStroke); -} - -//-------------------------------------------------------------------------------------------------- - void SurfaceImpl::Polygon(const Scintilla::Point *pts, size_t npts, FillStroke fillStroke) { std::vector<CGPoint> points; std::transform(pts, pts + npts, std::back_inserter(points), CGPointFromPoint); @@ -804,22 +671,6 @@ void SurfaceImpl::Polygon(const Scintilla::Point *pts, size_t npts, FillStroke f //-------------------------------------------------------------------------------------------------- -void SurfaceImpl::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) { - if (gc) { - CGContextBeginPath(gc); - FillColour(back); - PenColour(fore); - - // Quartz integer -> float point conversion fun (see comment in SurfaceImpl::LineTo) - // We subtract 1 from the Width() and Height() so that all our drawing is within the area defined - // by the PRectangle. Otherwise, we draw one pixel too far to the right and bottom. - CGContextAddRect(gc, CGRectMake(rc.left + 0.5, rc.top + 0.5, rc.Width() - 1, rc.Height() - 1)); - CGContextDrawPath(gc, kCGPathFillStroke); - } -} - -//-------------------------------------------------------------------------------------------------- - void SurfaceImpl::RectangleDraw(PRectangle rc, FillStroke fillStroke) { if (!gc) return; @@ -854,19 +705,6 @@ void SurfaceImpl::RectangleFrame(PRectangle rc, Stroke stroke) { //-------------------------------------------------------------------------------------------------- -void SurfaceImpl::FillRectangle(PRectangle rc, ColourDesired back) { - if (gc) { - FillColour(back); - // Snap rectangle boundaries to nearest int - rc.left = std::round(rc.left); - rc.right = std::round(rc.right); - CGRect rect = PRectangleToCGRect(rc); - CGContextFillRect(gc, rect); - } -} - -//-------------------------------------------------------------------------------------------------- - void SurfaceImpl::FillRectangle(PRectangle rc, Fill fill) { if (gc) { FillColour(fill.colour); @@ -940,68 +778,6 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) { } /* pattern != NULL */ } -void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) { - // This is only called from the margin marker drawing code for SC_MARK_ROUNDRECT - // The Win32 version does - // ::RoundRect(hdc, rc.left + 1, rc.top, rc.right - 1, rc.bottom, 8, 8 ); - // which is a rectangle with rounded corners each having a radius of 4 pixels. - // It would be almost as good just cutting off the corners with lines at - // 45 degrees as is done on GTK+. - - // Create a rectangle with semicircles at the corners - const int MAX_RADIUS = 4; - const int radius = std::min(MAX_RADIUS, static_cast<int>(std::min(rc.Height()/2, rc.Width()/2))); - - // Points go clockwise, starting from just below the top left - // Corners are kept together, so we can easily create arcs to connect them - CGPoint corners[4][3] = { - { - { rc.left, rc.top + radius }, - { rc.left, rc.top }, - { rc.left + radius, rc.top }, - }, - { - { rc.right - radius - 1, rc.top }, - { rc.right - 1, rc.top }, - { rc.right - 1, rc.top + radius }, - }, - { - { rc.right - 1, rc.bottom - radius - 1 }, - { rc.right - 1, rc.bottom - 1 }, - { rc.right - radius - 1, rc.bottom - 1 }, - }, - { - { rc.left + radius, rc.bottom - 1 }, - { rc.left, rc.bottom - 1 }, - { rc.left, rc.bottom - radius - 1 }, - }, - }; - - // Align the points in the middle of the pixels - for (int i = 0; i < 4; ++ i) { - for (int j = 0; j < 3; ++ j) { - corners[i][j].x += 0.5; - corners[i][j].y += 0.5; - } - } - - PenColour(fore); - FillColour(back); - - // Move to the last point to begin the path - CGContextBeginPath(gc); - CGContextMoveToPoint(gc, corners[3][2].x, corners[3][2].y); - - for (int i = 0; i < 4; ++ i) { - CGContextAddLineToPoint(gc, corners[i][0].x, corners[i][0].y); - CGContextAddArcToPoint(gc, corners[i][1].x, corners[i][1].y, corners[i][2].x, corners[i][2].y, radius); - } - - // Close the path to enclose it for stroking and for filling, then draw it - CGContextClosePath(gc); - CGContextDrawPath(gc, kCGPathFillStroke); -} - void SurfaceImpl::RoundedRectangle(PRectangle rc, FillStroke fillStroke) { // This is only called from the margin marker drawing code for SC_MARK_ROUNDRECT // The Win32 version does @@ -1111,54 +887,6 @@ static void DrawChamferedRectangle(CGContextRef gc, PRectangle rc, int cornerSiz CGContextDrawPath(gc, mode); } -void Scintilla::SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, - ColourDesired outline, int alphaOutline, int /*flags*/) { - if (gc) { - // Snap rectangle boundaries to nearest int - rc.left = std::round(rc.left); - rc.right = std::round(rc.right); - // Set the Fill color to match - CGContextSetRGBFillColor(gc, fill.GetRed() / 255.0, fill.GetGreen() / 255.0, fill.GetBlue() / 255.0, alphaFill / 255.0); - CGContextSetRGBStrokeColor(gc, outline.GetRed() / 255.0, outline.GetGreen() / 255.0, outline.GetBlue() / 255.0, alphaOutline / 255.0); - PRectangle rcFill = rc; - if (cornerSize == 0) { - // A simple rectangle, no rounded corners - if ((fill == outline) && (alphaFill == alphaOutline)) { - // Optimization for simple case - CGRect rect = PRectangleToCGRect(rcFill); - CGContextFillRect(gc, rect); - } else { - rcFill.left += 1.0; - rcFill.top += 1.0; - rcFill.right -= 1.0; - rcFill.bottom -= 1.0; - CGRect rect = PRectangleToCGRect(rcFill); - CGContextFillRect(gc, rect); - CGContextAddRect(gc, CGRectMake(rc.left + 0.5, rc.top + 0.5, rc.Width() - 1, rc.Height() - 1)); - CGContextStrokePath(gc); - } - } else { - // Approximate rounded corners with 45 degree chamfers. - // Drawing real circular arcs often leaves some over- or under-drawn pixels. - if ((fill == outline) && (alphaFill == alphaOutline)) { - // Specializing this case avoids a few stray light/dark pixels in corners. - rcFill.left -= 0.5; - rcFill.top -= 0.5; - rcFill.right += 0.5; - rcFill.bottom += 0.5; - DrawChamferedRectangle(gc, rcFill, cornerSize, kCGPathFill); - } else { - rcFill.left += 0.5; - rcFill.top += 0.5; - rcFill.right -= 0.5; - rcFill.bottom -= 0.5; - DrawChamferedRectangle(gc, rcFill, cornerSize-1, kCGPathFill); - DrawChamferedRectangle(gc, rc, cornerSize, kCGPathStroke); - } - } - } -} - void Scintilla::SurfaceImpl::AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke) { if (gc) { const XYPOSITION halfStroke = fillStroke.stroke.width / 2.0f; @@ -1317,15 +1045,6 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi } } -void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) { - CGRect ellipseRect = CGRectMake(rc.left, rc.top, rc.Width(), rc.Height()); - FillColour(back); - PenColour(fore); - CGContextBeginPath(gc); - CGContextAddEllipseInRect(gc, ellipseRect); - CGContextDrawPath(gc, kCGPathFillStroke); -} - void SurfaceImpl::Ellipse(PRectangle rc, FillStroke fillStroke) { const CGRect ellipseRect = CGRectFromPRectangleInset(rc, fillStroke.stroke.width / 2.0f); SetFillStroke(fillStroke); @@ -1784,17 +1503,6 @@ void SurfaceImpl::FlushCachedState() { CGContextSynchronize(gc); } -void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) { - mode.codePage = unicodeMode_ ? SC_CP_UTF8 : 0; -} - -void SurfaceImpl::SetDBCSMode(int codePage_) { - mode.codePage = codePage_; -} - -void SurfaceImpl::SetBidiR2L(bool) { -} - void SurfaceImpl::FlushDrawing() { } diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index f9c0a09f7..97f406f4b 100755 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -60,10 +60,6 @@ constexpr float floatFromPangoUnits(int pu) noexcept { return static_cast<float>(pu) / PANGO_SCALE; } -cairo_surface_t *CreateSimilarSurface(GdkWindow *window, cairo_content_t content, int width, int height) noexcept { - return gdk_window_create_similar_surface(window, content, width, height); -} - GdkWindow *WindowFromWidget(GtkWidget *w) noexcept { return gtk_widget_get_window(w); } @@ -130,8 +126,6 @@ class SurfaceImpl : public Surface { encodingType et= singleByte; cairo_t *context = nullptr; cairo_surface_t *psurf = nullptr; - int x = 0; - int y = 0; bool inited = false; bool createdGC = false; PangoContext *pcontext = nullptr; @@ -152,7 +146,6 @@ public: void Init(WindowID wid) override; void Init(SurfaceID sid, WindowID wid) override; - void InitPixMap(int width, int height, Surface *surface_, WindowID wid) override; std::unique_ptr<Surface> AllocatePixMap(int width, int height) override; void SetMode(SurfaceMode mode_) override; @@ -161,32 +154,23 @@ public: void Release() noexcept override; int Supports(int feature) noexcept override; bool Initialised() override; - void PenColour(ColourDesired fore) override; + void PenColour(ColourDesired fore); void PenColourAlpha(ColourAlpha fore); int LogPixelsY() override; int PixelDivisions() override; int DeviceHeightFont(int points) override; - void MoveTo(int x_, int y_) override; - void LineTo(int x_, int y_) override; void LineDraw(Point start, Point end, Stroke stroke) override; void PolyLine(const Point *pts, size_t npts, Stroke stroke) override; - void Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back) override; void Polygon(const Point *pts, size_t npts, FillStroke fillStroke) override; - void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) override; void RectangleDraw(PRectangle rc, FillStroke fillStroke) override; void RectangleFrame(PRectangle rc, Stroke stroke) override; - void FillRectangle(PRectangle rc, ColourDesired back) override; void FillRectangle(PRectangle rc, Fill fill) override; void FillRectangleAligned(PRectangle rc, Fill fill) override; void FillRectangle(PRectangle rc, Surface &surfacePattern) override; - void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) override; void RoundedRectangle(PRectangle rc, FillStroke fillStroke) override; - void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, - ColourDesired outline, int alphaOutline, int flags) override; void AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke) override; void GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options) override; void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) override; - void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) override; void Ellipse(PRectangle rc, FillStroke fillStroke) override; void Stadium(PRectangle rc, FillStroke fillStroke, Ends ends) override; void Copy(PRectangle rc, Point from, Surface &surfaceSource) override; @@ -217,10 +201,6 @@ public: void PopClip() override; void FlushCachedState() override; void FlushDrawing() override; - - void SetUnicodeMode(bool unicodeMode_) override; - void SetDBCSMode(int codePage) override; - void SetBidiR2L(bool bidiR2L_) override; }; const int SupportsGTK[] = { @@ -339,8 +319,6 @@ void SurfaceImpl::Clear() noexcept { pcontext = nullptr; conv.Close(); characterSet = -1; - x = 0; - y = 0; inited = false; createdGC = false; } @@ -397,36 +375,6 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID wid) { inited = true; } -void SurfaceImpl::InitPixMap(int width, int height, Surface *surface_, WindowID wid) { - PLATFORM_ASSERT(surface_); - Release(); - SurfaceImpl *surfImpl = dynamic_cast<SurfaceImpl *>(surface_); - PLATFORM_ASSERT(surfImpl); - PLATFORM_ASSERT(wid); - context = cairo_reference(surfImpl->context); - pcontext = gtk_widget_create_pango_context(PWidget(wid)); - // update the Pango context in case surface_ isn't the widget's surface - pango_cairo_update_context(context, pcontext); - PLATFORM_ASSERT(pcontext); - layout = pango_layout_new(pcontext); - PLATFORM_ASSERT(layout); - if (height > 0 && width > 0) - psurf = CreateSimilarSurface( - WindowFromWidget(PWidget(wid)), - CAIRO_CONTENT_COLOR_ALPHA, width, height); - cairo_destroy(context); - context = cairo_create(psurf); - cairo_rectangle(context, 0, 0, width, height); - cairo_set_source_rgb(context, 1.0, 0, 0); - cairo_fill(context); - // This produces sharp drawing more similar to GDK: - //cairo_set_antialias(context, CAIRO_ANTIALIAS_NONE); - cairo_set_line_width(context, 1); - createdGC = true; - inited = true; - SetMode(surfImpl->mode); -} - std::unique_ptr<Surface> SurfaceImpl::AllocatePixMap(int width, int height) { return std::make_unique<SurfaceImpl>(context, width, height, mode); } @@ -483,53 +431,6 @@ int SurfaceImpl::DeviceHeightFont(int points) { return (points * logPix + logPix / 2) / 72; } -void SurfaceImpl::MoveTo(int x_, int y_) { - x = x_; - y = y_; -} - -static int Delta(int difference) noexcept { - if (difference < 0) - return -1; - else if (difference > 0) - return 1; - else - return 0; -} - -void SurfaceImpl::LineTo(int x_, int y_) { - // cairo_line_to draws the end position, unlike Win32 or GDK with GDK_CAP_NOT_LAST. - // For simple cases, move back one pixel from end. - if (context) { - const int xDiff = x_ - x; - const int xDelta = Delta(xDiff); - const int yDiff = y_ - y; - const int yDelta = Delta(yDiff); - if ((xDiff == 0) || (yDiff == 0)) { - // Horizontal or vertical lines can be more precisely drawn as a filled rectangle - const int xEnd = x_ - xDelta; - const int left = std::min(x, xEnd); - const int width = std::abs(x - xEnd) + 1; - const int yEnd = y_ - yDelta; - const int top = std::min(y, yEnd); - const int height = std::abs(y - yEnd) + 1; - cairo_rectangle(context, left, top, width, height); - cairo_fill(context); - } else if ((std::abs(xDiff) == std::abs(yDiff))) { - // 45 degree slope - cairo_move_to(context, x + 0.5, y + 0.5); - cairo_line_to(context, x_ + 0.5 - xDelta, y_ + 0.5 - yDelta); - } else { - // Line has a different slope so difficult to avoid last pixel - cairo_move_to(context, x + 0.5, y + 0.5); - cairo_line_to(context, x_ + 0.5, y_ + 0.5); - } - cairo_stroke(context); - } - x = x_; - y = y_; -} - void SurfaceImpl::LineDraw(Point start, Point end, Stroke stroke) { PLATFORM_ASSERT(context); if (!context) @@ -555,20 +456,6 @@ void SurfaceImpl::PolyLine(const Point *pts, size_t npts, Stroke stroke) { cairo_stroke(context); } -void SurfaceImpl::Polygon(Point *pts, size_t npts, ColourDesired fore, - ColourDesired back) { - PLATFORM_ASSERT(context); - PenColour(back); - cairo_move_to(context, pts[0].x + 0.5, pts[0].y + 0.5); - for (size_t i = 1; i < npts; i++) { - cairo_line_to(context, pts[i].x + 0.5, pts[i].y + 0.5); - } - cairo_close_path(context); - cairo_fill_preserve(context); - PenColour(fore); - cairo_stroke(context); -} - void SurfaceImpl::Polygon(const Point *pts, size_t npts, FillStroke fillStroke) { PLATFORM_ASSERT(context); PenColourAlpha(fillStroke.fill.colour); @@ -583,17 +470,6 @@ void SurfaceImpl::Polygon(const Point *pts, size_t npts, FillStroke fillStroke) cairo_stroke(context); } -void SurfaceImpl::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) { - if (context) { - cairo_rectangle(context, rc.left + 0.5, rc.top + 0.5, - rc.Width() - 1, rc.Height() - 1); - PenColour(back); - cairo_fill_preserve(context); - PenColour(fore); - cairo_stroke(context); - } -} - void SurfaceImpl::RectangleDraw(PRectangle rc, FillStroke fillStroke) { if (context) { CairoRectangle(rc.Inset(fillStroke.stroke.width / 2)); @@ -614,16 +490,6 @@ void SurfaceImpl::RectangleFrame(PRectangle rc, Stroke stroke) { } } -void SurfaceImpl::FillRectangle(PRectangle rc, ColourDesired back) { - PenColour(back); - if (context && (rc.left < maxCoordinate)) { // Protect against out of range - rc.left = std::round(rc.left); - rc.right = std::round(rc.right); - cairo_rectangle(context, rc.left, rc.top, rc.Width(), rc.Height()); - cairo_fill(context); - } -} - void SurfaceImpl::FillRectangle(PRectangle rc, Fill fill) { PenColourAlpha(fill.colour); if (context && (rc.left < maxCoordinate)) { // Protect against out of range @@ -647,25 +513,6 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) { } } -void SurfaceImpl::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) { - if (((rc.right - rc.left) > 4) && ((rc.bottom - rc.top) > 4)) { - // Approximate a round rect with some cut off corners - Point pts[] = { - Point(rc.left + 2, rc.top), - Point(rc.right - 2, rc.top), - Point(rc.right, rc.top + 2), - Point(rc.right, rc.bottom - 2), - Point(rc.right - 2, rc.bottom), - Point(rc.left + 2, rc.bottom), - Point(rc.left, rc.bottom - 2), - Point(rc.left, rc.top + 2), - }; - Polygon(pts, std::size(pts), fore, back); - } else { - RectangleDraw(rc, fore, back); - } -} - void SurfaceImpl::RoundedRectangle(PRectangle rc, FillStroke fillStroke) { if (((rc.right - rc.left) > 4) && ((rc.bottom - rc.top) > 4)) { // Approximate a round rect with some cut off corners @@ -694,35 +541,6 @@ static void PathRoundRectangle(cairo_t *context, double left, double top, double cairo_close_path(context); } -void SurfaceImpl::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, - ColourDesired outline, int alphaOutline, int /*flags*/) { - if (context && rc.Width() > 0) { - const ColourDesired cdFill(fill.AsInteger()); - cairo_set_source_rgba(context, - cdFill.GetRed() / 255.0, - cdFill.GetGreen() / 255.0, - cdFill.GetBlue() / 255.0, - alphaFill / 255.0); - if (cornerSize > 0) - PathRoundRectangle(context, rc.left + 1.0, rc.top + 1.0, rc.Width() - 2.0, rc.Height() - 2.0, cornerSize); - else - cairo_rectangle(context, rc.left + 1.0, rc.top + 1.0, rc.Width() - 2.0, rc.Height() - 2.0); - cairo_fill(context); - - const ColourDesired cdOutline(outline.AsInteger()); - cairo_set_source_rgba(context, - cdOutline.GetRed() / 255.0, - cdOutline.GetGreen() / 255.0, - cdOutline.GetBlue() / 255.0, - alphaOutline / 255.0); - if (cornerSize > 0) - PathRoundRectangle(context, rc.left + 0.5, rc.top + 0.5, rc.Width() - 1, rc.Height() - 1, cornerSize); - else - cairo_rectangle(context, rc.left + 0.5, rc.top + 0.5, rc.Width() - 1, rc.Height() - 1); - cairo_stroke(context); - } -} - void SurfaceImpl::AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke) { if (context && rc.Width() > 0) { const float halfStroke = fillStroke.stroke.width / 2.0f; @@ -800,16 +618,6 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi cairo_surface_destroy(psurfImage); } -void SurfaceImpl::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) { - PLATFORM_ASSERT(context); - PenColour(back); - cairo_arc(context, (rc.left + rc.right) / 2, (rc.top + rc.bottom) / 2, - std::min(rc.Width(), rc.Height()) / 2, 0, 2*kPi); - cairo_fill_preserve(context); - PenColour(fore); - cairo_stroke(context); -} - void SurfaceImpl::Ellipse(PRectangle rc, FillStroke fillStroke) { PLATFORM_ASSERT(context); PenColourAlpha(fillStroke.fill.colour); @@ -1301,30 +1109,6 @@ void SurfaceImpl::PopClip() { void SurfaceImpl::FlushCachedState() {} -void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) { - if (unicodeMode_) { - mode.codePage = SC_CP_UTF8; - et = UTF8; - } else { - mode.codePage = 0; - et = singleByte; - } -} - -void SurfaceImpl::SetDBCSMode(int codePage) { - mode.codePage = codePage; - if (mode.codePage == SC_CP_UTF8) { - et = UTF8; - } else if (mode.codePage) { - et = dbcs; - } else { - et = singleByte; - } -} - -void SurfaceImpl::SetBidiR2L(bool) { -} - void SurfaceImpl::FlushDrawing() { } diff --git a/qt/ScintillaEditBase/PlatQt.cpp b/qt/ScintillaEditBase/PlatQt.cpp index 9510efa92..16f699e8e 100644 --- a/qt/ScintillaEditBase/PlatQt.cpp +++ b/qt/ScintillaEditBase/PlatQt.cpp @@ -156,8 +156,6 @@ std::shared_ptr<Font> Font::Allocate(const FontParameters &fp) } SurfaceImpl::SurfaceImpl() -: device(nullptr), painter(nullptr), deviceOwned(false), painterOwned(false), x(0), y(0), - codecName(nullptr), codec(nullptr) {} SurfaceImpl::SurfaceImpl(int width, int height, SurfaceMode mode_) @@ -201,20 +199,6 @@ void SurfaceImpl::Init(SurfaceID sid, WindowID /*wid*/) device = static_cast<QPaintDevice *>(sid); } -void SurfaceImpl::InitPixMap(int width, - int height, - Surface *surface, - WindowID /*wid*/) -{ - Release(); - if (width < 1) width = 1; - if (height < 1) height = 1; - deviceOwned = true; - device = new QPixmap(width, height); - SurfaceImpl *psurfOther = dynamic_cast<SurfaceImpl *>(surface); - mode = psurfOther->mode; -} - std::unique_ptr<Surface> SurfaceImpl::AllocatePixMap(int width, int height) { return std::make_unique<SurfaceImpl>(width, height, mode); @@ -244,13 +228,6 @@ bool SurfaceImpl::Initialised() return device != nullptr; } -void SurfaceImpl::PenColour(ColourDesired fore) -{ - QPen penOutline(QColorFromCA(fore)); - penOutline.setCapStyle(Qt::FlatCap); - GetPainter()->setPen(penOutline); -} - void SurfaceImpl::PenColour(ColourAlpha fore) { QPen penOutline(QColorFromColourAlpha(fore)); @@ -266,11 +243,6 @@ void SurfaceImpl::PenColourWidth(ColourAlpha fore, XYPOSITION strokeWidth) { GetPainter()->setPen(penOutline); } -void SurfaceImpl::BrushColour(ColourDesired back) -{ - GetPainter()->setBrush(QBrush(QColorFromCA(back))); -} - void SurfaceImpl::BrushColour(ColourAlpha back) { GetPainter()->setBrush(QBrush(QColorFromColourAlpha(back))); @@ -315,20 +287,6 @@ int SurfaceImpl::DeviceHeightFont(int points) return points; } -void SurfaceImpl::MoveTo(int x_, int y_) -{ - x = x_; - y = y_; -} - -void SurfaceImpl::LineTo(int x_, int y_) -{ - QLineF line(x, y, x_, y_); - GetPainter()->drawLine(line); - x = x_; - y = y_; -} - void SurfaceImpl::LineDraw(Point start, Point end, Stroke stroke) { PenColourWidth(stroke.colour, stroke.width); @@ -345,22 +303,6 @@ void SurfaceImpl::PolyLine(const Point *pts, size_t npts, Stroke stroke) GetPainter()->drawPolyline(&qpts[0], static_cast<int>(npts)); } -void SurfaceImpl::Polygon(Point *pts, - size_t npts, - ColourDesired fore, - ColourDesired back) -{ - PenColour(fore); - BrushColour(back); - - std::vector<QPoint> qpts(npts); - for (size_t i = 0; i < npts; i++) { - qpts[i] = QPoint(pts[i].x, pts[i].y); - } - - GetPainter()->drawPolygon(&qpts[0], static_cast<int>(npts)); -} - void SurfaceImpl::Polygon(const Point *pts, size_t npts, FillStroke fillStroke) { PenColourWidth(fillStroke.stroke.colour, fillStroke.stroke.width); @@ -372,16 +314,6 @@ void SurfaceImpl::Polygon(const Point *pts, size_t npts, FillStroke fillStroke) GetPainter()->drawPolygon(&qpts[0], static_cast<int>(npts)); } -void SurfaceImpl::RectangleDraw(PRectangle rc, - ColourDesired fore, - ColourDesired back) -{ - PenColour(fore); - BrushColour(back); - QRectF rect(rc.left, rc.top, rc.Width() - 1, rc.Height() - 1); - GetPainter()->drawRect(rect); -} - void SurfaceImpl::RectangleDraw(PRectangle rc, FillStroke fillStroke) { PenColourWidth(fillStroke.stroke.colour, fillStroke.stroke.width); @@ -398,11 +330,6 @@ void SurfaceImpl::RectangleFrame(PRectangle rc, Stroke stroke) { GetPainter()->drawRect(rect); } -void SurfaceImpl::FillRectangle(PRectangle rc, ColourDesired back) -{ - GetPainter()->fillRect(QRectFFromPRect(rc), QColorFromCA(back)); -} - void SurfaceImpl::FillRectangle(PRectangle rc, Fill fill) { GetPainter()->fillRect(QRectFFromPRect(rc), QColorFromColourAlpha(fill.colour)); @@ -432,15 +359,6 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) } } -void SurfaceImpl::RoundedRectangle(PRectangle rc, - ColourDesired fore, - ColourDesired back) -{ - PenColour(fore); - BrushColour(back); - GetPainter()->drawRoundedRect(QRectFFromPRect(RectangleInset(rc, 0.5f)), 3.0f, 3.0f); -} - void SurfaceImpl::RoundedRectangle(PRectangle rc, FillStroke fillStroke) { PenColourWidth(fillStroke.stroke.colour, fillStroke.stroke.width); @@ -448,44 +366,6 @@ void SurfaceImpl::RoundedRectangle(PRectangle rc, FillStroke fillStroke) GetPainter()->drawRoundedRect(QRectFFromPRect(rc), 3.0f, 3.0f); } -void SurfaceImpl::AlphaRectangle(PRectangle rc, - int cornerSize, - ColourDesired fill, - int alphaFill, - ColourDesired outline, - int alphaOutline, - int /*flags*/) -{ - const QColor qFill = QColorFromColourAlpha(ColourAlpha(fill, alphaFill)); - const QBrush brushFill(qFill); - GetPainter()->setBrush(brushFill); - - if ((fill == outline) && (alphaFill == alphaOutline)) { - painter->setPen(Qt::NoPen); - const QRectF rect = QRectFFromPRect(rc); - if (cornerSize > 0.0f) { - // A radius of 1 shows no curve so add 1 - qreal radius = cornerSize+1; - GetPainter()->drawRoundedRect(rect, radius, radius); - } else { - GetPainter()->fillRect(rect, brushFill); - } - } else { - const QColor qOutline = QColorFromColourAlpha(ColourAlpha(outline, alphaOutline)); - const QPen penOutline(qOutline); - GetPainter()->setPen(penOutline); - - const QRectF rect(rc.left, rc.top, rc.Width() - 1.5, rc.Height() - 1.5); - if (cornerSize > 0.0f) { - // A radius of 1 shows no curve so add 1 - qreal radius = cornerSize+1; - GetPainter()->drawRoundedRect(rect, radius, radius); - } else { - GetPainter()->drawRect(rect); - } - } -} - void SurfaceImpl::AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke) { QColor qFill = QColorFromColourAlpha(fillStroke.fill.colour); @@ -556,15 +436,6 @@ void SurfaceImpl::DrawRGBAImage(PRectangle rc, int width, int height, const unsi GetPainter()->drawImage(pt, image); } -void SurfaceImpl::Ellipse(PRectangle rc, - ColourDesired fore, - ColourDesired back) -{ - PenColour(fore); - BrushColour(back); - GetPainter()->drawEllipse(QRectFFromPRect(rc)); -} - void SurfaceImpl::Ellipse(PRectangle rc, FillStroke fillStroke) { PenColourWidth(fillStroke.stroke.colour, fillStroke.stroke.width); @@ -878,20 +749,6 @@ void SurfaceImpl::FlushCachedState() } } -void SurfaceImpl::SetUnicodeMode(bool unicodeMode_) -{ - mode.codePage = unicodeMode_ ? SC_CP_UTF8 : 0; -} - -void SurfaceImpl::SetDBCSMode(int codePage_) -{ - mode.codePage = codePage_; -} - -void SurfaceImpl::SetBidiR2L(bool) -{ -} - void SurfaceImpl::FlushDrawing() { } diff --git a/qt/ScintillaEditBase/PlatQt.h b/qt/ScintillaEditBase/PlatQt.h index c9424378e..898078f75 100644 --- a/qt/ScintillaEditBase/PlatQt.h +++ b/qt/ScintillaEditBase/PlatQt.h @@ -31,12 +31,6 @@ namespace Scintilla { const char *CharacterSetID(int characterSet); -inline QColor QColorFromCA(ColourDesired ca) -{ - long c = ca.AsInteger(); - return QColor(c & 0xff, (c >> 8) & 0xff, (c >> 16) & 0xff); -} - inline QColor QColorFromColourAlpha(ColourAlpha ca) { return QColor(ca.GetRed(), ca.GetGreen(), ca.GetBlue(), ca.GetAlpha()); @@ -77,8 +71,6 @@ private: QPainter *painter = nullptr; bool deviceOwned = false; bool painterOwned = false; - float x = 0; - float y = 0; SurfaceMode mode; const char *codecName = nullptr; QTextCodec *codec = nullptr; @@ -92,8 +84,6 @@ public: void Init(WindowID wid) override; void Init(SurfaceID sid, WindowID wid) override; - void InitPixMap(int width, int height, - Surface *surface, WindowID wid) override; std::unique_ptr<Surface> AllocatePixMap(int width, int height) override; void SetMode(SurfaceMode mode) override; @@ -101,38 +91,24 @@ public: void Release() noexcept override; int Supports(int feature) noexcept override; bool Initialised() override; - void PenColour(ColourDesired fore) override; void PenColour(ColourAlpha fore); void PenColourWidth(ColourAlpha fore, XYPOSITION strokeWidth); int LogPixelsY() override; int PixelDivisions() override; int DeviceHeightFont(int points) override; - void MoveTo(int x_, int y_) override; - void LineTo(int x_, int y_) override; void LineDraw(Point start, Point end, Stroke stroke) override; void PolyLine(const Point *pts, size_t npts, Stroke stroke) override; - void Polygon(Point *pts, size_t npts, ColourDesired fore, - ColourDesired back) override; void Polygon(const Point *pts, size_t npts, FillStroke fillStroke) override; - void RectangleDraw(PRectangle rc, ColourDesired fore, - ColourDesired back) override; void RectangleDraw(PRectangle rc, FillStroke fillStroke) override; void RectangleFrame(PRectangle rc, Stroke stroke) override; - void FillRectangle(PRectangle rc, ColourDesired back) override; void FillRectangle(PRectangle rc, Fill fill) override; void FillRectangleAligned(PRectangle rc, Fill fill) override; void FillRectangle(PRectangle rc, Surface &surfacePattern) override; - void RoundedRectangle(PRectangle rc, ColourDesired fore, - ColourDesired back) override; void RoundedRectangle(PRectangle rc, FillStroke fillStroke) override; - void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, - int alphaFill, ColourDesired outline, int alphaOutline, int flags) override; void AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke) override; void GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options) override; void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) override; - void Ellipse(PRectangle rc, ColourDesired fore, - ColourDesired back) override; void Ellipse(PRectangle rc, FillStroke fillStroke) override; void Stadium(PRectangle rc, FillStroke fillStroke, Ends ends) override; void Copy(PRectangle rc, Point from, Surface &surfaceSource) override; @@ -170,11 +146,6 @@ public: void FlushCachedState() override; void FlushDrawing() override; - void SetUnicodeMode(bool unicodeMode_) override; - void SetDBCSMode(int codePage_) override; - void SetBidiR2L(bool bidiR2L_) override; - - void BrushColour(ColourDesired back); void BrushColour(ColourAlpha back); void SetCodec(const Font *font); void SetFont(const Font *font); diff --git a/src/Platform.h b/src/Platform.h index 7a07fb5e7..8898e66f9 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -188,7 +188,6 @@ public: virtual void Init(WindowID wid)=0; virtual void Init(SurfaceID sid, WindowID wid)=0; - virtual void InitPixMap(int width, int height, Surface *surface_, WindowID wid)=0; virtual std::unique_ptr<Surface> AllocatePixMap(int width, int height)=0; virtual void SetMode(SurfaceMode mode)=0; @@ -204,32 +203,22 @@ public: virtual void Release() noexcept=0; virtual int Supports(int feature) noexcept=0; virtual bool Initialised()=0; - virtual void PenColour(ColourDesired fore)=0; virtual int LogPixelsY()=0; virtual int PixelDivisions()=0; virtual int DeviceHeightFont(int points)=0; - virtual void MoveTo(int x_, int y_)=0; - virtual void LineTo(int x_, int y_)=0; virtual void LineDraw(Point start, Point end, Stroke stroke)=0; virtual void PolyLine(const Point *pts, size_t npts, Stroke stroke)=0; - virtual void Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back)=0; virtual void Polygon(const Point *pts, size_t npts, FillStroke fillStroke)=0; - virtual void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back)=0; virtual void RectangleDraw(PRectangle rc, FillStroke fillStroke)=0; virtual void RectangleFrame(PRectangle rc, Stroke stroke)=0; - virtual void FillRectangle(PRectangle rc, ColourDesired back)=0; virtual void FillRectangle(PRectangle rc, Fill fill)=0; virtual void FillRectangleAligned(PRectangle rc, Fill fill)=0; virtual void FillRectangle(PRectangle rc, Surface &surfacePattern)=0; - virtual void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back)=0; virtual void RoundedRectangle(PRectangle rc, FillStroke fillStroke)=0; - virtual void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, - ColourDesired outline, int alphaOutline, int flags)=0; virtual void AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke)=0; enum class GradientOptions { leftToRight, topToBottom }; virtual void GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options)=0; virtual void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) = 0; - virtual void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back)=0; virtual void Ellipse(PRectangle rc, FillStroke fillStroke)=0; virtual void Stadium(PRectangle rc, FillStroke fillStroke, Ends ends)=0; virtual void Copy(PRectangle rc, Point from, Surface &surfaceSource)=0; @@ -258,10 +247,6 @@ public: virtual void PopClip()=0; virtual void FlushCachedState()=0; virtual void FlushDrawing()=0; - - virtual void SetUnicodeMode(bool unicodeMode_)=0; - virtual void SetDBCSMode(int codePage)=0; - virtual void SetBidiR2L(bool bidiR2L_)=0; }; /** diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx index d60b35325..034b526af 100644 --- a/win32/PlatWin.cxx +++ b/win32/PlatWin.cxx @@ -476,7 +476,6 @@ public: void Init(WindowID wid) override; void Init(SurfaceID sid, WindowID wid) override; - void InitPixMap(int width, int height, Surface *surface_, WindowID wid) override; std::unique_ptr<Surface> AllocatePixMap(int width, int height) override; void SetMode(SurfaceMode mode_) override; @@ -484,31 +483,21 @@ public: void Release() noexcept override; int Supports(int feature) noexcept override; bool Initialised() override; - void PenColour(ColourDesired fore) override; int LogPixelsY() override; int PixelDivisions() override; int DeviceHeightFont(int points) override; - void MoveTo(int x_, int y_) override; - void LineTo(int x_, int y_) override; void LineDraw(Point start, Point end, Stroke stroke) override; void PolyLine(const Point *pts, size_t npts, Stroke stroke) override; - void Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back) override; void Polygon(const Point *pts, size_t npts, FillStroke fillStroke) override; - void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) override; void RectangleDraw(PRectangle rc, FillStroke fillStroke) override; void RectangleFrame(PRectangle rc, Stroke stroke) override; - void FillRectangle(PRectangle rc, ColourDesired back) override; void FillRectangle(PRectangle rc, Fill fill) override; void FillRectangleAligned(PRectangle rc, Fill fill) override; void FillRectangle(PRectangle rc, Surface &surfacePattern) override; - void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) override; void RoundedRectangle(PRectangle rc, FillStroke fillStroke) override; - void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, - ColourDesired outline, int alphaOutline, int flags) override; void AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke) override; void GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options) override; void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) override; - void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) override; void Ellipse(PRectangle rc, FillStroke fillStroke) override; void Stadium(PRectangle rc, FillStroke fillStroke, Ends ends) override; void Copy(PRectangle rc, Point from, Surface &surfaceSource) override; @@ -539,10 +528,6 @@ public: void PopClip() override; void FlushCachedState() override; void FlushDrawing() override; - - void SetUnicodeMode(bool unicodeMode_) override; - void SetDBCSMode(int codePage_) override; - void SetBidiR2L(bool bidiR2L_) override; }; SurfaceGDI::SurfaceGDI() noexcept { @@ -622,20 +607,6 @@ void SurfaceGDI::Init(SurfaceID sid, WindowID wid) { logPixelsY = printing ? ::GetDeviceCaps(hdc, LOGPIXELSY) : DpiForWindow(wid); } -void SurfaceGDI::InitPixMap(int width, int height, Surface *surface_, WindowID wid) { - Release(); - SurfaceGDI *psurfOther = dynamic_cast<SurfaceGDI *>(surface_); - // Should only ever be called with a SurfaceGDI, not a SurfaceD2D - PLATFORM_ASSERT(psurfOther); - hdc = ::CreateCompatibleDC(psurfOther->hdc); - hdcOwned = true; - bitmap = ::CreateCompatibleBitmap(psurfOther->hdc, width, height); - bitmapOld = SelectBitmap(hdc, bitmap); - ::SetTextAlign(hdc, TA_BASELINE); - mode = psurfOther->mode; - logPixelsY = DpiForWindow(wid); -} - std::unique_ptr<Surface> SurfaceGDI::AllocatePixMap(int width, int height) { return std::make_unique<SurfaceGDI>(hdc, width, height, mode, logPixelsY); } @@ -644,17 +615,6 @@ void SurfaceGDI::SetMode(SurfaceMode mode_) { mode = mode_; } -void SurfaceGDI::PenColour(ColourDesired fore) { - if (pen) { - ::SelectObject(hdc, penOld); - ::DeleteObject(pen); - pen = {}; - penOld = {}; - } - pen = ::CreatePen(0,1,fore.AsInteger()); - penOld = SelectPen(hdc, pen); -} - void SurfaceGDI::PenColour(ColourAlpha fore, XYPOSITION widthStroke) noexcept { if (pen) { ::SelectObject(hdc, penOld); @@ -711,14 +671,6 @@ int SurfaceGDI::DeviceHeightFont(int points) { return ::MulDiv(points, LogPixelsY(), 72); } -void SurfaceGDI::MoveTo(int x_, int y_) { - ::MoveToEx(hdc, x_, y_, nullptr); -} - -void SurfaceGDI::LineTo(int x_, int y_) { - ::LineTo(hdc, x_, y_); -} - void SurfaceGDI::LineDraw(Point start, Point end, Stroke stroke) { PenColour(stroke.colour, stroke.width); ::MoveToEx(hdc, std::lround(std::floor(start.x)), std::lround(std::floor(start.y)), nullptr); @@ -736,14 +688,6 @@ void SurfaceGDI::PolyLine(const Point *pts, size_t npts, Stroke stroke) { ::Polyline(hdc, outline.data(), static_cast<int>(npts)); } -void SurfaceGDI::Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back) { - PenColour(fore); - BrushColour(back); - std::vector<POINT> outline; - std::transform(pts, pts + npts, std::back_inserter(outline), POINTFromPoint); - ::Polygon(hdc, outline.data(), static_cast<int>(npts)); -} - void SurfaceGDI::Polygon(const Point *pts, size_t npts, FillStroke fillStroke) { PenColour(fillStroke.stroke.colour.GetColour(), fillStroke.stroke.width); BrushColour(fillStroke.fill.colour.GetColour()); @@ -752,13 +696,6 @@ void SurfaceGDI::Polygon(const Point *pts, size_t npts, FillStroke fillStroke) { ::Polygon(hdc, outline.data(), static_cast<int>(npts)); } -void SurfaceGDI::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) { - PenColour(fore); - BrushColour(back); - const RECT rcw = RectFromPRectangle(rc); - ::Rectangle(hdc, rcw.left, rcw.top, rcw.right, rcw.bottom); -} - void SurfaceGDI::RectangleDraw(PRectangle rc, FillStroke fillStroke) { RectangleFrame(rc, fillStroke.stroke); FillRectangle(rc.Inset(fillStroke.stroke.width), fillStroke.fill.colour); @@ -770,14 +707,6 @@ void SurfaceGDI::RectangleFrame(PRectangle rc, Stroke stroke) { ::FrameRect(hdc, &rcw, brush); } -void SurfaceGDI::FillRectangle(PRectangle rc, ColourDesired back) { - // Using ExtTextOut rather than a FillRect ensures that no dithering occurs. - // There is no need to allocate a brush either. - const RECT rcw = RectFromPRectangle(rc); - ::SetBkColor(hdc, back.AsInteger()); - ::ExtTextOut(hdc, rcw.left, rcw.top, ETO_OPAQUE, &rcw, TEXT(""), 0, nullptr); -} - void SurfaceGDI::FillRectangle(PRectangle rc, Fill fill) { if (fill.colour.IsOpaque()) { // Using ExtTextOut rather than a FillRect ensures that no dithering occurs. @@ -806,16 +735,6 @@ void SurfaceGDI::FillRectangle(PRectangle rc, Surface &surfacePattern) { ::DeleteObject(br); } -void SurfaceGDI::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) { - PenColour(fore); - BrushColour(back); - const RECT rcw = RectFromPRectangle(rc); - ::RoundRect(hdc, - rcw.left + 1, rcw.top, - rcw.right - 1, rcw.bottom, - 8, 8); -} - void SurfaceGDI::RoundedRectangle(PRectangle rc, FillStroke fillStroke) { PenColour(fillStroke.stroke.colour, fillStroke.stroke.width); BrushColour(fillStroke.fill.colour); @@ -960,55 +879,6 @@ constexpr BLENDFUNCTION mergeAlpha = { AC_SRC_OVER, 0, 255, AC_SRC_ALPHA }; } -void SurfaceGDI::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, - ColourDesired outline, int alphaOutline, int /* flags*/ ) { - const RECT rcw = RectFromPRectangle(rc); - const SIZE size = SizeOfRect(rcw); - - if (size.cx > 0) { - - DIBSection section(hdc, size); - - if (section) { - - // Ensure not distorted too much by corners when small - const LONG corner = std::min<LONG>(cornerSize, (std::min(size.cx, size.cy) / 2) - 2); - - constexpr DWORD valEmpty = dwordFromBGRA(0,0,0,0); - const DWORD valFill = dwordMultiplied(fill, alphaFill); - const DWORD valOutline = dwordMultiplied(outline, alphaOutline); - - // Draw a framed rectangle - for (int y=0; y<size.cy; y++) { - for (int x=0; x<size.cx; x++) { - if ((x==0) || (x==size.cx-1) || (y == 0) || (y == size.cy -1)) { - section.SetPixel(x, y, valOutline); - } else { - section.SetPixel(x, y, valFill); - } - } - } - - // Make the corners transparent - for (LONG c=0; c<corner; c++) { - for (LONG x=0; x<c+1; x++) { - section.SetSymmetric(x, c - x, valEmpty); - } - } - - // Draw the corner frame pieces - for (LONG x=1; x<corner; x++) { - section.SetSymmetric(x, corner - x, valOutline); - } - - AlphaBlend(hdc, rcw.left, rcw.top, size.cx, size.cy, section.DC(), 0, 0, size.cx, size.cy, mergeAlpha); - } - } else { - BrushColour(outline); - FrameRect(hdc, &rcw, brush); - } -} - void SurfaceGDI::AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke) { // TODO: Implement strokeWidth const RECT rcw = RectFromPRectangle(rc); @@ -1113,13 +983,6 @@ void SurfaceGDI::DrawRGBAImage(PRectangle rc, int width, int height, const unsig } } -void SurfaceGDI::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) { - PenColour(fore); - BrushColour(back); - const RECT rcw = RectFromPRectangle(rc); - ::Ellipse(hdc, rcw.left, rcw.top, rcw.right, rcw.bottom); -} - void SurfaceGDI::Ellipse(PRectangle rc, FillStroke fillStroke) { PenColour(fillStroke.stroke.colour, fillStroke.stroke.width); BrushColour(fillStroke.fill.colour); @@ -1371,18 +1234,6 @@ void SurfaceGDI::FlushCachedState() { void SurfaceGDI::FlushDrawing() { } -void SurfaceGDI::SetUnicodeMode(bool unicodeMode_) { - mode.codePage = unicodeMode_ ? SC_CP_UTF8 : 0; -} - -void SurfaceGDI::SetDBCSMode(int codePage_) { - // No action on window as automatically handled by system. - mode.codePage = codePage_; -} - -void SurfaceGDI::SetBidiR2L(bool) { -} - #if defined(USE_D2D) namespace { @@ -1420,8 +1271,6 @@ class BlobInline; class SurfaceD2D : public Surface { SurfaceMode mode; - int x = 0; - int y = 0; int codePageText = 0; @@ -1456,7 +1305,6 @@ public: void SetScale(WindowID wid) noexcept; void Init(WindowID wid) override; void Init(SurfaceID sid, WindowID wid) override; - void InitPixMap(int width, int height, Surface *surface_, WindowID wid) override; std::unique_ptr<Surface> AllocatePixMap(int width, int height) override; void SetMode(SurfaceMode mode_) override; @@ -1465,34 +1313,23 @@ public: int Supports(int feature) noexcept override; bool Initialised() override; - void PenColour(ColourDesired fore) override; - void D2DPenColour(ColourDesired fore, int alpha=255); void D2DPenColourAlpha(ColourAlpha fore) noexcept; int LogPixelsY() override; int PixelDivisions() override; int DeviceHeightFont(int points) override; - void MoveTo(int x_, int y_) override; - void LineTo(int x_, int y_) override; void LineDraw(Point start, Point end, Stroke stroke) override; ID2D1PathGeometry *Geometry(const Point *pts, size_t npts, D2D1_FIGURE_BEGIN figureBegin) noexcept; void PolyLine(const Point *pts, size_t npts, Stroke stroke) override; - void Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back) override; void Polygon(const Point *pts, size_t npts, FillStroke fillStroke) override; - void RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) override; void RectangleDraw(PRectangle rc, FillStroke fillStroke) override; void RectangleFrame(PRectangle rc, Stroke stroke) override; - void FillRectangle(PRectangle rc, ColourDesired back) override; void FillRectangle(PRectangle rc, Fill fill) override; void FillRectangleAligned(PRectangle rc, Fill fill) override; void FillRectangle(PRectangle rc, Surface &surfacePattern) override; - void RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) override; void RoundedRectangle(PRectangle rc, FillStroke fillStroke) override; - void AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, - ColourDesired outline, int alphaOutline, int flags) override; void AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke) override; void GradientRectangle(PRectangle rc, const std::vector<ColourStop> &stops, GradientOptions options) override; void DrawRGBAImage(PRectangle rc, int width, int height, const unsigned char *pixelsImage) override; - void Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) override; void Ellipse(PRectangle rc, FillStroke fillStroke) override; void Stadium(PRectangle rc, FillStroke fillStroke, Ends ends) override; void Copy(PRectangle rc, Point from, Surface &surfaceSource) override; @@ -1523,31 +1360,9 @@ public: void PopClip() override; void FlushCachedState() override; void FlushDrawing() override; - - void SetUnicodeMode(bool unicodeMode_) override; - void SetDBCSMode(int codePage_) override; - void SetBidiR2L(bool bidiR2L_) override; }; -SurfaceD2D::SurfaceD2D() noexcept : - x(0), y(0) { - - codePageText = 0; - - pRenderTarget = nullptr; - pBitmapRenderTarget = nullptr; - ownRenderTarget = false; - clipsActive = 0; - - // From selected font - pTextFormat = nullptr; - yAscent = 2; - yDescent = 1; - yInternalLeading = 0; - - pBrush = nullptr; - - logPixelsY = USER_DEFAULT_SCREEN_DPI; +SurfaceD2D::SurfaceD2D() noexcept { } SurfaceD2D::SurfaceD2D(ID2D1RenderTarget *pRenderTargetCompatible, int width, int height, SurfaceMode mode_, int logPixelsY_) noexcept { @@ -1622,30 +1437,6 @@ void SurfaceD2D::Init(SurfaceID sid, WindowID wid) { pRenderTarget = static_cast<ID2D1RenderTarget *>(sid); } -void SurfaceD2D::InitPixMap(int width, int height, Surface *surface_, WindowID wid) { - Release(); - SetScale(wid); - SurfaceD2D *psurfOther = dynamic_cast<SurfaceD2D *>(surface_); - // Should only ever be called with a SurfaceD2D, not a SurfaceGDI - PLATFORM_ASSERT(psurfOther); - const D2D1_SIZE_F desiredSize = D2D1::SizeF(static_cast<float>(width), static_cast<float>(height)); - D2D1_PIXEL_FORMAT desiredFormat; -#ifdef __MINGW32__ - desiredFormat.format = DXGI_FORMAT_UNKNOWN; -#else - desiredFormat = psurfOther->pRenderTarget->GetPixelFormat(); -#endif - desiredFormat.alphaMode = D2D1_ALPHA_MODE_IGNORE; - const HRESULT hr = psurfOther->pRenderTarget->CreateCompatibleRenderTarget( - &desiredSize, nullptr, &desiredFormat, D2D1_COMPATIBLE_RENDER_TARGET_OPTIONS_NONE, &pBitmapRenderTarget); - if (SUCCEEDED(hr)) { - pRenderTarget = pBitmapRenderTarget; - pRenderTarget->BeginDraw(); - ownRenderTarget = true; - } - mode = psurfOther->mode; -} - std::unique_ptr<Surface> SurfaceD2D::AllocatePixMap(int width, int height) { return std::make_unique<SurfaceD2D>(pRenderTarget, width, height, mode, logPixelsY); } @@ -1659,14 +1450,6 @@ HRESULT SurfaceD2D::GetBitmap(ID2D1Bitmap **ppBitmap) { return pBitmapRenderTarget->GetBitmap(ppBitmap); } -void SurfaceD2D::PenColour(ColourDesired fore) { - D2DPenColour(fore); -} - -void SurfaceD2D::D2DPenColour(ColourDesired fore, int alpha) { - D2DPenColourAlpha(ColourAlpha(fore, alpha)); -} - void SurfaceD2D::D2DPenColourAlpha(ColourAlpha fore) noexcept { if (pRenderTarget) { const D2D_COLOR_F col = ColorFromColourAlpha(fore); @@ -1718,51 +1501,6 @@ int SurfaceD2D::DeviceHeightFont(int points) { return ::MulDiv(points, LogPixelsY(), 72); } -void SurfaceD2D::MoveTo(int x_, int y_) { - x = x_; - y = y_; -} - -static constexpr int Delta(int difference) noexcept { - if (difference < 0) - return -1; - else if (difference > 0) - return 1; - else - return 0; -} - -void SurfaceD2D::LineTo(int x_, int y_) { - if (pRenderTarget) { - const int xDiff = x_ - x; - const int xDelta = Delta(xDiff); - const int yDiff = y_ - y; - const int yDelta = Delta(yDiff); - if ((xDiff == 0) || (yDiff == 0)) { - // Horizontal or vertical lines can be more precisely drawn as a filled rectangle - const int xEnd = x_ - xDelta; - const int left = std::min(x, xEnd); - const int width = std::abs(x - xEnd) + 1; - const int yEnd = y_ - yDelta; - const int top = std::min(y, yEnd); - const int height = std::abs(y - yEnd) + 1; - const D2D1_RECT_F rectangle1 = D2D1::RectF(static_cast<float>(left), static_cast<float>(top), - static_cast<float>(left+width), static_cast<float>(top+height)); - pRenderTarget->FillRectangle(&rectangle1, pBrush); - } else if ((std::abs(xDiff) == std::abs(yDiff))) { - // 45 degree slope - pRenderTarget->DrawLine(D2D1::Point2F(x + 0.5f, y + 0.5f), - D2D1::Point2F(x_ + 0.5f - xDelta, y_ + 0.5f - yDelta), pBrush); - } else { - // Line has a different slope so difficult to avoid last pixel - pRenderTarget->DrawLine(D2D1::Point2F(x + 0.5f, y + 0.5f), - D2D1::Point2F(x_ + 0.5f, y_ + 0.5f), pBrush); - } - x = x_; - y = y_; - } -} - void SurfaceD2D::LineDraw(Point start, Point end, Stroke stroke) { D2DPenColourAlpha(stroke.colour); @@ -1841,35 +1579,6 @@ void SurfaceD2D::PolyLine(const Point *pts, size_t npts, Stroke stroke) { ReleaseUnknown(geometry); } -void SurfaceD2D::Polygon(Point *pts, size_t npts, ColourDesired fore, ColourDesired back) { - PLATFORM_ASSERT(pRenderTarget && (npts > 2)); - if (pRenderTarget) { - ID2D1PathGeometry *geometry = nullptr; - HRESULT hr = pD2DFactory->CreatePathGeometry(&geometry); - PLATFORM_ASSERT(geometry); - if (SUCCEEDED(hr) && geometry) { - ID2D1GeometrySink *sink = nullptr; - hr = geometry->Open(&sink); - PLATFORM_ASSERT(sink); - if (SUCCEEDED(hr) && sink) { - sink->BeginFigure(D2D1::Point2F(pts[0].x + 0.5f, pts[0].y + 0.5f), D2D1_FIGURE_BEGIN_FILLED); - for (size_t i=1; i<npts; i++) { - sink->AddLine(D2D1::Point2F(pts[i].x + 0.5f, pts[i].y + 0.5f)); - } - sink->EndFigure(D2D1_FIGURE_END_CLOSED); - sink->Close(); - ReleaseUnknown(sink); - - D2DPenColour(back); - pRenderTarget->FillGeometry(geometry,pBrush); - D2DPenColour(fore); - pRenderTarget->DrawGeometry(geometry,pBrush); - } - ReleaseUnknown(geometry); - } - } -} - void SurfaceD2D::Polygon(const Point *pts, size_t npts, FillStroke fillStroke) { PLATFORM_ASSERT(pRenderTarget && (npts > 2)); if (pRenderTarget) { @@ -1885,16 +1594,6 @@ void SurfaceD2D::Polygon(const Point *pts, size_t npts, FillStroke fillStroke) { } } -void SurfaceD2D::RectangleDraw(PRectangle rc, ColourDesired fore, ColourDesired back) { - if (pRenderTarget) { - const D2D1_RECT_F rectangle1 = D2D1::RectF(std::round(rc.left) + 0.5f, rc.top+0.5f, std::round(rc.right) - 0.5f, rc.bottom-0.5f); - D2DPenColour(back); - pRenderTarget->FillRectangle(&rectangle1, pBrush); - D2DPenColour(fore); - pRenderTarget->DrawRectangle(&rectangle1, pBrush); - } -} - void SurfaceD2D::RectangleDraw(PRectangle rc, FillStroke fillStroke) { if (!pRenderTarget) return; @@ -1919,14 +1618,6 @@ void SurfaceD2D::RectangleFrame(PRectangle rc, Stroke stroke) { } } -void SurfaceD2D::FillRectangle(PRectangle rc, ColourDesired back) { - if (pRenderTarget) { - D2DPenColour(back); - const D2D1_RECT_F rectangle1 = D2D1::RectF(std::round(rc.left), rc.top, std::round(rc.right), rc.bottom); - pRenderTarget->FillRectangle(&rectangle1, pBrush); - } -} - void SurfaceD2D::FillRectangle(PRectangle rc, Fill fill) { if (pRenderTarget) { D2DPenColourAlpha(fill.colour); @@ -1961,22 +1652,6 @@ void SurfaceD2D::FillRectangle(PRectangle rc, Surface &surfacePattern) { } } -void SurfaceD2D::RoundedRectangle(PRectangle rc, ColourDesired fore, ColourDesired back) { - if (pRenderTarget) { - D2D1_ROUNDED_RECT roundedRectFill = { - D2D1::RectF(rc.left+1.0f, rc.top+1.0f, rc.right-1.0f, rc.bottom-1.0f), - 4, 4}; - D2DPenColour(back); - pRenderTarget->FillRoundedRectangle(roundedRectFill, pBrush); - - D2D1_ROUNDED_RECT roundedRect = { - D2D1::RectF(rc.left + 0.5f, rc.top+0.5f, rc.right - 0.5f, rc.bottom-0.5f), - 4, 4}; - D2DPenColour(fore); - pRenderTarget->DrawRoundedRectangle(roundedRect, pBrush); - } -} - void SurfaceD2D::RoundedRectangle(PRectangle rc, FillStroke fillStroke) { if (pRenderTarget) { D2D1_ROUNDED_RECT roundedRectFill = { @@ -1993,35 +1668,6 @@ void SurfaceD2D::RoundedRectangle(PRectangle rc, FillStroke fillStroke) { } } -void SurfaceD2D::AlphaRectangle(PRectangle rc, int cornerSize, ColourDesired fill, int alphaFill, - ColourDesired outline, int alphaOutline, int /* flags*/ ) { - if (pRenderTarget) { - if (cornerSize == 0) { - // When corner size is zero, draw square rectangle to prevent blurry pixels at corners - const D2D1_RECT_F rectFill = D2D1::RectF(std::round(rc.left) + 1.0f, rc.top + 1.0f, std::round(rc.right) - 1.0f, rc.bottom - 1.0f); - D2DPenColour(fill, alphaFill); - pRenderTarget->FillRectangle(rectFill, pBrush); - - const D2D1_RECT_F rectOutline = D2D1::RectF(std::round(rc.left) + 0.5f, rc.top + 0.5f, std::round(rc.right) - 0.5f, rc.bottom - 0.5f); - D2DPenColour(outline, alphaOutline); - pRenderTarget->DrawRectangle(rectOutline, pBrush); - } else { - const float cornerSizeF = static_cast<float>(cornerSize); - D2D1_ROUNDED_RECT roundedRectFill = { - D2D1::RectF(std::round(rc.left) + 1.0f, rc.top + 1.0f, std::round(rc.right) - 1.0f, rc.bottom - 1.0f), - cornerSizeF - 1.0f, cornerSizeF - 1.0f }; - D2DPenColour(fill, alphaFill); - pRenderTarget->FillRoundedRectangle(roundedRectFill, pBrush); - - D2D1_ROUNDED_RECT roundedRect = { - D2D1::RectF(std::round(rc.left) + 0.5f, rc.top + 0.5f, std::round(rc.right) - 0.5f, rc.bottom - 0.5f), - cornerSizeF, cornerSizeF}; - D2DPenColour(outline, alphaOutline); - pRenderTarget->DrawRoundedRectangle(roundedRect, pBrush); - } - } -} - void SurfaceD2D::AlphaRectangle(PRectangle rc, XYPOSITION cornerSize, FillStroke fillStroke) { const D2D1_RECT_F rect = RectangleFromPRectangle(rc); const D2D1_RECT_F rectFill = RectangleInset(rect, fillStroke.stroke.width); @@ -2113,20 +1759,6 @@ void SurfaceD2D::DrawRGBAImage(PRectangle rc, int width, int height, const unsig } } -void SurfaceD2D::Ellipse(PRectangle rc, ColourDesired fore, ColourDesired back) { - if (pRenderTarget) { - const FLOAT radius = rc.Width() / 2.0f; - D2D1_ELLIPSE ellipse = { - D2D1::Point2F((rc.left + rc.right) / 2.0f, (rc.top + rc.bottom) / 2.0f), - radius,radius}; - - PenColour(back); - pRenderTarget->FillEllipse(ellipse, pBrush); - PenColour(fore); - pRenderTarget->DrawEllipse(ellipse, pBrush); - } -} - void SurfaceD2D::Ellipse(PRectangle rc, FillStroke fillStroke) { if (!pRenderTarget) return; @@ -2976,18 +2608,6 @@ void SurfaceD2D::FlushDrawing() { } } -void SurfaceD2D::SetUnicodeMode(bool unicodeMode_) { - mode.codePage = unicodeMode_ ? SC_CP_UTF8 : 0; -} - -void SurfaceD2D::SetDBCSMode(int codePage_) { - // No action on window as automatically handled by system. - mode.codePage = codePage_; -} - -void SurfaceD2D::SetBidiR2L(bool) { -} - #endif std::unique_ptr<Surface> Surface::Allocate(int technology) { |