Browse Source

Minor iPhone GL updates, fix for juce_WithoutMacros.h

tags/2021-05-28
Julian Storer 16 years ago
parent
commit
97e9095933
15 changed files with 107 additions and 130 deletions
  1. +3
    -1
      extras/juce demo/Source/demos/OpenGLDemo.cpp
  2. +31
    -42
      juce_amalgamated.cpp
  3. +22
    -23
      juce_amalgamated.h
  4. +2
    -3
      src/audio/plugins/formats/juce_AudioUnitPluginFormat.mm
  5. +1
    -2
      src/gui/components/special/juce_OpenGLComponent.cpp
  6. +1
    -2
      src/gui/components/special/juce_OpenGLComponent.h
  7. +2
    -2
      src/gui/graphics/geometry/juce_Rectangle.h
  8. +8
    -11
      src/io/files/juce_File.cpp
  9. +16
    -16
      src/io/files/juce_File.h
  10. +3
    -3
      src/io/streams/juce_BufferedInputStream.h
  11. +3
    -3
      src/io/streams/juce_OutputStream.cpp
  12. +1
    -9
      src/native/linux/juce_linux_Windowing.cpp
  13. +3
    -2
      src/native/mac/juce_mac_OpenGLComponent.mm
  14. +1
    -1
      src/native/windows/juce_win32_OpenGLComponent.cpp
  15. +10
    -10
      src/native/windows/juce_win32_WASAPI.cpp

+ 3
- 1
extras/juce demo/Source/demos/OpenGLDemo.cpp View File

@@ -165,7 +165,8 @@ public:
glOrthof (-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f);
glMatrixMode (GL_MODELVIEW);
glRotatef (1.0f, 0.0f, 0.0f, 1.0f);
glPushMatrix();
glRotatef (rotation, 0.0f, 0.0f, 1.0f);
glVertexPointer (2, GL_FLOAT, 0, vertices);
glEnableClientState (GL_VERTEX_ARRAY);
@@ -173,6 +174,7 @@ public:
glEnableClientState (GL_COLOR_ARRAY);
glDrawArrays (GL_TRIANGLE_STRIP, 0, 4);
glPopMatrix();
#else
glOrtho (0.0, getWidth(), 0.0, getHeight(), 0, 1);


+ 31
- 42
juce_amalgamated.cpp View File

@@ -5282,10 +5282,10 @@ OutputStream::~OutputStream()
#endif
}

void OutputStream::writeBool (bool b)
void OutputStream::writeBool (const bool b)
{
writeByte ((b) ? (char) 1
: (char) 0);
writeByte (b ? (char) 1
: (char) 0);
}

void OutputStream::writeByte (char byte)
@@ -6482,29 +6482,26 @@ const File File::withFileExtension (const String& newExtension) const
String filePart (getFileName());

int i = filePart.lastIndexOfChar (T('.'));
if (i < 0)
i = filePart.length();

String newExt (newExtension);
if (i >= 0)
filePart = filePart.substring (0, i);

if (newExt.isNotEmpty() && ! newExt.startsWithChar (T('.')))
newExt = T(".") + newExt;
if (newExtension.isNotEmpty() && ! newExtension.startsWithChar (T('.')))
filePart << '.';

return getSiblingFile (filePart.substring (0, i) + newExt);
return getSiblingFile (filePart + newExtension);
}

bool File::startAsProcess (const String& parameters) const
{
return exists()
&& juce_launchFile (fullPath, parameters);
return exists() && juce_launchFile (fullPath, parameters);
}

FileInputStream* File::createInputStream() const
{
if (existsAsFile())
return new FileInputStream (*this);
else
return 0;
return 0;
}

FileOutputStream* File::createOutputStream (const int bufferSize) const
@@ -30667,8 +30664,7 @@ public:

~AudioUnitPluginWindowCarbon()
{
deleteAndZero (innerWrapper);

innerWrapper = 0;
activeWindows.removeValue (this);

if (isValid())
@@ -30779,7 +30775,7 @@ private:
};

friend class InnerWrapperComponent;
InnerWrapperComponent* innerWrapper;
ScopedPointer<InnerWrapperComponent> innerWrapper;
};

#endif
@@ -74829,7 +74825,6 @@ private:

