Skip to content
Snippets Groups Projects
Commit 5076eecb authored by Jaswant Panchumarti (Kitware)'s avatar Jaswant Panchumarti (Kitware)
Browse files

Revert "Merge topic 'cocoa-thread-safety'"

This reverts commit 911f2f99, reversing
changes made to f8463163.
parent 00632c39
No related branches found
No related tags found
No related merge requests found
......@@ -76,7 +76,6 @@ vtk_add_test_cxx(vtkRenderingOpenGL2CxxTests tests
TestPropPicker2Renderers.cxx,NO_DATA
TestRemoveActorNonCurrentContext.cxx
TestRenderToImage.cxx
TestRenderWindowDifferentThread.cxx,NO_DATA
TestSetZBuffer.cxx
TestShadowMapBakerPass.cxx
TestShadowMapPass.cxx
......
/*=========================================================================
Program: Visualization Toolkit
Module: TestRenderWindowDifferentThread.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 "vtkActor.h"
#include "vtkCamera.h"
#include "vtkCylinderSource.h"
#include "vtkLogger.h"
#include "vtkNew.h"
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkRegressionTestImage.h"
#include "vtkRenderWindow.h"
#include "vtkRenderer.h"
#include <future>
#include <sstream>
#include <string>
#include <thread>
int Start(int argc, char* argv[])
{
vtkLogger::SetThreadName("Render Thread");
std::hash<std::thread::id> tid_hash{};
auto tid = tid_hash(std::this_thread::get_id());
vtkLog(INFO, << "Rendering on " << tid);
// Create a cylinder
vtkNew<vtkCylinderSource> cylinderSource;
cylinderSource->SetCenter(0.0, 0.0, 0.0);
cylinderSource->SetRadius(5.0);
cylinderSource->SetHeight(10.0);
cylinderSource->SetResolution(100);
// Create a mapper and actor
vtkNew<vtkPolyDataMapper> mapper;
mapper->SetInputConnection(cylinderSource->GetOutputPort());
vtkNew<vtkActor> actor;
actor->GetProperty()->SetColor(1.0, 0.38, 0.278);
actor->SetMapper(mapper);
actor->RotateX(30.0);
actor->RotateY(-45.0);
// Create a renderer
vtkNew<vtkRenderer> renderer;
renderer->AddActor(actor);
renderer->SetBackground(0.1, 0.2, 0.4);
renderer->ResetCamera();
// Create a render window initialized for offscreen rendering. you won't see it.
vtkNew<vtkRenderWindow> renWin;
renWin->OffScreenRenderingOn();
renWin->AddRenderer(renderer);
renWin->SetSize(1920, 1080);
renWin->Render();
int retVal = vtkRegressionTestImage(renWin);
return !retVal;
}
int TestRenderWindowDifferentThread(int argc, char* argv[])
{
vtkLogger::SetStderrVerbosity(vtkLogger::VERBOSITY_INFO);
std::future<int> fut = std::async(std::launch::async, &Start, argc, argv);
std::hash<std::thread::id> tid_hash{};
auto tid = tid_hash(std::this_thread::get_id());
vtkLog(INFO, << "Main thread " << tid);
int result = vtkRegressionTester::FAILED;
result = fut.get();
vtkLog(INFO, << "result=" << result);
return result;
}
a2284d940ba94194b346e13cc8d73fdd89537e796720d9378da4d1b91120b46eba63f8ccad27e8bba27aba24cc265decdafcb4bed5ec6db662bd866f49474204
......@@ -737,9 +737,8 @@ void vtkCocoaRenderWindow::CreateAWindow()
// This will show the menu and the dock
//[theWindow setLevel:NSFloatingWindowLevel];
}
else if (!this->UseOffScreenBuffers)
else
{
// initialize the window area only when we're not using offscreen buffers.
if ((this->Size[0] + this->Size[1]) == 0)
{
this->Size[0] = 300;
......@@ -772,28 +771,26 @@ void vtkCocoaRenderWindow::CreateAWindow()
backing:NSBackingStoreBuffered
defer:NO];
}
if (theWindow)
{
this->SetRootWindow(theWindow);
this->WindowCreated = 1;
// Since we created the NSWindow, give it a title.
NSString* winName = [NSString stringWithFormat:@"Visualization Toolkit - Cocoa #%u", count++];
this->SetWindowName([winName UTF8String]);
// makeKeyAndOrderFront: will show the window
if (this->ShowWindow)
{
[theWindow makeKeyAndOrderFront:nil];
[theWindow setAcceptsMouseMovedEvents:YES];
}
}
else if (!this->UseOffScreenBuffers)
if (!theWindow)
{
// if we're not using offscreen buffers, we need 'theWindow' for it's default framebuffer.
vtkErrorMacro("Could not create window, serious error!");
return;
}
this->SetRootWindow(theWindow);
this->WindowCreated = 1;
// Since we created the NSWindow, give it a title.
NSString* winName = [NSString stringWithFormat:@"Visualization Toolkit - Cocoa #%u", count++];
this->SetWindowName([winName UTF8String]);
// makeKeyAndOrderFront: will show the window
if (this->ShowWindow)
{
[theWindow makeKeyAndOrderFront:nil];
[theWindow setAcceptsMouseMovedEvents:YES];
}
}
// create an NSView if one has not been specified
......@@ -870,9 +867,8 @@ void vtkCocoaRenderWindow::CreateAWindow()
[glView release];
#endif
}
else if (!this->UseOffScreenBuffers)
else
{
// do not initialize gui frame when using offscreen buffers.
NSRect backingViewRect = NSMakeRect(0.0, 0.0, (CGFloat)this->Size[0], (CGFloat)this->Size[1]);
// Convert from points to pixels.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment