From 02c0cd009c96389b187a363c85e3aa7dfa48ab03 Mon Sep 17 00:00:00 2001 From: jules Date: Mon, 3 Dec 2012 15:04:08 +0000 Subject: [PATCH] Cleaned up some compiler warnings. --- .../codecs/juce_MP3AudioFormat.cpp | 56 +++++----- .../codecs/juce_QuickTimeAudioFormat.cpp | 8 +- .../juce_AudioUnitPluginFormat.mm | 12 +-- .../format_types/juce_VSTPluginFormat.cpp | 42 ++++---- modules/juce_core/native/juce_win32_Files.cpp | 102 +++++++++--------- .../native/juce_mac_NSViewComponentPeer.mm | 13 ++- .../juce_mac_CarbonViewWrapperComponent.h | 16 +-- .../juce_opengl/opengl/juce_OpenGLContext.cpp | 68 ++++++------ .../opengl/juce_OpenGLGraphicsContext.cpp | 22 ++-- .../juce_opengl/opengl/juce_OpenGLImage.cpp | 4 +- .../native/juce_win32_CameraDevice.cpp | 23 +--- 11 files changed, 179 insertions(+), 187 deletions(-) diff --git a/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp index baf423f3d6..c2f7803e90 100644 --- a/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_MP3AudioFormat.cpp @@ -671,38 +671,38 @@ private: { int i, j; for (i = -256; i < 118 + 4; ++i) - powToGains[i + 256] = pow (2.0, -0.25 * (i + 210)); + powToGains[i + 256] = (float) pow (2.0, -0.25 * (i + 210)); for (i = 0; i < 8207; ++i) - nToThe4Over3[i] = pow ((double) i, 4.0 / 3.0); + nToThe4Over3[i] = (float) pow ((double) i, 4.0 / 3.0); for (i = 0; i < 8; ++i) { static double Ci[] = { -0.6, -0.535, -0.33, -0.185, -0.095, -0.041, -0.0142, -0.0037 }; const double sq = sqrt (1.0 + Ci[i] * Ci[i]); - antiAliasingCs[i] = 1.0 / sq; - antiAliasingCa[i] = Ci[i] / sq; + antiAliasingCs[i] = (float) (1.0 / sq); + antiAliasingCa[i] = (float) (Ci[i] / sq); } for (i = 0; i < 18; ++i) { - win[0][i] = win[1][i] = 0.5 * sin (double_Pi / 72.0 * (2 * i + 1)) / cos (double_Pi * (2 * i + 19) / 72.0); - win[0][i + 18] = win[3][i + 18] = 0.5 * sin (double_Pi / 72.0 * (2 * (i + 18) + 1)) / cos (double_Pi * (2 * (i + 18) + 19) / 72.0); + win[0][i] = win[1][i] = (float) (0.5 * sin (double_Pi / 72.0 * (2 * i + 1)) / cos (double_Pi * (2 * i + 19) / 72.0)); + win[0][i + 18] = win[3][i + 18] = (float) (0.5 * sin (double_Pi / 72.0 * (2 * (i + 18) + 1)) / cos (double_Pi * (2 * (i + 18) + 19) / 72.0)); } const double piOver72 = double_Pi; for (i = 0; i < 6; ++i) { - win[1][i + 18] = 0.5 / cos (piOver72 * (2 * (i + 18) + 19)); - win[3][i + 12] = 0.5 / cos (piOver72 * (2 * (i + 12) + 19)); - win[1][i + 24] = 0.5 * sin (double_Pi / 24.0 * (2 * i + 13)) / cos (piOver72 * (2 * (i + 24) + 19)); + win[1][i + 18] = (float) (0.5 / cos (piOver72 * (2 * (i + 18) + 19))); + win[3][i + 12] = (float) (0.5 / cos (piOver72 * (2 * (i + 12) + 19))); + win[1][i + 24] = (float) (0.5 * sin (double_Pi / 24.0 * (2 * i + 13)) / cos (piOver72 * (2 * (i + 24) + 19))); win[1][i + 30] = win[3][i] = 0; - win[3][i + 6] = 0.5 * sin (double_Pi / 24.0 * (2 * i + 1)) / cos (piOver72 * (2 * (i + 6) + 19)); + win[3][i + 6] = (float) (0.5 * sin (double_Pi / 24.0 * (2 * i + 1)) / cos (piOver72 * (2 * (i + 6) + 19))); } for (i = 0; i < 12; ++i) - win[2][i] = 0.5 * sin (double_Pi / 24.0 * (2 * i + 1)) / cos (double_Pi * (2 * i + 7) / 24.0); + win[2][i] = (float) (0.5 * sin (double_Pi / 24.0 * (2 * i + 1)) / cos (double_Pi * (2 * i + 7) / 24.0)); for (j = 0; j < 4; ++j) { @@ -716,10 +716,10 @@ private: for (i = 0; i < 16; ++i) { const double t = tan (i * double_Pi / 12.0); - tan1_1[i] = t / (1.0 + t); - tan2_1[i] = 1.0 / (1.0 + t); - tan1_2[i] = sqrt2 * t / (1.0 + t); - tan2_2[i] = sqrt2 / (1.0 + t); + tan1_1[i] = (float) (t / (1.0 + t)); + tan2_1[i] = (float) (1.0 / (1.0 + t)); + tan1_2[i] = (float) (sqrt2 * t / (1.0 + t)); + tan2_2[i] = (float) (sqrt2 / (1.0 + t)); for (j = 0; j < 2; ++j) { @@ -735,10 +735,10 @@ private: p2 = pow (base, i * 0.5); } - pow1_1[j][i] = p1; - pow2_1[j][i] = p2; - pow1_2[j][i] = sqrt2 * p1; - pow2_2[j][i] = sqrt2 * p2; + pow1_1[j][i] = (float) p1; + pow2_1[j][i] = (float) p2; + pow1_2[j][i] = (float) (sqrt2 * p1); + pow2_2[j][i] = (float) (sqrt2 * p2); } } @@ -1670,7 +1670,7 @@ private: uint32 getOneBit() noexcept { - const uint8 result = *bufferPointer << bitIndex; + const uint8 result = (uint8) (*bufferPointer << bitIndex); ++bitIndex; bufferPointer += (bitIndex >> 3); bitIndex &= 7; @@ -2450,7 +2450,7 @@ private: { const int shift = 1 + granule.scaleFactorScale; float* xrpnt = (float*) xr; - int i, part2remain = granule.part2_3Length - part2bits; + int part2remain = granule.part2_3Length - part2bits; zeromem (xrpnt, sizeof (float) * (&xr[32][0] - xrpnt)); @@ -2481,7 +2481,7 @@ private: } } - for (i = 0; i < 3; ++i) + for (int i = 0; i < 3; ++i) if (l[i] < 0) l[i] = 0; @@ -2507,7 +2507,7 @@ private: mapEnd = constants.mapEnd [sampleRate][1]; } - for (i = 0; i < 2; ++i) + for (int i = 0; i < 2; ++i) { const BitsToTableMap* h = huffmanTables1 + granule.tableSelect[i]; @@ -2603,7 +2603,7 @@ private: val -= a; } - for (i = 0; i < 4; ++i) + for (int i = 0; i < 4; ++i) { if ((i & 1) == 0) { @@ -2675,11 +2675,11 @@ private: static const int pretab2[] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; const int* pretab = (const int*) (granule.preflag ? pretab1 : pretab2); - int i, max = -1, cb = 0, mc = 0; + int max = -1, cb = 0, mc = 0; int* map = constants.map [sampleRate][2]; float v = 0; - for (i = 0; i < 3; ++i) + for (int i = 0; i < 3; ++i) { const BitsToTableMap* h = huffmanTables1 + granule.tableSelect[i]; @@ -2757,7 +2757,7 @@ private: values -= a; } - for (i = 0; i < 4; ++i) + for (int i = 0; i < 4; ++i) { if ((i & 1) == 0) { @@ -2963,7 +2963,7 @@ public: if (currentPosition != startSampleInFile) { - if (! stream.seek (startSampleInFile / 1152 - 1)) + if (! stream.seek ((int) (startSampleInFile / 1152 - 1))) { currentPosition = -1; createEmptyDecodedData(); diff --git a/modules/juce_audio_formats/codecs/juce_QuickTimeAudioFormat.cpp b/modules/juce_audio_formats/codecs/juce_QuickTimeAudioFormat.cpp index 66584e5871..a22b5f7dfb 100644 --- a/modules/juce_audio_formats/codecs/juce_QuickTimeAudioFormat.cpp +++ b/modules/juce_audio_formats/codecs/juce_QuickTimeAudioFormat.cpp @@ -234,7 +234,7 @@ public: { JUCE_AUTORELEASEPOOL checkThreadIsAttached(); - bool ok = true; + bool readOk = true; while (numSamples > 0) { @@ -253,7 +253,7 @@ public: if (err != noErr) { - ok = false; + readOk = false; break; } } @@ -266,7 +266,7 @@ public: OSStatus err = MovieAudioExtractionFillBuffer (extractor, &actualNumFrames, bufferList, &outFlags); if (err != noErr) { - ok = false; + readOk = false; break; } @@ -302,7 +302,7 @@ public: } detachThread(); - return ok; + return readOk; } bool ok; diff --git a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm index caba2707ab..cac8e7a14d 100644 --- a/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm +++ b/modules/juce_audio_processors/format_types/juce_AudioUnitPluginFormat.mm @@ -220,7 +220,7 @@ namespace AudioUnitFormatHelpers const short resFileId = CFBundleOpenBundleResourceMap (bundleRef); UseResFile (resFileId); - for (int i = 1; i <= Count1Resources ('thng'); ++i) + for (ResourceIndex i = 1; i <= Count1Resources ('thng'); ++i) { if (Handle h = Get1IndResource ('thng', i)) { @@ -276,8 +276,8 @@ class AudioUnitPluginWindowCocoa; class AudioUnitPluginInstance : public AudioPluginInstance { public: - AudioUnitPluginInstance (const String& fileOrIdentifier) - : fileOrIdentifier (fileOrIdentifier), + AudioUnitPluginInstance (const String& fileOrId) + : fileOrIdentifier (fileOrId), wantsMidiMessages (false), producesMidiMessages (false), wasPlaying (false), @@ -1408,9 +1408,9 @@ private: { log ("Opening AU GUI: " + owner.plugin.getName()); - AudioUnitCarbonView viewComponent = owner.getViewComponent(); + AudioUnitCarbonView carbonView = owner.getViewComponent(); - if (viewComponent == 0) + if (carbonView == 0) return 0; Float32Point pos = { 0, 0 }; @@ -1418,7 +1418,7 @@ private: HIViewRef pluginView = 0; - AudioUnitCarbonViewCreate (viewComponent, + AudioUnitCarbonViewCreate (carbonView, owner.getAudioUnit(), windowRef, rootView, diff --git a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp index 284215d7c3..ad9c82ff12 100644 --- a/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp +++ b/modules/juce_audio_processors/format_types/juce_VSTPluginFormat.cpp @@ -686,11 +686,11 @@ public: { if (fragId != 0) { - eff->dispatcher = (AEffectDispatcherProc) newMachOFromCFM ((void*) eff->dispatcher); - eff->process = (AEffectProcessProc) newMachOFromCFM ((void*) eff->process); - eff->setParameter = (AEffectSetParameterProc) newMachOFromCFM ((void*) eff->setParameter); - eff->getParameter = (AEffectGetParameterProc) newMachOFromCFM ((void*) eff->getParameter); - eff->processReplacing = (AEffectProcessProc) newMachOFromCFM ((void*) eff->processReplacing); + eff->dispatcher = (AEffectDispatcherProc) newMachOFromCFM ((void*) eff->dispatcher); + eff->process = (AEffectProcessProc) newMachOFromCFM ((void*) eff->process); + eff->setParameter = (AEffectSetParameterProc) newMachOFromCFM ((void*) eff->setParameter); + eff->getParameter = (AEffectGetParameterProc) newMachOFromCFM ((void*) eff->getParameter); + eff->processReplacing = (AEffectProcessProc) newMachOFromCFM ((void*) eff->processReplacing); } } #endif @@ -1407,9 +1407,9 @@ public: } //============================================================================== - int dispatch (const int opcode, const int index, const int value, void* const ptr, float opt) const + VstIntPtr dispatch (const int opcode, const int index, const int value, void* const ptr, float opt) const { - int result = 0; + VstIntPtr result = 0; if (effect != nullptr) { @@ -1419,7 +1419,7 @@ public: try { #if JUCE_MAC - const int oldResFile = CurResFile(); + const ResFileRefNum oldResFile = CurResFile(); if (module->resFileId != 0) UseResFile (module->resFileId); @@ -1428,7 +1428,7 @@ public: result = effect->dispatcher (effect, opcode, index, value, ptr, opt); #if JUCE_MAC - const int newResFile = CurResFile(); + const ResFileRefNum newResFile = CurResFile(); if (newResFile != oldResFile) // avoid confusing the parent app's resource file with the plug-in's { module->resFileId = newResFile; @@ -1633,7 +1633,7 @@ public: if (usesChunks()) { void* data = nullptr; - const int bytes = dispatch (effGetChunk, isPreset ? 1 : 0, 0, &data, 0.0f); + const VstIntPtr bytes = dispatch (effGetChunk, isPreset ? 1 : 0, 0, &data, 0.0f); if (data != nullptr && bytes <= maxSizeMB * 1024 * 1024) { @@ -1707,14 +1707,14 @@ private: String getCurrentProgramName() { - String name; + String progName; if (effect != nullptr) { { char nm[256] = { 0 }; dispatch (effGetProgramName, 0, 0, nm, 0); - name = String (CharPointer_UTF8 (nm)).trim(); + progName = String (CharPointer_UTF8 (nm)).trim(); } const int index = getCurrentProgram(); @@ -1724,11 +1724,11 @@ private: while (programNames.size() < index) programNames.add (String::empty); - programNames.set (index, name); + programNames.set (index, progName); } } - return name; + return progName; } void setParamsInProgramBlock (fxProgram* const prog) @@ -1819,7 +1819,7 @@ private: String getVersion() const { - unsigned int v = dispatch (effGetVendorVersion, 0, 0, 0, 0); + unsigned int v = (unsigned int) dispatch (effGetVendorVersion, 0, 0, 0, 0); String s; @@ -2327,7 +2327,7 @@ private: } //============================================================================== - int dispatch (const int opcode, const int index, const int value, void* const ptr, float opt) + VstIntPtr dispatch (const int opcode, const int index, const int value, void* const ptr, float opt) { return plugin.dispatch (opcode, index, value, ptr, opt); } @@ -2597,10 +2597,10 @@ private: { const Point pos (getScreenPosition() - peer->getScreenPosition()); ERect r; - r.left = pos.getX(); - r.right = r.left + getWidth(); - r.top = pos.getY(); - r.bottom = r.top + getHeight(); + r.left = (VstInt16) pos.getX(); + r.top = (VstInt16) pos.getY(); + r.right = (VstInt16) (r.left + getWidth()); + r.bottom = (VstInt16) (r.top + getHeight()); owner.dispatch (effEditDraw, 0, 0, &r, 0); } @@ -2698,7 +2698,7 @@ void VSTPluginFormat::findAllTypesForFile (OwnedArray & resul for (;;) { char shellEffectName [64] = { 0 }; - const int uid = instance->dispatch (effShellGetNextPlugin, 0, 0, shellEffectName, 0); + const int uid = (int) instance->dispatch (effShellGetNextPlugin, 0, 0, shellEffectName, 0); if (uid == 0) break; diff --git a/modules/juce_core/native/juce_win32_Files.cpp b/modules/juce_core/native/juce_win32_Files.cpp index 256459684f..2b165504ba 100644 --- a/modules/juce_core/native/juce_win32_Files.cpp +++ b/modules/juce_core/native/juce_win32_Files.cpp @@ -701,7 +701,8 @@ bool Process::openDocument (const String& fileName, const String& parameters) JUCE_TRY { - hInstance = ShellExecute (0, 0, fileName.toWideCharPointer(), parameters.toWideCharPointer(), 0, SW_SHOWDEFAULT); + hInstance = ShellExecute (0, 0, fileName.toWideCharPointer(), + parameters.toWideCharPointer(), 0, SW_SHOWDEFAULT); } JUCE_CATCH_ALL @@ -730,25 +731,25 @@ void File::revealToUser() const class NamedPipe::Pimpl { public: - Pimpl (const String& file, const bool isPipe_) - : pipeH (0), + Pimpl (const String& file, const bool createPipe) + : pipeH (INVALID_HANDLE_VALUE), cancelEvent (CreateEvent (0, FALSE, FALSE, 0)), connected (false), - isPipe (isPipe_) + ownsPipe (createPipe) { - pipeH = isPipe ? CreateNamedPipe (file.toWideCharPointer(), - PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, 0, - PIPE_UNLIMITED_INSTANCES, 4096, 4096, 0, 0) - : CreateFile (file.toWideCharPointer(), - GENERIC_READ | GENERIC_WRITE, 0, 0, - OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); + pipeH = createPipe ? CreateNamedPipe (file.toWideCharPointer(), + PIPE_ACCESS_DUPLEX | FILE_FLAG_OVERLAPPED, 0, + PIPE_UNLIMITED_INSTANCES, 4096, 4096, 0, 0) + : CreateFile (file.toWideCharPointer(), + GENERIC_READ | GENERIC_WRITE, 0, 0, + OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0); } ~Pimpl() { disconnectPipe(); - if (pipeH != 0) + if (pipeH != INVALID_HANDLE_VALUE) CloseHandle (pipeH); CloseHandle (cancelEvent); @@ -756,7 +757,7 @@ public: bool connect (const int timeOutMs) { - if (! isPipe) + if (! ownsPipe) return true; if (! connected) @@ -764,11 +765,7 @@ public: OVERLAPPED over = { 0 }; over.hEvent = CreateEvent (0, TRUE, FALSE, 0); - if (ConnectNamedPipe (pipeH, &over)) - { - connected = false; // yes, you read that right. In overlapped mode it should always return 0. - } - else + if (ConnectNamedPipe (pipeH, &over) == 0) { const DWORD err = GetLastError(); @@ -801,10 +798,8 @@ public: } } - bool isConnected() const noexcept { return connected; } - HANDLE pipeH, cancelEvent; - bool connected, isPipe; + bool connected, ownsPipe; }; NamedPipe::NamedPipe() @@ -818,7 +813,7 @@ NamedPipe::~NamedPipe() bool NamedPipe::isOpen() const { - return pimpl != nullptr && pimpl->connected; + return pimpl != nullptr; } void NamedPipe::cancelPendingReads() @@ -894,13 +889,13 @@ int NamedPipe::read (void* destBuffer, const int maxBytesToRead, const int timeO { bytesRead = (int) numRead; } - else if ((GetLastError() == ERROR_BROKEN_PIPE || GetLastError() == ERROR_PIPE_NOT_CONNECTED) && pimpl->isPipe) + else if ((GetLastError() == ERROR_BROKEN_PIPE || GetLastError() == ERROR_PIPE_NOT_CONNECTED) && pimpl->ownsPipe) { pimpl->disconnectPipe(); waitAgain = true; } } - else if (pimpl->isPipe) + else if (pimpl->ownsPipe) { waitAgain = true; @@ -921,46 +916,53 @@ int NamedPipe::write (const void* sourceBuffer, int numBytesToWrite, int timeOut { int bytesWritten = -1; - if (pimpl != nullptr && pimpl->connect (timeOutMilliseconds)) + if (pimpl != nullptr) { - if (numBytesToWrite <= 0) - return 0; - - OVERLAPPED over = { 0 }; - over.hEvent = CreateEvent (0, TRUE, FALSE, 0); - - unsigned long numWritten; - - if (WriteFile (pimpl->pipeH, sourceBuffer, (DWORD) numBytesToWrite, &numWritten, &over)) + if (! pimpl->connect (timeOutMilliseconds)) { - bytesWritten = (int) numWritten; + pimpl = nullptr; } - else if (GetLastError() == ERROR_IO_PENDING) + else { - HANDLE handles[] = { over.hEvent, pimpl->cancelEvent }; - DWORD waitResult; + if (numBytesToWrite <= 0) + return 0; - waitResult = WaitForMultipleObjects (2, handles, FALSE, - timeOutMilliseconds >= 0 ? timeOutMilliseconds - : INFINITE); + OVERLAPPED over = { 0 }; + over.hEvent = CreateEvent (0, TRUE, FALSE, 0); - if (waitResult != WAIT_OBJECT_0) - { - CancelIo (pimpl->pipeH); - WaitForSingleObject (over.hEvent, INFINITE); - } + unsigned long numWritten; - if (GetOverlappedResult (pimpl->pipeH, &over, &numWritten, FALSE)) + if (WriteFile (pimpl->pipeH, sourceBuffer, (DWORD) numBytesToWrite, &numWritten, &over)) { bytesWritten = (int) numWritten; } - else if (GetLastError() == ERROR_BROKEN_PIPE && pimpl->isPipe) + else if (GetLastError() == ERROR_IO_PENDING) { - pimpl->disconnectPipe(); + HANDLE handles[] = { over.hEvent, pimpl->cancelEvent }; + DWORD waitResult; + + waitResult = WaitForMultipleObjects (2, handles, FALSE, + timeOutMilliseconds >= 0 ? timeOutMilliseconds + : INFINITE); + + if (waitResult != WAIT_OBJECT_0) + { + CancelIo (pimpl->pipeH); + WaitForSingleObject (over.hEvent, INFINITE); + } + + if (GetOverlappedResult (pimpl->pipeH, &over, &numWritten, FALSE)) + { + bytesWritten = (int) numWritten; + } + else if (GetLastError() == ERROR_BROKEN_PIPE && pimpl->ownsPipe) + { + pimpl->disconnectPipe(); + } } - } - CloseHandle (over.hEvent); + CloseHandle (over.hEvent); + } } return bytesWritten; diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 93c8c158c0..d999fdbd3f 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -760,16 +760,19 @@ public: if (! clip.isEmpty()) { Image temp (component.isOpaque() ? Image::RGB : Image::ARGB, - clipW * displayScale, clipH * displayScale, ! component.isOpaque()); + roundToInt (clipW * displayScale), + roundToInt (clipH * displayScale), + ! component.isOpaque()); { - if (displayScale != 1.0f) - clip.scaleAll (roundToInt (displayScale)); + const int intScale = roundToInt (displayScale); + if (intScale != 1) + clip.scaleAll (intScale); ScopedPointer context (component.getLookAndFeel() - .createGraphicsContext (temp, offset * displayScale, clip)); + .createGraphicsContext (temp, offset * intScale, clip)); - if (displayScale != 1.0f) + if (intScale != 1) context->addTransform (AffineTransform::scale (displayScale)); insideDrawRect = true; diff --git a/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h b/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h index 83a4b76bd5..94bc50ef4b 100644 --- a/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h +++ b/modules/juce_gui_extra/native/juce_mac_CarbonViewWrapperComponent.h @@ -75,10 +75,10 @@ public: if (wrapperWindow == 0) { Rect r; - r.left = getScreenX(); - r.top = getScreenY(); - r.right = r.left + getWidth(); - r.bottom = r.top + getHeight(); + r.left = (short) getScreenX(); + r.top = (short) getScreenY(); + r.right = (short) (r.left + getWidth()); + r.bottom = (short) (r.top + getHeight()); CreateNewWindow (kDocumentWindowClass, (WindowAttributes) (kWindowStandardHandlerAttribute | kWindowCompositingAttribute @@ -195,10 +195,10 @@ public: if (wrapperWindow != 0) { Rect wr; - wr.left = getScreenX(); - wr.top = getScreenY(); - wr.right = wr.left + getWidth(); - wr.bottom = wr.top + getHeight(); + wr.left = (short) getScreenX(); + wr.top = (short) getScreenY(); + wr.right = (short) (wr.left + getWidth()); + wr.bottom = (short) (wr.top + getHeight()); SetWindowBounds (wrapperWindow, kWindowContentRgn, &wr); ShowWindow (wrapperWindow); diff --git a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp index bfccf9c148..9427b06d1b 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLContext.cpp @@ -28,7 +28,7 @@ class OpenGLContext::CachedImage : public CachedComponentImage, { public: CachedImage (OpenGLContext& c, Component& comp, - const OpenGLPixelFormat& pixelFormat, void* contextToShareWith) + const OpenGLPixelFormat& pixFormat, void* contextToShare) : Thread ("OpenGL Rendering"), context (c), component (comp), scale (1.0), @@ -39,7 +39,7 @@ public: #endif needsUpdate (true) { - nativeContext = new NativeContext (component, pixelFormat, contextToShareWith); + nativeContext = new NativeContext (component, pixFormat, contextToShare); if (nativeContext->createdOk()) context.nativeContext = nativeContext; @@ -118,7 +118,7 @@ public: return true; } - void clearRegionInFrameBuffer (const RectangleList& list, const float scale) + void clearRegionInFrameBuffer (const RectangleList& list, const float scaleFactor) { glClearColor (0, 0, 0, 0); glEnable (GL_SCISSOR_TEST); @@ -129,7 +129,7 @@ public: for (const Rectangle* i = list.begin(), * const e = list.end(); i != e; ++i) { - const Rectangle r ((i->toFloat() * scale).getSmallestIntegerContainer()); + const Rectangle r ((i->toFloat() * scaleFactor).getSmallestIntegerContainer()); glScissor (r.getX(), imageH - r.getBottom(), r.getWidth(), r.getHeight()); glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); } @@ -248,9 +248,9 @@ public: JUCE_CHECK_OPENGL_ERROR } - void paintOwner (LowLevelGraphicsContext& context) + void paintOwner (LowLevelGraphicsContext& llgc) { - Graphics g (&context); + Graphics g (&llgc); #if JUCE_ENABLE_REPAINT_DEBUGGING g.saveState(); @@ -703,40 +703,40 @@ void OpenGLContext::copyTexture (const Rectangle& targetClipArea, struct ProgramBuilder { - ProgramBuilder (OpenGLShaderProgram& program) + ProgramBuilder (OpenGLShaderProgram& prog) { - program.addShader ("attribute " JUCE_HIGHP " vec2 position;" - "uniform " JUCE_HIGHP " vec2 screenSize;" - "varying " JUCE_HIGHP " vec2 pixelPos;" - "void main()" - "{" - "pixelPos = position;" - JUCE_HIGHP " vec2 scaled = position / (0.5 * screenSize.xy);" - "gl_Position = vec4 (scaled.x - 1.0, 1.0 - scaled.y, 0, 1.0);" - "}", - GL_VERTEX_SHADER); - - program.addShader ("uniform sampler2D imageTexture;" - "uniform " JUCE_HIGHP " float textureBounds[4];" - "varying " JUCE_HIGHP " vec2 pixelPos;" - "void main()" - "{" - JUCE_HIGHP " vec2 texturePos = (pixelPos - vec2 (textureBounds[0], textureBounds[1]))" - "/ vec2 (textureBounds[2], textureBounds[3]);" - "gl_FragColor = texture2D (imageTexture, vec2 (texturePos.x, 1.0 - texturePos.y));" - "}", - GL_FRAGMENT_SHADER); - program.link(); + prog.addShader ("attribute " JUCE_HIGHP " vec2 position;" + "uniform " JUCE_HIGHP " vec2 screenSize;" + "varying " JUCE_HIGHP " vec2 pixelPos;" + "void main()" + "{" + "pixelPos = position;" + JUCE_HIGHP " vec2 scaled = position / (0.5 * screenSize.xy);" + "gl_Position = vec4 (scaled.x - 1.0, 1.0 - scaled.y, 0, 1.0);" + "}", + GL_VERTEX_SHADER); + + prog.addShader ("uniform sampler2D imageTexture;" + "uniform " JUCE_HIGHP " float textureBounds[4];" + "varying " JUCE_HIGHP " vec2 pixelPos;" + "void main()" + "{" + JUCE_HIGHP " vec2 texturePos = (pixelPos - vec2 (textureBounds[0], textureBounds[1]))" + "/ vec2 (textureBounds[2], textureBounds[3]);" + "gl_FragColor = texture2D (imageTexture, vec2 (texturePos.x, 1.0 - texturePos.y));" + "}", + GL_FRAGMENT_SHADER); + prog.link(); } }; struct Params { - Params (OpenGLShaderProgram& program) - : positionAttribute (program, "position"), - screenSize (program, "screenSize"), - imageTexture (program, "imageTexture"), - textureBounds (program, "textureBounds") + Params (OpenGLShaderProgram& prog) + : positionAttribute (prog, "position"), + screenSize (prog, "screenSize"), + imageTexture (prog, "imageTexture"), + textureBounds (prog, "textureBounds") {} void set (const float targetWidth, const float targetHeight, const Rectangle& bounds) const diff --git a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp index 2b1aa866ed..8d93001510 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLGraphicsContext.cpp @@ -464,12 +464,12 @@ public: fullHeightProportion - halfPixelY); } - void setMatrix (const AffineTransform& trans, const OpenGLTextureFromImage& image, + void setMatrix (const AffineTransform& trans, const OpenGLTextureFromImage& im, const float targetX, const float targetY) const { setMatrix (trans, - image.imageWidth, image.imageHeight, - image.fullWidthProportion, image.fullHeightProportion, + im.imageWidth, im.imageHeight, + im.fullWidthProportion, im.fullHeightProportion, targetX, targetY); } @@ -1593,10 +1593,10 @@ private: struct ShaderFillOperation { - ShaderFillOperation (const ClipRegion_Mask& clip, const FillType& fill, const bool clampTiledImages) - : state (clip.state) + ShaderFillOperation (const ClipRegion_Mask& clipMask, const FillType& fill, const bool clampTiledImages) + : state (clipMask.state) { - const GLuint maskTextureID = clip.mask.getTextureID(); + const GLuint maskTextureID = clipMask.mask.getTextureID(); if (fill.isColour()) { @@ -1605,17 +1605,17 @@ private: state.activeTextures.bindTexture (maskTextureID); state.setShader (state.currentShader.programs->solidColourMasked); - state.currentShader.programs->solidColourMasked.maskParams.setBounds (clip.maskArea, state.target, 0); + state.currentShader.programs->solidColourMasked.maskParams.setBounds (clipMask.maskArea, state.target, 0); } else if (fill.isGradient()) { - state.setShaderForGradientFill (*fill.gradient, fill.transform, maskTextureID, &clip.maskArea); + state.setShaderForGradientFill (*fill.gradient, fill.transform, maskTextureID, &clipMask.maskArea); } else { jassert (fill.isTiledImage()); image = new OpenGLTextureFromImage (fill.image); - state.setShaderForTiledImageFill (*image, fill.transform, maskTextureID, &clip.maskArea, clampTiledImages); + state.setShaderForTiledImageFill (*image, fill.transform, maskTextureID, &clipMask.maskArea, clampTiledImages); } } @@ -1770,9 +1770,9 @@ private: struct ShaderFillOperation { - ShaderFillOperation (const ClipRegion_RectangleList& clip, const FillType& fill, + ShaderFillOperation (const ClipRegion_RectangleList& clipList, const FillType& fill, const bool replaceContents, const bool clampTiledImages) - : state (clip.state) + : state (clipList.state) { if (fill.isColour()) { diff --git a/modules/juce_opengl/opengl/juce_OpenGLImage.cpp b/modules/juce_opengl/opengl/juce_OpenGLImage.cpp index 4bb336d63d..c814f9f1e9 100644 --- a/modules/juce_opengl/opengl/juce_OpenGLImage.cpp +++ b/modules/juce_opengl/opengl/juce_OpenGLImage.cpp @@ -142,9 +142,9 @@ private: template struct DataReleaser : public Image::BitmapData::BitmapDataReleaser { - DataReleaser (OpenGLFrameBuffer& frameBuffer, int x, int y, int w, int h) + DataReleaser (OpenGLFrameBuffer& fb, int x, int y, int w, int h) : data (w * h), - writer (frameBuffer, x, y, w, h) + writer (fb, x, y, w, h) {} ~DataReleaser() diff --git a/modules/juce_video/native/juce_win32_CameraDevice.cpp b/modules/juce_video/native/juce_win32_CameraDevice.cpp index 26ac3ae98e..89b1b9f3a0 100644 --- a/modules/juce_video/native/juce_win32_CameraDevice.cpp +++ b/modules/juce_video/native/juce_win32_CameraDevice.cpp @@ -411,12 +411,8 @@ public: const ScopedLock sl (listenerLock); for (int i = listeners.size(); --i >= 0;) - { - CameraDevice::Listener* const l = listeners[i]; - - if (l != nullptr) + if (CameraDevice::Listener* const l = listeners[i]) l->imageReceived (image); - } } //============================================================================== @@ -681,18 +677,9 @@ private: class GrabberCallback : public ComBaseClassHelperBase { public: - GrabberCallback (DShowCameraDeviceInteral& owner_) : owner (owner_) {} - - JUCE_COMRESULT QueryInterface (REFIID refId, void** result) - { - if (refId == IID_ISampleGrabberCB) { AddRef(); *result = dynamic_cast (this); return S_OK; } - if (refId == IID_IUnknown) { AddRef(); *result = dynamic_cast (this); return S_OK; } - - *result = nullptr; - return E_NOINTERFACE; - } + GrabberCallback (DShowCameraDeviceInteral& cam) : owner (cam) {} - STDMETHODIMP SampleCB (double /*SampleTime*/, IMediaSample* /*pSample*/) { return E_FAIL; } + STDMETHODIMP SampleCB (double, IMediaSample*) { return E_FAIL; } STDMETHODIMP BufferCB (double time, BYTE* buffer, long bufferSize) { @@ -716,8 +703,8 @@ private: //============================================================================== -CameraDevice::CameraDevice (const String& name_, int /*index*/) - : name (name_) +CameraDevice::CameraDevice (const String& nm, int /*index*/) + : name (nm) { isRecording = false; }