OpenGLComponent::OpenGLComponent (const OpenGLType type_)
: type (type_),
context (0),
contextToShareListsWith (0),
needToUpdateViewport (true)
{
@@ -74846,7 +74841,7 @@ OpenGLComponent::~OpenGLComponent()
void OpenGLComponent::deleteContext()
{
const ScopedLock sl (contextLock);
deleteAndZero (context);
context = 0;
}

void OpenGLComponent::updateContextPosition()
@@ -219252,7 +219247,7 @@ OpenGLContext* OpenGLComponent::createContext()

void* OpenGLComponent::getNativeWindowHandle() const
{
return context != 0 ? ((WindowedGLContext*) context)->getNativeWindowHandle() : 0;
return context != 0 ? static_cast<WindowedGLContext*> (static_cast<OpenGLContext*> (context))->getNativeWindowHandle() : 0;
}

void juce_glViewport (const int w, const int h)
@@ -226842,24 +226837,24 @@ public:
jassert (hasScanned); // need to call scanForDevices() before doing this

const bool useExclusiveMode = false;
WASAPIAudioIODevice* d = 0;
ScopedPointer<WASAPIAudioIODevice> device;

const int outputIndex = outputDeviceNames.indexOf (outputDeviceName);
const int inputIndex = inputDeviceNames.indexOf (inputDeviceName);

if (outputIndex >= 0 || inputIndex >= 0)
{
d = new WASAPIAudioIODevice (outputDeviceName.isNotEmpty() ? outputDeviceName
: inputDeviceName,
outputDeviceIds [outputIndex],
inputDeviceIds [inputIndex],
useExclusiveMode);
device = new WASAPIAudioIODevice (outputDeviceName.isNotEmpty() ? outputDeviceName
: inputDeviceName,
outputDeviceIds [outputIndex],
inputDeviceIds [inputIndex],
useExclusiveMode);

if (! d->initialise())
deleteAndZero (d);
if (! device->initialise())
device = 0;
}

return d;
return device.release();
}

juce_UseDebuggingNewOperator
@@ -231691,7 +231686,6 @@ public:
wy (0),
ww (0),
wh (0),
taskbarImage (0),
fullScreen (false),
mapped (false),
visual (0),
@@ -231712,7 +231706,6 @@ public:
// it's dangerous to delete a window on a thread other than the message thread..
jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager());

deleteTaskBarIcon();
deleteIconPixmaps();

destroyWindow();
@@ -232720,7 +232713,6 @@ public:
void setTaskBarIcon (const Image& image)
{
ScopedXLock xlock;
deleteTaskBarIcon();
taskbarImage = image.createCopy();

Screen* const screen = XDefaultScreenOfDisplay (display);
@@ -232775,11 +232767,6 @@ public:
XFree (hints);
}

void deleteTaskBarIcon()
{
deleteAndZero (taskbarImage);
}

const Image* getTaskbarIcon() const throw() { return taskbarImage; }

juce_UseDebuggingNewOperator
@@ -232947,7 +232934,7 @@ private:
friend class LinuxRepaintManager;
Window windowH, parentWindow;
int wx, wy, ww, wh;
Image* taskbarImage;
ScopedPointer<Image> taskbarImage;
bool fullScreen, mapped;
Visual* visual;
int depth;
@@ -241891,7 +241878,7 @@ OpenGLContext* OpenGLComponent::createContext()

void* OpenGLComponent::getNativeWindowHandle() const
{
return context != 0 ? ((WindowedGLContext*) context)->getNativeWindowHandle()
return context != 0 ? static_cast<WindowedGLContext*> (static_cast<OpenGLContext*> (context))->getNativeWindowHandle()
: 0;
}

@@ -241969,7 +241956,8 @@ public:
view = [[JuceGLView alloc] initWithFrame: CGRectMake (0, 0, 64, 64)];
view.opaque = YES;
view.hidden = NO;
view.backgroundColor = [UIColor redColor];
view.backgroundColor = [UIColor blackColor];
view.userInteractionEnabled = NO;

glLayer = (CAEAGLLayer*) [view layer];
[peer->view addSubview: view];
@@ -247443,7 +247431,7 @@ OpenGLContext* OpenGLComponent::createContext()

void* OpenGLComponent::getNativeWindowHandle() const
{
return context != 0 ? ((WindowedGLContext*) context)->getNativeWindowHandle()
return context != 0 ? static_cast<WindowedGLContext*> (static_cast<OpenGLContext*> (context))->getNativeWindowHandle()
: 0;
}

@@ -247521,7 +247509,8 @@ public:
view = [[JuceGLView alloc] initWithFrame: CGRectMake (0, 0, 64, 64)];
view.opaque = YES;
view.hidden = NO;
view.backgroundColor = [UIColor redColor];
view.backgroundColor = [UIColor blackColor];
view.userInteractionEnabled = NO;

glLayer = (CAEAGLLayer*) [view layer];
[peer->view addSubview: view];


+ 22
- 23
juce_amalgamated.h View File

@@ -4255,7 +4255,7 @@ public:

int64 getSize() const;

static const String descriptionOfSizeInBytes (const int64 bytes);
static const String descriptionOfSizeInBytes (int64 bytes);

const String& getFullPathName() const throw() { return fullPath; }

@@ -4287,15 +4287,15 @@ public:
const String& suffix,
bool putNumbersInBrackets = true) const;

const File getNonexistentSibling (const bool putNumbersInBrackets = true) const;
const File getNonexistentSibling (bool putNumbersInBrackets = true) const;

bool operator== (const File& otherFile) const;
bool operator!= (const File& otherFile) const;

bool hasWriteAccess() const;

bool setReadOnly (const bool shouldBeReadOnly,
const bool applyRecursively = false) const;
bool setReadOnly (bool shouldBeReadOnly,
bool applyRecursively = false) const;

bool isHidden() const;

@@ -4340,36 +4340,36 @@ public:
};

int findChildFiles (Array<File>& results,
const int whatToLookFor,
const bool searchRecursively,
int whatToLookFor,
bool searchRecursively,
const String& wildCardPattern = JUCE_T("*")) const;

int getNumberOfChildFiles (const int whatToLookFor,
int getNumberOfChildFiles (int whatToLookFor,
const String& wildCardPattern = JUCE_T("*")) const;

bool containsSubDirectories() const;

FileInputStream* createInputStream() const;

FileOutputStream* createOutputStream (const int bufferSize = 0x8000) const;
FileOutputStream* createOutputStream (int bufferSize = 0x8000) const;

bool loadFileAsData (MemoryBlock& result) const;

const String loadFileAsString() const;

bool appendData (const void* const dataToAppend,
const int numberOfBytes) const;
bool appendData (const void* dataToAppend,
int numberOfBytes) const;

bool replaceWithData (const void* const dataToWrite,
const int numberOfBytes) const;
bool replaceWithData (const void* dataToWrite,
int numberOfBytes) const;

bool appendText (const String& textToAppend,
const bool asUnicode = false,
const bool writeUnicodeHeaderBytes = false) const;
bool asUnicode = false,
bool writeUnicodeHeaderBytes = false) const;

bool replaceWithText (const String& textToWrite,
const bool asUnicode = false,
const bool writeUnicodeHeaderBytes = false) const;
bool asUnicode = false,
bool writeUnicodeHeaderBytes = false) const;

static void findFileSystemRoots (Array<File>& results);

