Browse Source

Added an internal flag JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS

tags/2021-05-28
jules 9 years ago
parent
commit
e0f5218121
1 changed files with 32 additions and 4 deletions
  1. +32
    -4
      modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm

+ 32
- 4
modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm View File

@@ -69,7 +69,6 @@ public:
view (nil), view (nil),
isSharedWindow (viewToAttachTo != nil), isSharedWindow (viewToAttachTo != nil),
fullScreen (false), fullScreen (false),
insideDrawRect (false),
#if USE_COREGRAPHICS_RENDERING #if USE_COREGRAPHICS_RENDERING
usingCoreGraphics (true), usingCoreGraphics (true),
#else #else
@@ -793,6 +792,37 @@ public:
displayScale = (float) screen.backingScaleFactor; displayScale = (float) screen.backingScaleFactor;
#endif #endif
#if USE_COREGRAPHICS_RENDERING && JUCE_COREGRAPHICS_RENDER_WITH_MULTIPLE_PAINT_CALLS
// This option invokes a separate paint call for each rectangle of the clip region.
// It's a long story, but this is a basically a workaround for a CGContext not having
// a way of finding whether a rectangle falls within its clip region
if (usingCoreGraphics)
{
const NSRect* rects = nullptr;
NSInteger numRects = 0;
[view getRectsBeingDrawn: &rects count: &numRects];
if (numRects > 1)
{
for (int i = 0; i < numRects; ++i)
{
NSRect rect = rects[i];
CGContextSaveGState (cg);
CGContextClipToRect (cg, CGRectMake (rect.origin.x, rect.origin.y, rect.size.width, rect.size.height));
drawRect (cg, rect, displayScale);
CGContextRestoreGState (cg);
}
return;
}
}
#endif
drawRect (cg, r, displayScale);
}
void drawRect (CGContextRef cg, NSRect r, float displayScale)
{
#if USE_COREGRAPHICS_RENDERING #if USE_COREGRAPHICS_RENDERING
if (usingCoreGraphics) if (usingCoreGraphics)
{ {
@@ -872,9 +902,7 @@ public:
void invokePaint (LowLevelGraphicsContext& context) void invokePaint (LowLevelGraphicsContext& context)
{ {
lastRepaintTime = Time::getCurrentTime(); lastRepaintTime = Time::getCurrentTime();
insideDrawRect = true;
handlePaint (context); handlePaint (context);
insideDrawRect = false;
} }
void performAnyPendingRepaintsNow() override void performAnyPendingRepaintsNow() override
@@ -1283,7 +1311,7 @@ public:
//============================================================================== //==============================================================================
NSWindow* window; NSWindow* window;
NSView* view; NSView* view;
bool isSharedWindow, fullScreen, insideDrawRect;
bool isSharedWindow, fullScreen;
bool usingCoreGraphics, isZooming, textWasInserted; bool usingCoreGraphics, isZooming, textWasInserted;
String stringBeingComposed; String stringBeingComposed;
NSNotificationCenter* notificationCenter; NSNotificationCenter* notificationCenter;


Loading…
Cancel
Save