Changeset 25189 in vbox
- Timestamp:
- Dec 4, 2009 1:37:54 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_cocoa_helper.m
r25188 r25189 156 156 GLfloat m_FBOThumbScaleX; 157 157 GLfloat m_FBOThumbScaleY; 158 uint64_t m_uiDockUpdateTime; 158 159 159 160 /* For clipping */ … … 1025 1026 [m_DockTileView thumbBitmap] != nil) 1026 1027 { 1028 /* Only update after atleast 200 ms, cause glReadPixels is 1029 * heavy performance wise. */ 1030 uint64_t uiNewTime = RTTimeMilliTS(); 1031 if (uiNewTime - m_uiDockUpdateTime > 200) 1032 { 1033 m_uiDockUpdateTime = uiNewTime; 1027 1034 #if 0 1028 /* todo: check this for optimization */1029 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, myTextureName);1030 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_STORAGE_HINT_APPLE,1031 GL_STORAGE_SHARED_APPLE);1032 glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE);1033 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA,1034 sizex, sizey, 0, GL_BGRA,1035 GL_UNSIGNED_INT_8_8_8_8_REV, myImagePtr);1036 glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB,1037 0, 0, 0, 0, 0, image_width, image_height);1038 glFlush();1039 // Do other work processing here, using a double or triple buffer1040 glGetTexImage(GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA,1041 GL_UNSIGNED_INT_8_8_8_8_REV, pixels);1035 /* todo: check this for optimization */ 1036 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, myTextureName); 1037 glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_STORAGE_HINT_APPLE, 1038 GL_STORAGE_SHARED_APPLE); 1039 glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); 1040 glTexImage2D(GL_TEXTURE_RECTANGLE_ARB, 0, GL_RGBA, 1041 sizex, sizey, 0, GL_BGRA, 1042 GL_UNSIGNED_INT_8_8_8_8_REV, myImagePtr); 1043 glCopyTexSubImage2D(GL_TEXTURE_RECTANGLE_ARB, 1044 0, 0, 0, 0, 0, image_width, image_height); 1045 glFlush(); 1046 // Do other work processing here, using a double or triple buffer 1047 glGetTexImage(GL_TEXTURE_RECTANGLE_ARB, 0, GL_BGRA, 1048 GL_UNSIGNED_INT_8_8_8_8_REV, pixels); 1042 1049 #endif 1043 1050 1044 GL_SAVE_STATE; 1045 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FBOThumbId); 1046 1047 /* We like to read from the primary color buffer */ 1048 glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); 1049 1050 NSRect rr = [m_DockTileView frame]; 1051 1052 /* Setup all matrices */ 1053 glMatrixMode(GL_PROJECTION); 1054 glLoadIdentity(); 1055 glViewport(0, 0, rr.size.width, rr.size.height); 1056 glOrtho(0, rr.size.width, 0, rr.size.height, -1, 1); 1057 glScalef(m_FBOThumbScaleX, m_FBOThumbScaleY, 1.0f); 1058 glMatrixMode(GL_TEXTURE); 1059 glLoadIdentity(); 1060 glTranslatef(0.0f, m_RootShift.y, 0.0f); 1061 glMatrixMode(GL_MODELVIEW); 1062 glLoadIdentity(); 1051 GL_SAVE_STATE; 1052 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, m_FBOThumbId); 1053 1054 /* We like to read from the primary color buffer */ 1055 glReadBuffer(GL_COLOR_ATTACHMENT0_EXT); 1056 1057 NSRect rr = [m_DockTileView frame]; 1058 1059 /* Setup all matrices */ 1060 glMatrixMode(GL_PROJECTION); 1061 glLoadIdentity(); 1062 glViewport(0, 0, rr.size.width, rr.size.height); 1063 glOrtho(0, rr.size.width, 0, rr.size.height, -1, 1); 1064 glScalef(m_FBOThumbScaleX, m_FBOThumbScaleY, 1.0f); 1065 glMatrixMode(GL_TEXTURE); 1066 glLoadIdentity(); 1067 glTranslatef(0.0f, m_RootShift.y, 0.0f); 1068 glMatrixMode(GL_MODELVIEW); 1069 glLoadIdentity(); 1070 1071 /* Clear background to transparent */ 1072 glClearColor(0.0f, 0.0f, 0.0f, 0.0f); 1073 glClear(GL_COLOR_BUFFER_BIT); 1074 1075 glEnable(GL_TEXTURE_RECTANGLE_ARB); 1076 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_FBOTexId); 1077 GLint i; 1078 for (i = 0; i < m_cClipRects; ++i) 1079 { 1080 GLint x1 = m_paClipRects[4*i]; 1081 GLint y1 = (r.size.height - m_paClipRects[4*i+1]); 1082 GLint x2 = m_paClipRects[4*i+2]; 1083 GLint y2 = (r.size.height - m_paClipRects[4*i+3]); 1084 glBegin(GL_QUADS); 1085 { 1086 glTexCoord2i(x1, y1); glVertex2i(x1, y1); 1087 glTexCoord2i(x1, y2); glVertex2i(x1, y2); 1088 glTexCoord2i(x2, y2); glVertex2i(x2, y2); 1089 glTexCoord2i(x2, y1); glVertex2i(x2, y1); 1090 } 1091 glEnd(); 1092 } 1093 glFinish(); 1094 1095 /* Here the magic of reading the FBO content in our own buffer 1096 * happens. We have to lock this access, in the case the dock 1097 * is updated currently. */ 1098 [m_DockTileView lock]; 1099 glReadPixels(0, 0, rr.size.width, rr.size.height, 1100 GL_RGBA, 1101 GL_UNSIGNED_BYTE, 1102 [[m_DockTileView thumbBitmap] bitmapData]); 1103 [m_DockTileView unlock]; 1104 1105 NSDockTile *pDT = [[NSApplication sharedApplication] dockTile]; 1106 1107 /* Send a display message to the dock tile in the main thread */ 1108 [[[NSApplication sharedApplication] dockTile] performSelectorOnMainThread:@selector(display) withObject:nil waitUntilDone:NO]; 1109 1110 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1111 GL_RESTORE_STATE; 1112 } 1063 1113 1064 1114 /* Clear background to transparent */ 1065 glClearColor(0.0f, 0.0f, 0.0f, 0.0f);1066 1115 glClear(GL_COLOR_BUFFER_BIT); 1067 1116 1068 glEnable(GL_TEXTURE_RECTANGLE_ARB);1069 glBindTexture(GL_TEXTURE_RECTANGLE_ARB, m_FBOTexId);1117 /* Blit the content of the FBO to the screen. todo: check for 1118 * optimization with display lists. */ 1070 1119 GLint i; 1071 1120 for (i = 0; i < m_cClipRects; ++i) 1072 1121 { 1073 1122 GLint x1 = m_paClipRects[4*i]; 1074 GLint y1 = (r.size.height - m_paClipRects[4*i+1]);1123 GLint y1 = r.size.height - m_paClipRects[4*i+1]; 1075 1124 GLint x2 = m_paClipRects[4*i+2]; 1076 GLint y2 = (r.size.height - m_paClipRects[4*i+3]);1125 GLint y2 = r.size.height - m_paClipRects[4*i+3]; 1077 1126 glBegin(GL_QUADS); 1078 1127 { … … 1084 1133 glEnd(); 1085 1134 } 1086 glFinish(); 1087 1088 /* Here the magic of reading the FBO content in our own buffer 1089 * happens. We have to lock this access, in the case the dock 1090 * is updated currently. */ 1091 [m_DockTileView lock]; 1092 glReadPixels(0, 0, rr.size.width, rr.size.height, 1093 GL_RGBA, 1094 GL_UNSIGNED_BYTE, 1095 [[m_DockTileView thumbBitmap] bitmapData]); 1096 [m_DockTileView unlock]; 1097 1098 NSDockTile *pDT = [[NSApplication sharedApplication] dockTile]; 1099 1100 /* Send a display message to the dock tile in the main thread */ 1101 [[[NSApplication sharedApplication] dockTile] performSelectorOnMainThread:@selector(display) withObject:nil waitUntilDone:NO]; 1102 1103 glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); 1104 GL_RESTORE_STATE; 1135 [m_pSharedGLCtx flushBuffer]; 1136 [m_pGLCtx makeCurrentContext]; 1105 1137 } 1106 1107 /* Clear background to transparent */1108 glClear(GL_COLOR_BUFFER_BIT);1109 1110 /* Blit the content of the FBO to the screen. todo: check for1111 * optimization with display lists. */1112 GLint i;1113 for (i = 0; i < m_cClipRects; ++i)1114 {1115 GLint x1 = m_paClipRects[4*i];1116 GLint y1 = r.size.height - m_paClipRects[4*i+1];1117 GLint x2 = m_paClipRects[4*i+2];1118 GLint y2 = r.size.height - m_paClipRects[4*i+3];1119 glBegin(GL_QUADS);1120 {1121 glTexCoord2i(x1, y1); glVertex2i(x1, y1);1122 glTexCoord2i(x1, y2); glVertex2i(x1, y2);1123 glTexCoord2i(x2, y2); glVertex2i(x2, y2);1124 glTexCoord2i(x2, y1); glVertex2i(x2, y1);1125 }1126 glEnd();1127 }1128 [m_pSharedGLCtx flushBuffer];1129 [m_pGLCtx makeCurrentContext];1130 1138 } 1131 1139 }
Note:
See TracChangeset
for help on using the changeset viewer.