@@ -8171,9 +8171,9 @@ class JUCE_API BufferedInputStream : public InputStream
{
public:

BufferedInputStream (InputStream* const sourceStream,
const int bufferSize,
const bool deleteSourceWhenDestroyed);
BufferedInputStream (InputStream* sourceStream,
int bufferSize,
bool deleteSourceWhenDestroyed);

~BufferedInputStream();

@@ -10136,14 +10136,14 @@ public:
{
String s;
s.preallocateStorage (16);
s << x << T(' ') << y << T(' ') << w << T(' ') << h;
s << x << ' ' << y << ' ' << w << ' ' << h;
return s;
}

static const Rectangle fromString (const String& stringVersion)
{
StringArray toks;
toks.addTokens (stringVersion.trim(), T(",; \t\r\n"), String::empty);
toks.addTokens (stringVersion.trim(), JUCE_T(",; \t\r\n"), String::empty);

return Rectangle (toks[0].trim().getIntValue(),
toks[1].trim().getIntValue(),
@@ -26815,8 +26815,7 @@ private:
friend class OpenGLComponentWatcher;
friend class ScopedPointer <OpenGLComponentWatcher>;
ScopedPointer <OpenGLComponentWatcher> componentWatcher;

OpenGLContext* context;
ScopedPointer <OpenGLContext> context;
OpenGLContext* contextToShareListsWith;

CriticalSection contextLock;


+ 2
- 3
src/audio/plugins/formats/juce_AudioUnitPluginFormat.mm View File

@@ -962,8 +962,7 @@ public:
~AudioUnitPluginWindowCarbon()
{
deleteAndZero (innerWrapper);
innerWrapper = 0;
activeWindows.removeValue (this);
if (isValid())
@@ -1080,7 +1079,7 @@ private:
};
friend class InnerWrapperComponent;
InnerWrapperComponent* innerWrapper;
ScopedPointer<InnerWrapperComponent> innerWrapper;
};
#endif


+ 1
- 2
src/gui/components/special/juce_OpenGLComponent.cpp View File

@@ -179,7 +179,6 @@ private:
//==============================================================================
OpenGLComponent::OpenGLComponent (const OpenGLType type_)
: type (type_),
context (0),
contextToShareListsWith (0),
needToUpdateViewport (true)
{
@@ -196,7 +195,7 @@ OpenGLComponent::~OpenGLComponent()
void OpenGLComponent::deleteContext()
{
const ScopedLock sl (contextLock);
deleteAndZero (context);
context = 0;
}
void OpenGLComponent::updateContextPosition()


+ 1
- 2
src/gui/components/special/juce_OpenGLComponent.h View File

@@ -339,8 +339,7 @@ private:
friend class OpenGLComponentWatcher;
friend class ScopedPointer <OpenGLComponentWatcher>;
ScopedPointer <OpenGLComponentWatcher> componentWatcher;
OpenGLContext* context;
ScopedPointer <OpenGLContext> context;
OpenGLContext* contextToShareListsWith;
CriticalSection contextLock;


+ 2
- 2
src/gui/graphics/geometry/juce_Rectangle.h View File

@@ -502,7 +502,7 @@ public:
{
String s;
s.preallocateStorage (16);
s << x << T(' ') << y << T(' ') << w << T(' ') << h;
s << x << ' ' << y << ' ' << w << ' ' << h;
return s;
}
@@ -519,7 +519,7 @@ public:
static const Rectangle fromString (const String& stringVersion)
{
StringArray toks;
toks.addTokens (stringVersion.trim(), T(",; \t\r\n"), String::empty);
toks.addTokens (stringVersion.trim(), JUCE_T(",; \t\r\n"), String::empty);
return Rectangle (toks[0].trim().getIntValue(),
toks[1].trim().getIntValue(),


+ 8
- 11
src/io/files/juce_File.cpp View File

@@ -908,22 +908,19 @@ const File File::withFileExtension (const String& newExtension) const
String filePart (getFileName());
int i = filePart.lastIndexOfChar (T('.'));
if (i < 0)
i = filePart.length();
if (i >= 0)
filePart = filePart.substring (0, i);
String newExt (newExtension);
if (newExtension.isNotEmpty() && ! newExtension.startsWithChar (T('.')))
filePart << '.';
if (newExt.isNotEmpty() && ! newExt.startsWithChar (T('.')))
newExt = T(".") + newExt;
return getSiblingFile (filePart.substring (0, i) + newExt);
return getSiblingFile (filePart + newExtension);
}
//==============================================================================
bool File::startAsProcess (const String& parameters) const
{
return exists()
&& juce_launchFile (fullPath, parameters);
return exists() && juce_launchFile (fullPath, parameters);
}
//==============================================================================
@@ -931,8 +928,8 @@ FileInputStream* File::createInputStream() const
{
if (existsAsFile())
return new FileInputStream (*this);
else
return 0;
return 0;
}
FileOutputStream* File::createOutputStream (const int bufferSize) const


+ 16
- 16
src/io/files/juce_File.h View File

@@ -132,7 +132,7 @@ public:
So for example 100 would return "100 bytes", 2000 would return "2 KB",
2000000 would produce "2 MB", etc.
*/
static const String descriptionOfSizeInBytes (const int64 bytes);
static const String descriptionOfSizeInBytes (int64 bytes);
//==============================================================================
/** Returns the complete, absolute path of this file.
@@ -313,7 +313,7 @@ public:
@param putNumbersInBrackets whether to add brackets around the numbers that
get appended to the new filename.
*/
const File getNonexistentSibling (const bool putNumbersInBrackets = true) const;
const File getNonexistentSibling (bool putNumbersInBrackets = true) const;
//==============================================================================
/** Compares the pathnames for two files. */
@@ -340,8 +340,8 @@ public:
@returns true if it manages to change the file's permissions.
@see hasWriteAccess
*/
bool setReadOnly (const bool shouldBeReadOnly,
const bool applyRecursively = false) const;
bool setReadOnly (bool shouldBeReadOnly,
bool applyRecursively = false) const;
/** Returns true if this file is a hidden or system file.
@@ -530,8 +530,8 @@ public:
@see getNumberOfChildFiles, DirectoryIterator
*/
int findChildFiles (Array<File>& results,
const int whatToLookFor,
const bool searchRecursively,
int whatToLookFor,
bool searchRecursively,
const String& wildCardPattern = JUCE_T("*")) const;
/** Searches inside a directory and counts how many files match a wildcard pattern.
@@ -550,7 +550,7 @@ public:
@returns the number of matches found
@see findChildFiles, DirectoryIterator
*/
int getNumberOfChildFiles (const int whatToLookFor,
int getNumberOfChildFiles (int whatToLookFor,
const String& wildCardPattern = JUCE_T("*")) const;
/** Returns true if this file is a directory that contains one or more subdirectories.
@@ -577,7 +577,7 @@ public:
end of the file), or 0 if the file can't be opened for some reason
@see createInputStream, appendData, appendText
*/
FileOutputStream* createOutputStream (const int bufferSize = 0x8000) const;
FileOutputStream* createOutputStream (int bufferSize = 0x8000) const;
//==============================================================================
/** Loads a file's contents into memory as a block of binary data.
@@ -608,8 +608,8 @@ public:
@returns false if it can't write to the file for some reason
*/
bool appendData (const void* const dataToAppend,
const int numberOfBytes) const;
bool appendData (const void* dataToAppend,
int numberOfBytes) const;
/** Replaces this file's contents with a given block of data.
@@ -625,8 +625,8 @@ public:
@see appendText
*/
bool replaceWithData (const void* const dataToWrite,
const int numberOfBytes) const;
bool replaceWithData (const void* dataToWrite,
int numberOfBytes) const;
/** Appends a string to the end of the file.
@@ -641,8 +641,8 @@ public:
@see replaceWithText
*/
bool appendText (const String& textToAppend,
const bool asUnicode = false,
const bool writeUnicodeHeaderBytes = false) const;
bool asUnicode = false,
bool writeUnicodeHeaderBytes = false) const;
/** Replaces this file's contents with a given text string.
@@ -661,8 +661,8 @@ public:
@see appendText
*/
bool replaceWithText (const String& textToWrite,
const bool asUnicode = false,
const bool writeUnicodeHeaderBytes = false) const;
bool asUnicode = false,
bool writeUnicodeHeaderBytes = false) const;
//==============================================================================
/** Creates a set of files to represent each file root.


+ 3
- 3
src/io/streams/juce_BufferedInputStream.h View File

@@ -49,9 +49,9 @@ public:
@param deleteSourceWhenDestroyed whether the sourceStream that is passed in should be
deleted by this object when it is itself deleted.
*/
BufferedInputStream (InputStream* const sourceStream,
const int bufferSize,
const bool deleteSourceWhenDestroyed);
BufferedInputStream (InputStream* sourceStream,
int bufferSize,
bool deleteSourceWhenDestroyed);
/** Destructor.


+ 3
- 3
src/io/streams/juce_OutputStream.cpp View File

@@ -68,10 +68,10 @@ OutputStream::~OutputStream()
}
//==============================================================================
void OutputStream::writeBool (bool b)
void OutputStream::writeBool (const bool b)
{
writeByte ((b) ? (char) 1
: (char) 0);
writeByte (b ? (char) 1
: (char) 0);
}
void OutputStream::writeByte (char byte)


+ 1
- 9
src/native/linux/juce_linux_Windowing.cpp View File

@@ -714,7 +714,6 @@ public:
wy (0),
ww (0),
wh (0),
taskbarImage (0),
fullScreen (false),
mapped (false),
visual (0),
@@ -735,7 +734,6 @@ public:
// it's dangerous to delete a window on a thread other than the message thread..
jassert (MessageManager::getInstance()->currentThreadHasLockedMessageManager());
deleteTaskBarIcon();
deleteIconPixmaps();
destroyWindow();
@@ -1746,7 +1744,6 @@ public:
void setTaskBarIcon (const Image& image)
{
ScopedXLock xlock;
deleteTaskBarIcon();
taskbarImage = image.createCopy();
Screen* const screen = XDefaultScreenOfDisplay (display);
@@ -1801,11 +1798,6 @@ public:
XFree (hints);
}
void deleteTaskBarIcon()
{
deleteAndZero (taskbarImage);
}
const Image* getTaskbarIcon() const throw() { return taskbarImage; }
//==============================================================================
@@ -1974,7 +1966,7 @@ private:
friend class LinuxRepaintManager;
Window windowH, parentWindow;
int wx, wy, ww, wh;
Image* taskbarImage;
ScopedPointer<Image> taskbarImage;
bool fullScreen, mapped;
Visual* visual;
int depth;


+ 3
- 2
src/native/mac/juce_mac_OpenGLComponent.mm View File

@@ -268,7 +268,7 @@ OpenGLContext* OpenGLComponent::createContext()
void* OpenGLComponent::getNativeWindowHandle() const
{
return context != 0 ? ((WindowedGLContext*) context)->getNativeWindowHandle()
return context != 0 ? static_cast<WindowedGLContext*> (static_cast<OpenGLContext*> (context))->getNativeWindowHandle()
: 0;
}
@@ -348,7 +348,8 @@ public:
view = [[JuceGLView alloc] initWithFrame: CGRectMake (0, 0, 64, 64)];
view.opaque = YES;
view.hidden = NO;
view.backgroundColor = [UIColor redColor];
view.backgroundColor = [UIColor blackColor];
view.userInteractionEnabled = NO;
glLayer = (CAEAGLLayer*) [view layer];
[peer->view addSubview: view];


+ 1
- 1
src/native/windows/juce_win32_OpenGLComponent.cpp View File

@@ -509,7 +509,7 @@ OpenGLContext* OpenGLComponent::createContext()
void* OpenGLComponent::getNativeWindowHandle() const
{
return context != 0 ? ((WindowedGLContext*) context)->getNativeWindowHandle() : 0;
return context != 0 ? static_cast<WindowedGLContext*> (static_cast<OpenGLContext*> (context))->getNativeWindowHandle() : 0;
}
void juce_glViewport (const int w, const int h)


+ 10
- 10
src/native/windows/juce_win32_WASAPI.cpp View File

@@ -1060,24 +1060,24 @@ public:
jassert (hasScanned); // need to call scanForDevices() before doing this
const bool useExclusiveMode = false;
WASAPIAudioIODevice* d = 0;
ScopedPointer<WASAPIAudioIODevice> device;
const int outputIndex = outputDeviceNames.indexOf (outputDeviceName);
const int inputIndex = inputDeviceNames.indexOf (inputDeviceName);
if (outputIndex >= 0 || inputIndex >= 0)
{
d = new WASAPIAudioIODevice (outputDeviceName.isNotEmpty() ? outputDeviceName
: inputDeviceName,
outputDeviceIds [outputIndex],
inputDeviceIds [inputIndex],
useExclusiveMode);
if (! d->initialise())
deleteAndZero (d);
device = new WASAPIAudioIODevice (outputDeviceName.isNotEmpty() ? outputDeviceName
: inputDeviceName,
outputDeviceIds [outputIndex],
inputDeviceIds [inputIndex],
useExclusiveMode);
if (! device->initialise())
device = 0;
}
return d;
return device.release();
}
//==============================================================================


Loading…
Cancel
Save