comparison src/video/quartz/SDL_QuartzVideo.m @ 1183:634d85aefc8c

Fixed bug reported here: http://www.devolution.com/pipermail/sdl/2005-October/070998.html --ryan.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 22 Nov 2005 09:59:42 +0000
parents 49d3efec6651
children c96b326b90ba
comparison
equal deleted inserted replaced
1182:e8e8dcb68e7a 1183:634d85aefc8c
654 ERR_NO_CAPTURE: if (!gamma_error) { QZ_FadeGammaIn (this, &gamma_table); } 654 ERR_NO_CAPTURE: if (!gamma_error) { QZ_FadeGammaIn (this, &gamma_table); }
655 ERR_NO_MATCH: return NULL; 655 ERR_NO_MATCH: return NULL;
656 } 656 }
657 657
658 static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width, 658 static SDL_Surface* QZ_SetVideoWindowed (_THIS, SDL_Surface *current, int width,
659 int height, int bpp, Uint32 flags) { 659 int height, int *bpp, Uint32 flags) {
660 unsigned int style; 660 unsigned int style;
661 NSRect contentRect; 661 NSRect contentRect;
662 BOOL isCustom = NO; 662 BOOL isCustom = NO;
663 int center_window = 1; 663 int center_window = 1;
664 int origin_x, origin_y; 664 int origin_x, origin_y;
772 } 772 }
773 773
774 /* For OpenGL, we bind the context to a subview */ 774 /* For OpenGL, we bind the context to a subview */
775 if ( flags & SDL_OPENGL ) { 775 if ( flags & SDL_OPENGL ) {
776 776
777 if ( ! QZ_SetupOpenGL (this, bpp, flags) ) { 777 if ( ! QZ_SetupOpenGL (this, *bpp, flags) ) {
778 return NULL; 778 return NULL;
779 } 779 }
780 780
781 window_view = [ [ NSView alloc ] initWithFrame:contentRect ]; 781 window_view = [ [ NSView alloc ] initWithFrame:contentRect ];
782 [ window_view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable ]; 782 [ window_view setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable ];
787 [ qz_window makeKeyAndOrderFront:nil ]; 787 [ qz_window makeKeyAndOrderFront:nil ];
788 current->flags |= SDL_OPENGL; 788 current->flags |= SDL_OPENGL;
789 } 789 }
790 /* For 2D, we set the subview to an NSQuickDrawView */ 790 /* For 2D, we set the subview to an NSQuickDrawView */
791 else { 791 else {
792 short qdbpp = 0;
792 793
793 /* Only recreate the view if it doesn't already exist */ 794 /* Only recreate the view if it doesn't already exist */
794 if (window_view == nil) { 795 if (window_view == nil) {
795 796
796 window_view = [ [ NSQuickDrawView alloc ] initWithFrame:contentRect ]; 797 window_view = [ [ NSQuickDrawView alloc ] initWithFrame:contentRect ];
801 } 802 }
802 803
803 LockPortBits ( [ window_view qdPort ] ); 804 LockPortBits ( [ window_view qdPort ] );
804 current->pixels = GetPixBaseAddr ( GetPortPixMap ( [ window_view qdPort ] ) ); 805 current->pixels = GetPixBaseAddr ( GetPortPixMap ( [ window_view qdPort ] ) );
805 current->pitch = GetPixRowBytes ( GetPortPixMap ( [ window_view qdPort ] ) ); 806 current->pitch = GetPixRowBytes ( GetPortPixMap ( [ window_view qdPort ] ) );
807 qdbpp = GetPixDepth ( GetPortPixMap ( [ window_view qdPort ] ) );
806 UnlockPortBits ( [ window_view qdPort ] ); 808 UnlockPortBits ( [ window_view qdPort ] );
809
810 /* QuickDraw may give a 16-bit shadow surface on 8-bit displays! */
811 *bpp = qdbpp;
807 812
808 current->flags |= SDL_SWSURFACE; 813 current->flags |= SDL_SWSURFACE;
809 current->flags |= SDL_PREALLOC; 814 current->flags |= SDL_PREALLOC;
810 current->flags |= SDL_ASYNCBLIT; 815 current->flags |= SDL_ASYNCBLIT;
811 816
817 int vOffset = [ qz_window frame ].size.height - 822 int vOffset = [ qz_window frame ].size.height -
818 [ window_view frame ].size.height - [ window_view frame ].origin.y; 823 [ window_view frame ].size.height - [ window_view frame ].origin.y;
819 824
820 int hOffset = [ window_view frame ].origin.x; 825 int hOffset = [ window_view frame ].origin.x;
821 826
822 current->pixels += (vOffset * current->pitch) + hOffset * (device_bpp/8); 827 current->pixels += (vOffset * current->pitch) + hOffset * (qdbpp/8);
823 } 828 }
824 this->UpdateRects = QZ_UpdateRects; 829 this->UpdateRects = QZ_UpdateRects;
825 this->LockHWSurface = QZ_LockWindow; 830 this->LockHWSurface = QZ_LockWindow;
826 this->UnlockHWSurface = QZ_UnlockWindow; 831 this->UnlockHWSurface = QZ_UnlockWindow;
827 } 832 }
846 } 851 }
847 /* Setup windowed video */ 852 /* Setup windowed video */
848 else { 853 else {
849 /* Force bpp to the device's bpp */ 854 /* Force bpp to the device's bpp */
850 bpp = device_bpp; 855 bpp = device_bpp;
851 current = QZ_SetVideoWindowed (this, current, width, height, bpp, flags); 856 current = QZ_SetVideoWindowed (this, current, width, height, &bpp, flags);
852 if (current == NULL) 857 if (current == NULL)
853 return NULL; 858 return NULL;
854 } 859 }
855 860
856 /* Setup the new pixel format */ 861 /* Setup the new pixel format */