Commit da50d6c1 authored by Sean McBride's avatar Sean McBride
Browse files

Purge support for OS X 10.5 and Carbon

Minimum SDK and deployment is now 10.6.
parent 0e0059d3
......@@ -289,10 +289,6 @@ IF(APPLE)
SET(CTEST_CUSTOM_WARNING_EXCEPTION
${CTEST_CUSTOM_WARNING_EXCEPTION}
"warning -.: directory name .* does not exist"
# Almost all of Carbon is deprecated, so mask deprecation warnings out
# of dashboard results for Carbon-specific files.
"vtkCarbonRenderWindow.*warning.*is deprecated"
)
ENDIF()
......
......@@ -4,11 +4,12 @@ set(VTK_USE_X_DEFAULT OFF)
if(APPLE AND NOT APPLE_IOS)
option(VTK_USE_COCOA "Use Cocoa for VTK render windows" ON)
option(VTK_USE_CARBON "Use Carbon for VTK render windows (deprecated)" OFF)
mark_as_advanced(VTK_USE_COCOA VTK_USE_CARBON)
if(VTK_USE_COCOA AND VTK_USE_CARBON)
message(FATAL_ERROR "You can't enable Carbon and Cocoa - you must choose one.")
endif()
mark_as_advanced(VTK_USE_COCOA)
# VTK_USE_CARBON was deprecated for several releases, then removed in VTK 7.
if (VTK_USE_CARBON)
message(FATAL_ERROR "Carbon support has been removed, but it appears that it was requested. If you require Carbon support, use VTK 6.x. Otherwise, turn off the VTK_USE_CARBON option.")
endif ()
elseif(UNIX AND NOT ANDROID AND NOT APPLE_IOS)
set(VTK_USE_X_DEFAULT ON)
endif()
......@@ -23,7 +24,7 @@ unset(VTK_CAN_DO_OFFSCREEN)
if(VTK_OPENGL_HAS_OSMESA OR WIN32)
set(VTK_CAN_DO_OFFSCREEN 1)
endif()
if(VTK_USE_X OR VTK_USE_CARBON OR VTK_USE_COCOA OR WIN32 OR ANDROID OR APPLE_IOS)
if(VTK_USE_X OR VTK_USE_COCOA OR WIN32 OR ANDROID OR APPLE_IOS)
set(VTK_USE_OSMESA FALSE)
else()
set(VTK_USE_OSMESA TRUE)
......
......@@ -301,6 +301,10 @@ if(APPLE)
CMAKE_OSX_DEPLOYMENT_TARGET
CMAKE_OSX_SYSROOT
)
if (CMAKE_OSX_DEPLOYMENT_TARGET AND CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS 10.6)
message(FATAL_ERROR "Minimun OS X deployment target is 10.6, please update CMAKE_OSX_DEPLOYMENT_TARGET.")
endif ()
endif()
#-----------------------------------------------------------------------------
......
......@@ -99,9 +99,7 @@ int vtkMultiThreader::GetGlobalDefaultNumberOfThreads()
#endif
#ifdef __APPLE__
// Determine the number of CPU cores. Prefer sysctlbyname()
// over MPProcessors() because it doesn't require CoreServices
// (which is only available in 32bit on Mac OS X 10.4).
// Determine the number of CPU cores.
// hw.logicalcpu takes into account cores/CPUs that are
// disabled because of power management.
size_t dataLen = sizeof(int); // 'num' is an 'int'
......
......@@ -14,18 +14,12 @@ IF (VTK_USE_MPI)
if (MPI_CXX_LIBRARIES)
TARGET_LINK_LIBRARIES(ParallelIso ${MPI_CXX_LIBRARIES})
endif()
IF(APPLE AND VTK_USE_CARBON)
TARGET_LINK_LIBRARIES(ParallelIso "-framework Carbon")
ENDIF()
ENDIF ()
SET(TaskPara_SRCS TaskParallelism.cxx task1.cxx task2.cxx)
ADD_EXECUTABLE(TaskParallelism ${TaskPara_SRCS})
TARGET_LINK_LIBRARIES (TaskParallelism vtkParallel)
IF(APPLE AND VTK_USE_CARBON)
TARGET_LINK_LIBRARIES(TaskParallelism "-framework Carbon")
ENDIF()
# ADD_EXECUTABLE(SimpleBenchmark SimpleBenchmark.cxx)
# TARGET_LINK_LIBRARIES(SimpleBenchmark vtkParallel ${MPI_LIBRARIES} )
......
......@@ -97,12 +97,6 @@ if(VTK_USE_X)
vtk_module_link_libraries(${vtk-module} LINK_PRIVATE ${X11_LIBRARIES})
endif()
if(APPLE)
if(VTK_USE_CARBON)
vtk_module_link_libraries(${vtk-module} LINK_PRIVATE "-framework Carbon" )
endif()
endif()
# This build plugin logic should just get migrated into a module I think.
if(BUILD_SHARED_LIBS)
set(PluginLibSrcs Q4VTKWidgetPlugin.cxx)
......
......@@ -55,9 +55,6 @@
#include "vtkInteractorStyleTrackballCamera.h"
#include "vtkRenderWindow.h"
#if defined(QVTK_USE_CARBON)
# include "vtkCarbonRenderWindow.h"
#endif
#include "vtkCommand.h"
#include "vtkOStrStreamWrapper.h"
#include "vtkObjectFactory.h"
......@@ -104,11 +101,6 @@ QVTKWidget::QVTKWidget(QWidget* p, Qt::WindowFlags f)
this->mCachedImage->SetOrigin(0,0,0);
this->mCachedImage->SetSpacing(1,1,1);
#if defined(QVTK_USE_CARBON)
this->DirtyRegionHandler = 0;
this->DirtyRegionHandlerUPP = 0;
#endif
mIrenAdapter = new QVTKInteractorAdapter(this);
}
......@@ -268,27 +260,6 @@ void QVTKWidget::SetRenderWindow(vtkRenderWindow* w)
this->mRenWin->AddObserver(vtkCommand::RenderEvent,
this, &QVTKWidget::renderEventCallback);
}
#if defined(QVTK_USE_CARBON)
if(mRenWin && !this->DirtyRegionHandlerUPP)
{
this->DirtyRegionHandlerUPP = NewEventHandlerUPP(QVTKWidget::DirtyRegionProcessor);
static EventTypeSpec events[] = { {'cute', 20}, {'Cute', 20} };
// kEventClassQt, kEventQtRequestWindowChange from qt_mac_p.h
// Suggested by Sam Magnuson at Trolltech as best portabile hack
// around Apple's missing functionality in HI Toolbox.
InstallEventHandler(GetApplicationEventTarget(), this->DirtyRegionHandlerUPP,
GetEventTypeCount(events), events,
reinterpret_cast<void*>(this), &this->DirtyRegionHandler);
}
else if(!mRenWin && this->DirtyRegionHandlerUPP)
{
RemoveEventHandler(this->DirtyRegionHandler);
DisposeEventHandlerUPP(this->DirtyRegionHandlerUPP);
this->DirtyRegionHandler = 0;
this->DirtyRegionHandlerUPP = 0;
}
#endif
}
......@@ -849,22 +820,6 @@ bool QVTKWidget::nativeEvent(const QByteArray& eventType, void* message, long* r
#endif
#endif
#if defined (QVTK_USE_CARBON)
OSStatus QVTKWidget::DirtyRegionProcessor(EventHandlerCallRef, EventRef event, void* wid)
{
QVTKWidget* widget = reinterpret_cast<QVTKWidget*>(wid);
UInt32 event_kind = GetEventKind(event);
UInt32 event_class = GetEventClass(event);
if((event_class == 'cute' || event_class == 'Cute') && event_kind == 20)
{
static_cast<vtkCarbonRenderWindow*>(widget->GetRenderWindow())->UpdateGLRegion();
}
return eventNotHandledErr;
}
#endif
//-----------------------------------------------------------------------------
bool QVTKWidget::paintCachedImage()
{
......
......@@ -55,20 +55,12 @@ class vtkTDxDevice;
#if defined(Q_WS_MAC)
# if defined(QT_MAC_USE_COCOA) && defined(VTK_USE_COCOA)
# define QVTK_USE_COCOA
# elif !defined(QT_MAC_USE_COCOA) && defined(VTK_USE_CARBON)
# define QVTK_USE_CARBON
# elif defined(VTK_USE_COCOA)
# error "VTK configured to use Cocoa, but Qt configured to use Carbon"
# elif defined(VTK_USE_CARBON)
# error "VTK configured to use Carbon, but Qt configured to use Cocoa"
# endif
#endif
#if defined(QVTK_USE_CARBON)
#include <Carbon/Carbon.h> // Event handling for dirty region
#endif
#include "QVTKWin32Header.h"
//! QVTKWidget displays a VTK window in a Qt window.
......@@ -257,12 +249,6 @@ protected:
#endif
#if defined(QVTK_USE_CARBON)
EventHandlerUPP DirtyRegionHandlerUPP;
EventHandlerRef DirtyRegionHandler;
static OSStatus DirtyRegionProcessor(EventHandlerCallRef er, EventRef event, void*);
#endif
protected:
vtkImageData* mCachedImage;
......
......@@ -70,9 +70,6 @@ const char *vtkGraphicsFactory::GetRenderLibrary()
#ifdef VTK_DISPLAY_WIN32_OGL
temp = "Win32OpenGL";
#endif
#ifdef VTK_DISPLAY_CARBON
temp = "CarbonOpenGL";
#endif
#ifdef VTK_DISPLAY_COCOA
temp = "CocoaOpenGL";
#endif
......
......@@ -9,11 +9,7 @@ set(VTK_USE_X_DEFAULT OFF)
if(APPLE)
option(VTK_USE_COCOA "Use Cocoa for VTK render windows" ON)
option(VTK_USE_CARBON "Use Carbon for VTK render windows (deprecated)" OFF)
mark_as_advanced(VTK_USE_COCOA VTK_USE_CARBON)
if(VTK_USE_COCOA AND VTK_USE_CARBON)
message(FATAL_ERROR "You can't enable Carbon and Cocoa - you must choose one.")
endif()
mark_as_advanced(VTK_USE_COCOA)
elseif(UNIX)
set(VTK_USE_X_DEFAULT ON)
endif()
......@@ -30,7 +26,7 @@ if(VTK_OPENGL_HAS_OSMESA OR WIN32)
set(VTK_CAN_DO_OFFSCREEN 1)
endif()
mark_as_advanced(VTK_OPENGL_HAS_OSMESA VTK_USE_OFFSCREEN)
if(VTK_USE_X OR VTK_USE_CARBON OR VTK_USE_COCOA OR WIN32)
if(VTK_USE_X OR VTK_USE_COCOA OR WIN32)
set(VTK_USE_OSMESA FALSE)
else()
set(VTK_USE_OSMESA TRUE)
......@@ -400,16 +396,6 @@ elseif(VTK_USE_COCOA)
PROPERTIES COMPILE_FLAGS "${VTK_REQUIRED_OBJCXX_FLAGS}")
endif()
set_source_files_properties(vtkCocoaGLView WRAP_EXCLUDE)
elseif(VTK_USE_CARBON)
# Add some custom overrides
list(APPEND vtk_module_overrides "vtkRenderWindowInteractor")
set(vtk_module_vtkRenderWindowInteractor_override "vtkCarbonRenderWindowInteractor")
list(APPEND vtk_module_overrides "vtkRenderWindow")
set(vtk_module_vtkRenderWindow_override "vtkCarbonRenderWindow")
list(APPEND Module_SRCS
vtkCarbonRenderWindowInteractor.cxx
vtkCarbonRenderWindow.cxx
)
endif()
# Now to see about the GPU info list.
......@@ -485,8 +471,6 @@ if(VTK_USE_X)
LINK_PUBLIC ${X11_LIBRARIES} ${X11_Xt_LIB})
elseif(VTK_USE_COCOA)
vtk_module_link_libraries(vtkRenderingOpenGL LINK_PUBLIC "-framework Cocoa")
elseif(VTK_USE_CARBON)
vtk_module_link_libraries(vtkRenderingOpenGL LINK_PUBLIC "-framework Carbon")
endif()
if(VTK_OPENGL_HAS_OSMESA)
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkCarbonRenderWindow.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkCarbonRenderWindow.h"
#include "vtkCarbonRenderWindowInteractor.h"
#include "vtkIdList.h"
#include "vtkObjectFactory.h"
#include "vtkOpenGLActor.h"
#include "vtkOpenGLCamera.h"
#include "vtkOpenGLLight.h"
#include "vtkOpenGLProperty.h"
#include "vtkOpenGLRenderer.h"
#include "vtkOpenGLTexture.h"
#include "vtkRendererCollection.h"
#include <math.h>
//----------------------------------------------------------------------------
vtkStandardNewMacro(vtkCarbonRenderWindow);
//----------------------------------------------------------------------------
// Dump agl errors to string, return error code
OSStatus aglReportError ()
{
GLenum err = aglGetError();
if (AGL_NO_ERROR != err)
cout << ((char *)aglErrorString(err));
// ensure we are returning an OSStatus noErr if no error condition
if (err == AGL_NO_ERROR)
return noErr;
else
return (OSStatus) err;
}
//----------------------------------------------------------------------------
// if error dump gl errors, return error
OSStatus glReportError ()
{
GLenum err = glGetError();
switch (err)
{
case GL_NO_ERROR:
break;
case GL_INVALID_ENUM:
cout << "GL Error: Invalid enumeration\n";
break;
case GL_INVALID_VALUE:
cout << "GL Error: Invalid value\n";
break;
case GL_INVALID_OPERATION:
cout << "GL Error: Invalid operation\n";
break;
case GL_STACK_OVERFLOW:
cout << "GL Error: Stack overflow\n";
break;
case GL_STACK_UNDERFLOW:
cout << "GL Error: Stack underflow\n";
break;
case GL_OUT_OF_MEMORY:
cout << "GL Error: Out of memory\n";
break;
}
// ensure we are returning an OSStatus noErr if no error condition
if (err == GL_NO_ERROR)
return noErr;
else
return (OSStatus) err;
}
//-----------------------------------------------------------------------------
static void* vtkCreateOSWindow(int width, int height, int pixel_size)
{
return malloc(width*height*pixel_size);
}
//-----------------------------------------------------------------------------
static void vtkDestroyOSWindow(void* win)
{
free(win);
}
class vtkCarbonRenderWindowInternal
{
public:
vtkCarbonRenderWindowInternal(vtkRenderWindow* win)
{
this->OffScreenWindow = NULL;
this->OffScreenContextId = NULL;
this->ScreenMapped = win->GetMapped();
this->ScreenDoubleBuffer = win->GetDoubleBuffer();
}
void* OffScreenWindow;
AGLContext OffScreenContextId;
AGLPixelFormat OffScreenPixelFmt;
int ScreenMapped;
int ScreenDoubleBuffer;
AGLPixelFormat ChoosePixelFormat(int accel, int offscreen, int doublebuff, int stereo,
int multisamples, int alphaBitPlanes, int stencil);
AGLContext CreateContext(int offscreen, int& doublebuff, int& stereo,
int& multisamples, int& alphaBitPlanes, int &stencil, const char*& error);
};
AGLPixelFormat vtkCarbonRenderWindowInternal::ChoosePixelFormat(int accel, int offscreen, int doublebuff,
int stereo, int multisamples, int alphaBitPlanes, int stencil)
{
int i = 0;
GLint attr[64];
if(offscreen)
{
attr[i++] = AGL_OFFSCREEN;
}
if(doublebuff)
{
attr[i++] = AGL_DOUBLEBUFFER;
}
attr[i++] = AGL_RGBA;
attr[i++] = AGL_DEPTH_SIZE;
attr[i++] = 32;
attr[i++] = AGL_PIXEL_SIZE;
attr[i++] = 32;
if(accel)
{
attr[i++] = AGL_ACCELERATED;
}
if(multisamples)
{
attr[i++] = AGL_SAMPLE_BUFFERS_ARB;
attr[i++] = 1;
attr[i++] = AGL_SAMPLES_ARB;
attr[i++] = multisamples;
attr[i++] = AGL_MULTISAMPLE;
}
if (alphaBitPlanes)
{
attr[i++] = AGL_ALPHA_SIZE;
attr[i++] = 8;
}
if(stereo)
{
attr[i++] = AGL_STEREO;
attr[i++] = GL_TRUE;
}
if(stencil)
{
attr[i++] = AGL_STENCIL_SIZE;
attr[i++] = 8;
}
attr[i++] = AGL_NO_RECOVERY; // must choose the pixel format we want!
attr[i++] = AGL_NONE;
return aglChoosePixelFormat (NULL, 0, attr);
}
AGLContext vtkCarbonRenderWindowInternal::CreateContext(int offscreen, int& doublebuff,
int& stereo, int& multisamples, int& alphaBitPlanes, int& stencil, const char*& error)
{
error = NULL;
AGLContext ctx = 0;
AGLPixelFormat fmt = 0;
int noSoftwareRendering = 1; // flip to zero if you're willing to do software
// rendering to get more features.
int _db, _a, _s, _m, _stencil;
for(_stencil = stencil; !fmt && _stencil >= 0; _stencil--)
{
for(_db = doublebuff; !fmt && _db >= 0; _db--)
{
for(_a = alphaBitPlanes; !fmt && _a >= 0; _a--)
{
for(_s = stereo; !fmt && _s >= 0; _s--)
{
for(_m = multisamples; !fmt && _m >= 0; _m--)
{
for(int accel = 1; !fmt && accel >= noSoftwareRendering; accel--)
{
fmt = this->ChoosePixelFormat(accel, offscreen, _db, _s, _m, _a, _stencil);
if(fmt)
{
doublebuff = _db;
stereo = _s;
multisamples = _m;
alphaBitPlanes = _a;
stencil = _stencil;
}
}
}
}
}
}
}
aglReportError (); // cough up any errors encountered
if (NULL == fmt)
{
error = "Could not find valid pixel format";
return NULL;
}
ctx = aglCreateContext (fmt, 0); // create without sharing
aglDestroyPixelFormat(fmt);
aglReportError (); // cough up errors
if (NULL == ctx)
{
error = "Could not create context";
return NULL;
}
return ctx;
}
//--------------------------------------------------------------------------
vtkCarbonRenderWindow::vtkCarbonRenderWindow()
{
this->Internal = new vtkCarbonRenderWindowInternal(this);
this->ApplicationInitialized = 0;
this->ContextId = 0;
this->WindowId = 0;
this->ParentId = 0;
this->RootWindow = 0;
this->OwnWindow = 0; // Keep before SetWindowName.
this->SetWindowName("Visualization Toolkit - Carbon");
this->CursorHidden = 0;
this->ForceMakeCurrent = 0;
this->RegionEventHandlerUPP = 0;
this->RegionEventHandler = 0;
}
// --------------------------------------------------------------------------
vtkCarbonRenderWindow::~vtkCarbonRenderWindow()
{
this->Finalize();
vtkRenderer *ren;
vtkCollectionSimpleIterator rit;
this->Renderers->InitTraversal(rit);
while ( (ren = this->Renderers->GetNextRenderer(rit)) )
{
ren->SetRenderWindow(NULL);
}
delete this->Internal;
}
//--------------------------------------------------------------------------
void vtkCarbonRenderWindow::DestroyWindow()
{
GLuint txId;
this->MakeCurrent();
// tell each of the renderers that this render window/graphics context
// is being removed (the RendererCollection is removed by vtkRenderWindow's
// destructor)
vtkCollectionSimpleIterator rsit;
vtkRenderer *ren;
for ( this->Renderers->InitTraversal(rsit);
(ren = this->Renderers->GetNextRenderer(rsit));)
{
ren->SetRenderWindow(NULL);
ren->SetRenderWindow(this);
}
/* finish OpenGL rendering */
if (this->ContextId)
{
/* now delete all textures */
glDisable(GL_TEXTURE_2D);
for (int i = 1; i < this->TextureResourceIds->GetNumberOfIds(); i++)
{
txId = (GLuint) this->TextureResourceIds->GetId(i);
#ifdef GL_VERSION_1_1
if (glIsTexture(txId))
{
glDeleteTextures(1, &txId);
}
#else
if (glIsList(txId))
{
glDeleteLists(txId,1);
}
#endif
}
aglSetCurrentContext(this->ContextId);
aglDestroyContext(this->ContextId);
this->ContextId = NULL;
}
// remove event filters if we have them
if(this->RegionEventHandler)
{
RemoveEventHandler(this->RegionEventHandler);
DisposeEventHandlerUPP(this->RegionEventHandlerUPP);
this->RegionEventHandler = 0;
this->RegionEventHandlerUPP = 0;
}
if (this->RootWindow && this->OwnWindow)
{
DisposeWindow(this->RootWindow);
this->RootWindow = 0;
this->WindowId = 0;
}
this->Mapped = 0;
}
//--------------------------------------------------------------------------
void vtkCarbonRenderWindow::SetWindowName( const char * _arg )
{
vtkWindow::SetWindowName(_arg);
if(this->OwnWindow)
{
CFStringRef newTitle =
CFStringCreateWithCString(kCFAllocatorDefault, _arg,
kCFStringEncodingUTF8);
SetWindowTitleWithCFString(this->RootWindow, newTitle);
CFRelease(newTitle);
}
}
//--------------------------------------------------------------------------
int vtkCarbonRenderWindow::GetEventPending()
{
return 0;
}
//--------------------------------------------------------------------------
// Set the window id to a pre-existing window.