summaryrefslogtreecommitdiff
path: root/indra/llwindow/llopenglview-objc.mm
diff options
context:
space:
mode:
authormobserveur <mobserveur@gmail.com>2025-09-16 16:46:51 +0200
committermobserveur <mobserveur@gmail.com>2025-09-16 16:46:51 +0200
commit7aa203297435674b7b598eb2764a6db7edbb4bc3 (patch)
tree26a1cd40dc4205ab5640f9066d5c768583c8226a /indra/llwindow/llopenglview-objc.mm
parent56c5cfa9fd9685180e0ba90625dfdc5475d0dc9a (diff)
Fixes the slow down related to the attached huds rendering
This commit fixes the long time issue with attached huds rendering, which was causing important slow down with certain combinations of post processing settings.
Diffstat (limited to 'indra/llwindow/llopenglview-objc.mm')
-rw-r--r--indra/llwindow/llopenglview-objc.mm129
1 files changed, 73 insertions, 56 deletions
diff --git a/indra/llwindow/llopenglview-objc.mm b/indra/llwindow/llopenglview-objc.mm
index 3058a6f289..bbdb176560 100644
--- a/indra/llwindow/llopenglview-objc.mm
+++ b/indra/llwindow/llopenglview-objc.mm
@@ -65,16 +65,16 @@ attributedStringInfo getSegments(NSAttributedString *str)
segment_standouts seg_standouts;
NSRange effectiveRange;
NSRange limitRange = NSMakeRange(0, [str length]);
-
+
while (limitRange.length > 0) {
NSNumber *attr = [str attribute:NSUnderlineStyleAttributeName atIndex:limitRange.location longestEffectiveRange:&effectiveRange inRange:limitRange];
limitRange = NSMakeRange(NSMaxRange(effectiveRange), NSMaxRange(limitRange) - NSMaxRange(effectiveRange));
-
+
if (effectiveRange.length <= 0)
{
effectiveRange.length = 1;
}
-
+
if ([attr integerValue] == 2)
{
seg_lengths.push_back(effectiveRange.length);
@@ -97,12 +97,12 @@ attributedStringInfo getSegments(NSAttributedString *str)
+ (NSScreen *)currentScreenForMouseLocation
{
NSPoint mouseLocation = [NSEvent mouseLocation];
-
+
NSEnumerator *screenEnumerator = [[NSScreen screens] objectEnumerator];
NSScreen *screen;
while ((screen = [screenEnumerator nextObject]) && !NSMouseInRect(mouseLocation, screen.frame, NO))
;
-
+
return screen;
}
@@ -111,7 +111,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
{
float normalizedX = fabs(fabs(self.frame.origin.x) - fabs(aPoint.x));
float normalizedY = aPoint.y - self.frame.origin.y;
-
+
return NSMakePoint(normalizedX, normalizedY);
}
@@ -124,6 +124,16 @@ attributedStringInfo getSegments(NSAttributedString *str)
@implementation LLOpenGLView
+- (NSOpenGLContext*) glContext
+{
+ return glContext;
+}
+
+- (NSOpenGLPixelFormat*) pixelFormat
+{
+ return pixelFormat;
+}
+
// Force a high quality update after live resizing
- (void) viewDidEndLiveResize
{
@@ -154,7 +164,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
{
vram_megabytes = 256;
}
-
+
return (unsigned long)vram_megabytes; // return value is in megabytes.
}
@@ -179,15 +189,15 @@ attributedStringInfo getSegments(NSAttributedString *str)
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowResized:) name:NSWindowDidResizeNotification
object:[self window]];
-
+
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowWillMiniaturize:) name:NSWindowWillMiniaturizeNotification
object:[self window]];
-
+
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification
object:[self window]];
-
+
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification
object:[self window]];
@@ -263,7 +273,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
{
[self registerForDraggedTypes:[NSArray arrayWithObject:NSURLPboardType]];
[self initWithFrame:frame];
-
+
// Initialize with a default "safe" pixel format that will work with versions dating back to OS X 10.6.
// Any specialized pixel formats, i.e. a core profile pixel format, should be initialized through rebuildContextWithFormat.
// 10.7 and 10.8 don't really care if we're defining a profile or not. If we don't explicitly request a core or legacy profile, it'll always assume a legacy profile (for compatibility reasons).
@@ -273,11 +283,11 @@ attributedStringInfo getSegments(NSAttributedString *str)
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAClosestPolicy,
NSOpenGLPFAAccelerated,
- NSOpenGLPFASampleBuffers, 0,
- NSOpenGLPFASamples, 0,
- NSOpenGLPFADepthSize, 24,
- NSOpenGLPFAAlphaSize, 8,
- NSOpenGLPFAColorSize, 32,
+ //NSOpenGLPFASampleBuffers, samples,
+ //NSOpenGLPFASamples, 0,
+ NSOpenGLPFADepthSize, 24,
+ //NSOpenGLPFAAlphaSize, 8,
+ NSOpenGLPFAColorSize, 24,
NSOpenGLPFAOpenGLProfile, NSOpenGLProfileVersion4_1Core,
0
};
@@ -288,8 +298,8 @@ attributedStringInfo getSegments(NSAttributedString *str)
NSOpenGLPFADoubleBuffer,
NSOpenGLPFAClosestPolicy,
NSOpenGLPFAAccelerated,
- NSOpenGLPFASampleBuffers, 0,
- NSOpenGLPFASamples, 0,
+ //NSOpenGLPFASampleBuffers, samples,
+ //NSOpenGLPFASamples, 0,
NSOpenGLPFAColorFloat,
NSOpenGLPFAColorSize, 64,
NSOpenGLPFADepthSize, 24,
@@ -297,7 +307,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
0
};
- NSOpenGLPixelFormat *pixelFormat = nil;
+ //NSOpenGLPixelFormat *pixelFormat = nil;
mHDRDisplay = NO;
@@ -325,15 +335,15 @@ attributedStringInfo getSegments(NSAttributedString *str)
NSLog(@"Failed to create pixel format!", nil);
return nil;
}
-
- NSOpenGLContext *glContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
-
+
+ glContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat shareContext:nil];
+
if (glContext == nil)
{
NSLog(@"Failed to create OpenGL context!", nil);
return nil;
}
-
+
[self setPixelFormat:pixelFormat];
if(mHDRDisplay)
@@ -353,25 +363,32 @@ attributedStringInfo getSegments(NSAttributedString *str)
[self setWantsBestResolutionOpenGLSurface:gHiDPISupport];
[self setOpenGLContext:glContext];
-
+
[glContext setView:self];
-
+
[glContext makeCurrentContext];
-
+
+/*
if (vsync)
{
GLint value = 1;
[glContext setValues:&value forParameter:NSOpenGLCPSwapInterval];
- } else {
+ }
+ else
+ {
+ */
// supress this error after move to Xcode 7:
// error: null passed to a callee that requires a non-null argument [-Werror,-Wnonnull]
// Tried using ObjC 'nonnull' keyword as per SO article but didn't build
- GLint swapInterval=0;
+ GLint swapInterval = 0;
[glContext setValues:&swapInterval forParameter:NSOpenGLCPSwapInterval];
- }
-
+ //}
+
+ GLint opacity = 1;
+ [glContext setValues:&opacity forParameter:NSOpenGLCPSurfaceOpacity];
+
mOldResize = false;
-
+
return self;
}
@@ -383,16 +400,16 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (BOOL) rebuildContextWithFormat:(NSOpenGLPixelFormat *)format
{
NSOpenGLContext *ctx = [self openGLContext];
-
+
[ctx clearDrawable];
[ctx initWithFormat:format shareContext:nil];
-
+
if (ctx == nil)
{
NSLog(@"Failed to create OpenGL context!", nil);
return false;
}
-
+
[self setOpenGLContext:ctx];
[ctx setView:self];
[ctx makeCurrentContext];
@@ -479,9 +496,9 @@ attributedStringInfo getSegments(NSAttributedString *str)
float(dev_delta.x),
float(dev_delta.y)
};
-
+
callDeltaUpdate(mouseDeltas, 0);
-
+
NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
mMousePos[0] = mPoint.x;
mMousePos[1] = mPoint.y;
@@ -503,9 +520,9 @@ attributedStringInfo getSegments(NSAttributedString *str)
float(dev_delta.x),
float(dev_delta.y)
};
-
+
callDeltaUpdate(mouseDeltas, 0);
-
+
NSPoint mPoint = gHiDPISupport ? [self convertPointToBacking:[theEvent locationInWindow]] : [theEvent locationInWindow];
mMousePos[0] = mPoint.x;
mMousePos[1] = mPoint.y;
@@ -535,7 +552,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void) otherMouseDragged:(NSEvent *)theEvent
{
- [self mouseDragged:theEvent];
+ [self mouseDragged:theEvent];
}
- (void) scrollWheel:(NSEvent *)theEvent
@@ -559,7 +576,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
{
NativeKeyEventData eventData = extractKeyDataFromKeyEvent(theEvent);
eventData.mKeyEvent = NativeKeyEventData::KEYDOWN;
-
+
uint keycode = [theEvent keyCode];
// We must not depend on flagsChange event to detect modifier flags changed,
// must depend on the modifire flags in the event parameter.
@@ -593,13 +610,13 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (void)flagsChanged:(NSEvent *)theEvent
{
NativeKeyEventData eventData = extractKeyDataFromModifierEvent(theEvent);
-
+
mModifiers = [theEvent modifierFlags];
callModifier([theEvent modifierFlags]);
-
+
NSInteger mask = 0;
switch([theEvent keyCode])
- {
+ {
case 56:
mask = NSShiftKeyMask;
break;
@@ -610,9 +627,9 @@ attributedStringInfo getSegments(NSAttributedString *str)
mask = NSControlKeyMask;
break;
default:
- return;
+ return;
}
-
+
if (mModifiers & mask)
{
eventData.mKeyEvent = NativeKeyEventData::KEYDOWN;
@@ -631,7 +648,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
{
eventData.mKeyEvent = NativeKeyEventData::KEYUP;
callKeyUp(&eventData, [theEvent keyCode], 0);
- }
+ }
}
- (BOOL) acceptsFirstResponder
@@ -643,11 +660,11 @@ attributedStringInfo getSegments(NSAttributedString *str)
{
NSPasteboard *pboard;
NSDragOperation sourceDragMask;
-
+
sourceDragMask = [sender draggingSourceOperationMask];
-
+
pboard = [sender draggingPasteboard];
-
+
if ([[pboard types] containsObject:NSURLPboardType])
{
if (sourceDragMask & NSDragOperationLink) {
@@ -662,7 +679,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
- (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender
{
callHandleDragUpdated(mLastDraggedUrl);
-
+
return NSDragOperationLink;
}
@@ -716,12 +733,12 @@ attributedStringInfo getSegments(NSAttributedString *str)
unsigned(selectedRange.location),
unsigned(selectedRange.length)
};
-
+
unsigned int replacement[2] = {
unsigned(replacementRange.location),
unsigned(replacementRange.length)
};
-
+
int string_length = [aString length];
unichar *text = new unichar[string_length];
attributedStringInfo segments;
@@ -822,7 +839,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
return;
}
}
-
+
@try
{
if (!mHasMarkedText)
@@ -835,7 +852,7 @@ attributedStringInfo getSegments(NSAttributedString *str)
resetPreedit();
// We may never get this point since unmarkText may be called before insertText ever gets called once we submit our text.
// But just in case...
-
+
for (NSInteger i = 0; i < [aString length]; i++)
{
handleUnicodeCharacter([aString characterAtIndex:i]);
@@ -981,10 +998,10 @@ attributedStringInfo getSegments(NSAttributedString *str)
NSPoint screenPoint = [[view window] convertBaseToScreen:windowPoint];
NSPoint flippedScreenPoint = [currentScreen flipPoint:screenPoint];
flippedScreenPoint.y += [currentScreen frame].origin.y;
-
+
return flippedScreenPoint;
}
-
+
return NSZeroPoint;
}