1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

cleaned up and removed some old functions from SystemStats

This commit is contained in:
jules 2007-07-27 17:05:58 +00:00
parent 477aeecfab
commit b81e6b15ed
20 changed files with 129 additions and 405 deletions

View file

@ -47,14 +47,6 @@ BEGIN_JUCE_NAMESPACE
#include "../../../src/juce_appframework/events/juce_Timer.h" #include "../../../src/juce_appframework/events/juce_Timer.h"
#include "../../../src/juce_core/misc/juce_PlatformUtilities.h" #include "../../../src/juce_core/misc/juce_PlatformUtilities.h"
static struct _LogicalCpuInfo
{
bool htSupported;
bool htAvailable;
int numPackages;
int numLogicalPerPackage;
uint32 physicalAffinityMask;
} logicalCpuInfo;
//============================================================================== //==============================================================================
static juce_noinline unsigned int getCPUIDWord (int* familyModel, int* extFeatures) throw() static juce_noinline unsigned int getCPUIDWord (int* familyModel, int* extFeatures) throw()
@ -82,110 +74,6 @@ static juce_noinline unsigned int getCPUIDWord (int* familyModel, int* extFeatur
return cpu; return cpu;
} }
void juce_initLogicalCpuInfo() throw()
{
int familyModelWord, extFeaturesWord;
int featuresWord = getCPUIDWord (&familyModelWord, &extFeaturesWord);
logicalCpuInfo.htSupported = false;
logicalCpuInfo.htAvailable = false;
logicalCpuInfo.numLogicalPerPackage = 1;
logicalCpuInfo.numPackages = 0;
logicalCpuInfo.physicalAffinityMask = 0;
#if SUPPORT_AFFINITIES
cpu_set_t processAffinity;
/*
N.B. If this line causes a compile error, then you've probably not got the latest
version of glibc installed.
If you don't want to update your copy of glibc and don't care about cpu affinities,
then you can just disable all this stuff by removing the SUPPORT_AFFINITIES macro
from the linuxincludes.h file.
*/
if (sched_getaffinity (getpid(),
sizeof (cpu_set_t),
&processAffinity) != sizeof (cpu_set_t))
{
return;
}
// Checks: CPUID supported, model >= Pentium 4, Hyperthreading bit set, logical CPUs per package > 1
if (featuresWord == 0
|| ((familyModelWord >> 8) & 0xf) < 15
|| (featuresWord & (1 << 28)) == 0
|| ((extFeaturesWord >> 16) & 0xff) < 2)
{
for (int i = 0; i < 64; ++i)
if (CPU_ISSET (i, &processAffinity))
logicalCpuInfo.physicalAffinityMask |= (1 << i);
return;
}
logicalCpuInfo.htSupported = true;
logicalCpuInfo.numLogicalPerPackage = (extFeaturesWord >> 16) & 0xff;
cpu_set_t affinityMask;
cpu_set_t physAff;
CPU_ZERO (&physAff);
unsigned char i = 1;
unsigned char physIdMask = 0xFF;
unsigned char physIdShift = 0;
//unsigned char apicId, logId, physId;
while (i < logicalCpuInfo.numLogicalPerPackage)
{
i *= 2;
physIdMask <<= 1;
physIdShift++;
}
CPU_SET (0, &affinityMask);
logicalCpuInfo.numPackages = 0;
//xxx revisit this at some point..
/* while ((affinityMask != 0) && (affinityMask <= processAffinity))
{
int ret;
if (! sched_setaffinity (getpid(), sizeof (cpu_set_t), &affinityMask))
{
sched_yield(); // schedule onto correct CPU
featuresWord = getCPUIDWord(&familyModelWord, &extFeaturesWord);
apicId = (unsigned char)(extFeaturesWord >> 24);
logId = (unsigned char)(apicId & ~physIdMask);
physId = (unsigned char)(apicId >> physIdShift);
if (logId != 0)
logicalCpuInfo.htAvailable = true;
if ((((int)logId) % logicalCpuInfo.numLogicalPerPackage) == 0)
{
// This is a physical CPU
physAff |= affinityMask;
logicalCpuInfo.numPackages++;
}
}
affinityMask = affinityMask << 1;
}
sched_setaffinity (getpid(), sizeof(unsigned long), &processAffinity);
*/
logicalCpuInfo.physicalAffinityMask = 0;
for (int i = 0; i < 64; ++i)
if (CPU_ISSET (i, &physAff))
logicalCpuInfo.physicalAffinityMask |= (1 << i);
#endif
}
//============================================================================== //==============================================================================
void Logger::outputDebugString (const String& text) throw() void Logger::outputDebugString (const String& text) throw()
{ {
@ -280,11 +168,6 @@ int SystemStats::getCpuSpeedInMegaherz() throw()
return (int) (speed.getFloatValue() + 0.5f); return (int) (speed.getFloatValue() + 0.5f);
} }
bool SystemStats::hasHyperThreading() throw()
{
return logicalCpuInfo.htAvailable;
}
int SystemStats::getMemorySizeInMegabytes() throw() int SystemStats::getMemorySizeInMegabytes() throw()
{ {
struct sysinfo sysi; struct sysinfo sysi;
@ -360,34 +243,13 @@ int SystemStats::getPageSize() throw()
return systemPageSize; return systemPageSize;
} }
int SystemStats::getNumPhysicalCpus() throw() int SystemStats::getNumCpus() throw()
{
if (logicalCpuInfo.numPackages)
return logicalCpuInfo.numPackages;
return getNumLogicalCpus();
}
int SystemStats::getNumLogicalCpus() throw()
{ {
const int lastCpu = getCpuInfo ("processor", true).getIntValue(); const int lastCpu = getCpuInfo ("processor", true).getIntValue();
return lastCpu + 1; return lastCpu + 1;
} }
uint32 SystemStats::getPhysicalAffinityMask() throw()
{
#if SUPPORT_AFFINITIES
return logicalCpuInfo.physicalAffinityMask;
#else
/* affinities aren't supported because either the appropriate header files weren't found,
or the SUPPORT_AFFINITIES macro was turned off in linuxheaders.h
*/
jassertfalse
return 0;
#endif
}
//============================================================================== //==============================================================================
void SystemStats::initialiseStats() throw() void SystemStats::initialiseStats() throw()
@ -396,8 +258,6 @@ void SystemStats::initialiseStats() throw()
Process::lowerPrivilege(); Process::lowerPrivilege();
String s (SystemStats::getJUCEVersion()); String s (SystemStats::getJUCEVersion());
juce_initLogicalCpuInfo();
} }
void PlatformUtilities::fpuReset() void PlatformUtilities::fpuReset()

View file

@ -167,7 +167,7 @@ void Thread::yield() throw()
sched_yield(); sched_yield();
} }
void Thread::sleep (int millisecs) throw() void JUCE_CALLTYPE Thread::sleep (int millisecs) throw()
{ {
struct timespec time; struct timespec time;
time.tv_sec = millisecs / 1000; time.tv_sec = millisecs / 1000;

View file

@ -83,7 +83,6 @@ struct CPUFlags
bool hasSSE : 1; bool hasSSE : 1;
bool hasSSE2 : 1; bool hasSSE2 : 1;
bool has3DNow : 1; bool has3DNow : 1;
bool hasHT : 1;
}; };
static CPUFlags cpuFlags; static CPUFlags cpuFlags;
@ -145,7 +144,6 @@ void SystemStats::initialiseStats() throw()
cpuFlags.hasSSE = ((features & (1 << 25)) != 0); cpuFlags.hasSSE = ((features & (1 << 25)) != 0);
cpuFlags.hasSSE2 = ((features & (1 << 26)) != 0); cpuFlags.hasSSE2 = ((features & (1 << 26)) != 0);
cpuFlags.has3DNow = ((extFeatures & (1 << 31)) != 0); cpuFlags.has3DNow = ((extFeatures & (1 << 31)) != 0);
cpuFlags.hasHT = ((features & (1 << 28)) != 0);
} }
#endif #endif
@ -201,15 +199,6 @@ bool SystemStats::has3DNow() throw()
#endif #endif
} }
bool SystemStats::hasHyperThreading() throw()
{
#if JUCE_INTEL
return cpuFlags.hasHT;
#else
return false;
#endif
}
const String SystemStats::getCpuVendor() throw() const String SystemStats::getCpuVendor() throw()
{ {
#if JUCE_INTEL #if JUCE_INTEL
@ -226,22 +215,11 @@ int SystemStats::getCpuSpeedInMegaherz() throw()
return GetCPUSpeed(); return GetCPUSpeed();
} }
int SystemStats::getNumPhysicalCpus() throw() int SystemStats::getNumCpus() throw()
{ {
return MPProcessors(); return MPProcessors();
} }
int SystemStats::getNumLogicalCpus() throw()
{
return getNumPhysicalCpus();
}
uint32 SystemStats::getPhysicalAffinityMask() throw()
{
jassertfalse
return 0;
}
//============================================================================== //==============================================================================
static int64 juce_getMicroseconds() throw() static int64 juce_getMicroseconds() throw()
{ {

View file

@ -213,7 +213,7 @@ void Thread::setCurrentThreadAffinityMask (const uint32 affinityMask) throw()
jassertfalse jassertfalse
} }
void Thread::sleep (int millisecs) throw() void JUCE_CALLTYPE Thread::sleep (int millisecs) throw()
{ {
struct timespec time; struct timespec time;
time.tv_sec = millisecs / 1000; time.tv_sec = millisecs / 1000;

View file

@ -567,7 +567,7 @@ static const File juce_getSpecialFolderPath (int type) throw()
return File::nonexistent; return File::nonexistent;
} }
const File File::getSpecialLocation (const SpecialLocationType type) const File JUCE_CALLTYPE File::getSpecialLocation (const SpecialLocationType type)
{ {
switch (type) switch (type)
{ {

View file

@ -63,6 +63,11 @@ BEGIN_JUCE_NAMESPACE
#include "../../../src/juce_core/basics/juce_SystemStats.h" #include "../../../src/juce_core/basics/juce_SystemStats.h"
extern void juce_updateMultiMonitorInfo() throw(); extern void juce_updateMultiMonitorInfo() throw();
extern void juce_initialiseThreadEvents() throw();
#if JUCE_ENABLE_WIN98_COMPATIBILITY
extern void juce_initialiseUnicodeFileFunctions() throw();
#endif
//============================================================================== //==============================================================================
@ -83,16 +88,8 @@ void Logger::outputDebugPrintf (const tchar* format, ...) throw()
//============================================================================== //==============================================================================
static int64 hiResTicksPerSecond; static int64 hiResTicksPerSecond;
static double hiResTicksScaleFactor; static double hiResTicksScaleFactor;
static SYSTEM_INFO systemInfo;
static struct _LogicalCpuInfo static SYSTEM_INFO systemInfo;
{
bool htSupported;
bool htAvailable;
int numPackages;
int numLogicalPerPackage;
unsigned long physicalAffinityMask;
} logicalCpuInfo;
//============================================================================== //==============================================================================
@ -103,7 +100,7 @@ static struct _LogicalCpuInfo
#pragma intrinsic (__cpuid) #pragma intrinsic (__cpuid)
#pragma intrinsic (__rdtsc) #pragma intrinsic (__rdtsc)
static unsigned int getCPUIDWord (int* familyModel = 0, int* extFeatures = 0) throw() /*static unsigned int getCPUIDWord (int* familyModel = 0, int* extFeatures = 0) throw()
{ {
int info [4]; int info [4];
__cpuid (info, 1); __cpuid (info, 1);
@ -115,7 +112,7 @@ static unsigned int getCPUIDWord (int* familyModel = 0, int* extFeatures = 0) th
*extFeatures = info[1]; *extFeatures = info[1];
return info[3]; return info[3];
} }*/
const String SystemStats::getCpuVendor() throw() const String SystemStats::getCpuVendor() throw()
{ {
@ -135,7 +132,7 @@ const String SystemStats::getCpuVendor() throw()
//============================================================================== //==============================================================================
// CPU info functions using old fashioned inline asm... // CPU info functions using old fashioned inline asm...
static juce_noinline unsigned int getCPUIDWord (int* familyModel = 0, int* extFeatures = 0) /*static juce_noinline unsigned int getCPUIDWord (int* familyModel = 0, int* extFeatures = 0)
{ {
unsigned int cpu = 0; unsigned int cpu = 0;
unsigned int ext = 0; unsigned int ext = 0;
@ -177,7 +174,7 @@ static juce_noinline unsigned int getCPUIDWord (int* familyModel = 0, int* extFe
*extFeatures = ext; *extFeatures = ext;
return cpu; return cpu;
} }*/
static void juce_getCpuVendor (char* const v) static void juce_getCpuVendor (char* const v)
{ {
@ -223,117 +220,36 @@ const String SystemStats::getCpuVendor() throw()
} }
#endif #endif
static void initLogicalCpuInfo() throw()
{
int familyModelWord, extFeaturesWord;
int featuresWord = getCPUIDWord (&familyModelWord, &extFeaturesWord);
HANDLE hCurrentProcessHandle = GetCurrentProcess();
logicalCpuInfo.htSupported = false;
logicalCpuInfo.htAvailable = false;
logicalCpuInfo.numLogicalPerPackage = 1;
logicalCpuInfo.numPackages = 0;
logicalCpuInfo.physicalAffinityMask = 0;
DWORD_PTR processAffinity, systemAffinity;
if (! GetProcessAffinityMask (hCurrentProcessHandle, &processAffinity, &systemAffinity))
return;
// Checks: CPUID supported, model >= Pentium 4, Hyperthreading bit set, logical CPUs per package > 1
if (featuresWord == 0
|| ((familyModelWord >> 8) & 0xf) < 15
|| (featuresWord & (1 << 28)) == 0
|| ((extFeaturesWord >> 16) & 0xff) < 2)
{
logicalCpuInfo.physicalAffinityMask = static_cast <unsigned long> (processAffinity);
return;
}
logicalCpuInfo.htSupported = true;
logicalCpuInfo.numLogicalPerPackage = (extFeaturesWord >> 16) & 0xff;
unsigned int affinityMask;
unsigned int physAff = 0;
unsigned char i = 1;
unsigned char physIdMask = 0xFF;
unsigned char physIdShift = 0;
unsigned char apicId;
unsigned char logId;
unsigned char physId;
while (i < logicalCpuInfo.numLogicalPerPackage)
{
i *= 2;
physIdMask <<= 1;
physIdShift++;
}
affinityMask = 1;
logicalCpuInfo.numPackages = 0;
while ((affinityMask != 0) && (affinityMask <= processAffinity))
{
if (SetProcessAffinityMask (hCurrentProcessHandle, affinityMask))
{
Sleep(0); // schedule onto correct CPU
featuresWord = getCPUIDWord (&familyModelWord, &extFeaturesWord);
apicId = (unsigned char) (extFeaturesWord >> 24);
logId = (unsigned char) (apicId & ~physIdMask);
physId = (unsigned char) (apicId >> physIdShift);
if (logId != 0)
logicalCpuInfo.htAvailable = true;
if ((((int) logId) % logicalCpuInfo.numLogicalPerPackage) == 0)
{
// This is a physical CPU
physAff |= affinityMask;
logicalCpuInfo.numPackages++;
}
}
affinityMask = affinityMask << 1;
}
logicalCpuInfo.physicalAffinityMask = physAff;
SetProcessAffinityMask(hCurrentProcessHandle, processAffinity);
}
//============================================================================== //==============================================================================
void juce_initialiseThreadEvents() throw(); struct CPUFlags
#if JUCE_ENABLE_WIN98_COMPATIBILITY
void juce_initialiseUnicodeFileFunctions() throw();
#endif
static struct JuceCpuProps
{ {
bool hasMMX : 1, hasSSE : 1, hasSSE2 : 1, has3DNow : 1; bool hasMMX : 1;
} juce_CpuProps; bool hasSSE : 1;
bool hasSSE2 : 1;
bool has3DNow : 1;
};
static CPUFlags cpuFlags;
bool SystemStats::hasMMX() throw() bool SystemStats::hasMMX() throw()
{ {
return juce_CpuProps.hasMMX; return cpuFlags.hasMMX;
} }
bool SystemStats::hasSSE() throw() bool SystemStats::hasSSE() throw()
{ {
return juce_CpuProps.hasSSE; return cpuFlags.hasSSE;
} }
bool SystemStats::hasSSE2() throw() bool SystemStats::hasSSE2() throw()
{ {
return juce_CpuProps.hasSSE2; return cpuFlags.hasSSE2;
} }
bool SystemStats::has3DNow() throw() bool SystemStats::has3DNow() throw()
{ {
return juce_CpuProps.has3DNow; return cpuFlags.has3DNow;
} }
void SystemStats::initialiseStats() throw() void SystemStats::initialiseStats() throw()
@ -344,13 +260,13 @@ void SystemStats::initialiseStats() throw()
juce_initialiseThreadEvents(); juce_initialiseThreadEvents();
juce_CpuProps.hasMMX = IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE) != 0; cpuFlags.hasMMX = IsProcessorFeaturePresent (PF_MMX_INSTRUCTIONS_AVAILABLE) != 0;
juce_CpuProps.hasSSE = IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE) != 0; cpuFlags.hasSSE = IsProcessorFeaturePresent (PF_XMMI_INSTRUCTIONS_AVAILABLE) != 0;
juce_CpuProps.hasSSE2 = IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE) != 0; cpuFlags.hasSSE2 = IsProcessorFeaturePresent (PF_XMMI64_INSTRUCTIONS_AVAILABLE) != 0;
#ifdef PF_AMD3D_INSTRUCTIONS_AVAILABLE #ifdef PF_AMD3D_INSTRUCTIONS_AVAILABLE
juce_CpuProps.has3DNow = IsProcessorFeaturePresent (PF_AMD3D_INSTRUCTIONS_AVAILABLE) != 0; cpuFlags.has3DNow = IsProcessorFeaturePresent (PF_AMD3D_INSTRUCTIONS_AVAILABLE) != 0;
#else #else
juce_CpuProps.has3DNow = IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE) != 0; cpuFlags.has3DNow = IsProcessorFeaturePresent (PF_3DNOW_INSTRUCTIONS_AVAILABLE) != 0;
#endif #endif
LARGE_INTEGER f; LARGE_INTEGER f;
@ -361,7 +277,6 @@ void SystemStats::initialiseStats() throw()
String s (SystemStats::getJUCEVersion()); String s (SystemStats::getJUCEVersion());
GetSystemInfo (&systemInfo); GetSystemInfo (&systemInfo);
initLogicalCpuInfo();
#ifdef JUCE_DEBUG #ifdef JUCE_DEBUG
const MMRESULT res = timeBeginPeriod (1); const MMRESULT res = timeBeginPeriod (1);
@ -445,29 +360,11 @@ int SystemStats::getMemorySizeInMegabytes() throw()
return (int) (mem.dwTotalPhys / (1024 * 1024)) + 1; return (int) (mem.dwTotalPhys / (1024 * 1024)) + 1;
} }
bool SystemStats::hasHyperThreading() throw() int SystemStats::getNumCpus() throw()
{
return logicalCpuInfo.htAvailable;
}
int SystemStats::getNumPhysicalCpus() throw()
{
if (logicalCpuInfo.numPackages)
return logicalCpuInfo.numPackages;
return getNumLogicalCpus();
}
int SystemStats::getNumLogicalCpus() throw()
{ {
return systemInfo.dwNumberOfProcessors; return systemInfo.dwNumberOfProcessors;
} }
uint32 SystemStats::getPhysicalAffinityMask() throw()
{
return logicalCpuInfo.physicalAffinityMask;
}
//============================================================================== //==============================================================================
uint32 juce_millisecondsSinceStartup() throw() uint32 juce_millisecondsSinceStartup() throw()
{ {

View file

@ -225,7 +225,7 @@ void Thread::yield() throw()
Sleep (0); Sleep (0);
} }
void Thread::sleep (const int millisecs) throw() void JUCE_CALLTYPE Thread::sleep (const int millisecs) throw()
{ {
if (millisecs >= 10) if (millisecs >= 10)
{ {

View file

@ -124,13 +124,11 @@ private:
<< T("\nOperating system: ") << SystemStats::getOperatingSystemName() << T("\nOperating system: ") << SystemStats::getOperatingSystemName()
<< T("\nCPU vendor: ") << SystemStats::getCpuVendor() << T("\nCPU vendor: ") << SystemStats::getCpuVendor()
<< T("\nCPU speed: ") << SystemStats::getCpuSpeedInMegaherz() << T("MHz\n") << T("\nCPU speed: ") << SystemStats::getCpuSpeedInMegaherz() << T("MHz\n")
<< T("\nNumber of physical CPUs: ") << SystemStats::getNumPhysicalCpus() << T("\nNumber of CPUs: ") << SystemStats::getNumCpus()
<< T("\nNumber of logical CPUs: ") << SystemStats::getNumLogicalCpus()
<< T("\nCPU has MMX: ") << (SystemStats::hasMMX() ? T("yes") : T("no")) << T("\nCPU has MMX: ") << (SystemStats::hasMMX() ? T("yes") : T("no"))
<< T("\nCPU has SSE: ") << (SystemStats::hasSSE() ? T("yes") : T("no")) << T("\nCPU has SSE: ") << (SystemStats::hasSSE() ? T("yes") : T("no"))
<< T("\nCPU has SSE2: ") << (SystemStats::hasSSE2() ? T("yes") : T("no")) << T("\nCPU has SSE2: ") << (SystemStats::hasSSE2() ? T("yes") : T("no"))
<< T("\nCPU has 3DNOW: ") << (SystemStats::has3DNow() ? T("yes") : T("no")) << T("\nCPU has 3DNOW: ") << (SystemStats::has3DNow() ? T("yes") : T("no"))
<< T("\nCPU has hyperthreading: ") << (SystemStats::hasHyperThreading() ? T("yes") : T("no"))
<< T("\nMemory size: ") << SystemStats::getMemorySizeInMegabytes() << T("MB\n"); << T("\nMemory size: ") << SystemStats::getMemorySizeInMegabytes() << T("MB\n");
int64 macAddresses[8]; int64 macAddresses[8];

View file

@ -1169,7 +1169,7 @@ private:
public: public:
TabMoveProperty (TabbedComponent* comp, JucerDocument& document_, TabMoveProperty (TabbedComponent* comp, JucerDocument& document_,
const int tabIndex_, const int totalNumTabs_) const int tabIndex_, const int totalNumTabs_)
: ButtonPropertyComponent (T("add tab"), false), : ButtonPropertyComponent (T("move tab"), false),
component (comp), component (comp),
document (document_), document (document_),
tabIndex (tabIndex_), tabIndex (tabIndex_),

View file

@ -429,30 +429,25 @@ void* Component::getWindowHandle() const throw()
} }
//============================================================================== //==============================================================================
void Component::addToDesktop (int desktopWindowStyleFlags, void* nativeWindowToAttachTo) void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo)
{ {
// if component methods are being called from threads other than the message // if component methods are being called from threads other than the message
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
checkMessageManagerIsLocked checkMessageManagerIsLocked
if (! isOpaque()) if (! isOpaque())
desktopWindowStyleFlags |= juce_windowIsSemiTransparentFlag; styleWanted |= juce_windowIsSemiTransparentFlag;
int currentStyleFlags = 0; int currentStyleFlags = 0;
ComponentBoundsConstrainer* currentConstainer = 0;
if (isOnDesktop()) // don't use getPeer(), so that we only get the peer that's specifically
{ // for this comp, and not for one of its parents.
const ComponentPeer* const peer = getPeer(); ComponentPeer* peer = ComponentPeer::getPeerFor (this);
if (peer != 0) if (peer != 0)
{ currentStyleFlags = peer->getStyleFlags();
currentStyleFlags = peer->getStyleFlags();
currentConstainer = peer->getConstrainer();
}
}
if ((! isOnDesktop()) || desktopWindowStyleFlags != currentStyleFlags) if (styleWanted != currentStyleFlags || ! flags.hasHeavyweightPeerFlag)
{ {
const ComponentDeletionWatcher deletionChecker (this); const ComponentDeletionWatcher deletionChecker (this);
@ -467,14 +462,16 @@ void Component::addToDesktop (int desktopWindowStyleFlags, void* nativeWindowToA
int x = 0, y = 0; int x = 0, y = 0;
relativePositionToGlobal (x, y); relativePositionToGlobal (x, y);
ComponentPeer* peer = getPeer();
bool wasFullscreen = false; bool wasFullscreen = false;
bool wasMinimised = false; bool wasMinimised = false;
ComponentBoundsConstrainer* currentConstainer = 0;
if (peer != 0) if (peer != 0)
{ {
wasFullscreen = peer->isFullScreen(); wasFullscreen = peer->isFullScreen();
wasMinimised = peer->isMinimised(); wasMinimised = peer->isMinimised();
currentConstainer = peer->getConstrainer();
removeFromDesktop(); removeFromDesktop();
} }
@ -485,7 +482,7 @@ void Component::addToDesktop (int desktopWindowStyleFlags, void* nativeWindowToA
{ {
flags.hasHeavyweightPeerFlag = true; flags.hasHeavyweightPeerFlag = true;
peer = createNewPeer (desktopWindowStyleFlags, nativeWindowToAttachTo); peer = createNewPeer (styleWanted, nativeWindowToAttachTo);
Desktop::getInstance().addDesktopComponent (this); Desktop::getInstance().addDesktopComponent (this);
@ -518,7 +515,7 @@ void Component::removeFromDesktop()
// thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe. // thread, you'll need to use a MessageManagerLock object to make sure it's thread-safe.
checkMessageManagerIsLocked checkMessageManagerIsLocked
if (isOnDesktop()) if (flags.hasHeavyweightPeerFlag)
{ {
ComponentPeer* const peer = ComponentPeer::getPeerFor (this); ComponentPeer* const peer = ComponentPeer::getPeerFor (this);
@ -559,9 +556,9 @@ void Component::setOpaque (const bool shouldBeOpaque) throw()
{ {
flags.opaqueFlag = shouldBeOpaque; flags.opaqueFlag = shouldBeOpaque;
if (isOnDesktop()) if (flags.hasHeavyweightPeerFlag)
{ {
const ComponentPeer* const peer = getPeer(); const ComponentPeer* const peer = ComponentPeer::getPeerFor (this);
if (peer != 0) if (peer != 0)
{ {
@ -880,7 +877,7 @@ void Component::setBounds (int x, int y, int w, int h)
// send a fake mouse move to trigger enter/exit messages if needed.. // send a fake mouse move to trigger enter/exit messages if needed..
sendFakeMouseMove(); sendFakeMouseMove();
if (! isOnDesktop()) if (! flags.hasHeavyweightPeerFlag)
repaintParent(); repaintParent();
} }
@ -888,7 +885,7 @@ void Component::setBounds (int x, int y, int w, int h)
if (wasResized) if (wasResized)
repaint(); repaint();
else if (! isOnDesktop()) else if (! flags.hasHeavyweightPeerFlag)
repaintParent(); repaintParent();
if (flags.hasHeavyweightPeerFlag) if (flags.hasHeavyweightPeerFlag)
@ -1859,9 +1856,17 @@ void Component::sendLookAndFeelChange()
} }
} }
static const String getColourPropertyName (const int colourId) throw()
{
String s;
s.preallocateStorage (18);
s << T("jcclr_") << colourId;
return s;
}
const Colour Component::findColour (const int colourId, const bool inheritFromParent) const throw() const Colour Component::findColour (const int colourId, const bool inheritFromParent) const throw()
{ {
const String customColour (getComponentProperty (T("jucecol_") + String::toHexString (colourId), const String customColour (getComponentProperty (getColourPropertyName (colourId),
inheritFromParent, inheritFromParent,
String::empty)); String::empty));
@ -1873,7 +1878,7 @@ const Colour Component::findColour (const int colourId, const bool inheritFromPa
bool Component::isColourSpecified (const int colourId) const throw() bool Component::isColourSpecified (const int colourId) const throw()
{ {
return getComponentProperty (T("jucecol_") + String::toHexString (colourId), return getComponentProperty (getColourPropertyName (colourId),
false, false,
String::empty).isNotEmpty(); String::empty).isNotEmpty();
} }
@ -1882,14 +1887,14 @@ void Component::removeColour (const int colourId)
{ {
if (isColourSpecified (colourId)) if (isColourSpecified (colourId))
{ {
removeComponentProperty (T("jucecol_") + String::toHexString (colourId)); removeComponentProperty (getColourPropertyName (colourId));
colourChanged(); colourChanged();
} }
} }
void Component::setColour (const int colourId, const Colour& colour) void Component::setColour (const int colourId, const Colour& colour)
{ {
const String colourName (T("jucecol_") + String::toHexString (colourId)); const String colourName (getColourPropertyName (colourId));
const String customColour (getComponentProperty (colourName, false, String::empty)); const String customColour (getComponentProperty (colourName, false, String::empty));
if (customColour.isEmpty() || Colour (customColour.getIntValue()) != colour) if (customColour.isEmpty() || Colour (customColour.getIntValue()) != colour)
@ -1908,7 +1913,7 @@ void Component::copyAllExplicitColoursTo (Component& target) const throw()
for (int i = 0; i < keys.size(); ++i) for (int i = 0; i < keys.size(); ++i)
{ {
if (keys[i].startsWith (T("jucecol_"))) if (keys[i].startsWith (T("jcclr_")))
{ {
target.setComponentProperty (keys[i], target.setComponentProperty (keys[i],
props.getAllValues() [i]); props.getAllValues() [i]);

View file

@ -156,12 +156,12 @@ DropShadower::~DropShadower()
void DropShadower::deleteShadowWindows() void DropShadower::deleteShadowWindows()
{ {
int i;
for (i = numShadows; --i >= 0;)
delete shadowWindows[i];
if (numShadows > 0) if (numShadows > 0)
{ {
int i;
for (i = numShadows; --i >= 0;)
delete shadowWindows[i];
for (i = 12; --i >= 0;) for (i = 12; --i >= 0;)
delete shadowImageSections[i]; delete shadowImageSections[i];
@ -305,22 +305,22 @@ void DropShadower::updateShadows()
} }
const int x = owner->getX(); const int x = owner->getX();
const int y = owner->getY(); const int y = owner->getY() - shadowEdge;
const int w = owner->getWidth(); const int w = owner->getWidth();
const int h = owner->getHeight(); const int h = owner->getHeight() + shadowEdge + shadowEdge;
shadowWindows[0]->setBounds (x - shadowEdge, shadowWindows[0]->setBounds (x - shadowEdge,
y - shadowEdge, y,
shadowEdge, shadowEdge,
h + shadowEdge + shadowEdge); h);
shadowWindows[1]->setBounds (x + w, shadowWindows[1]->setBounds (x + w,
y - shadowEdge, y,
shadowEdge, shadowEdge,
h + shadowEdge + shadowEdge); h);
shadowWindows[2]->setBounds (x, shadowWindows[2]->setBounds (x,
y - shadowEdge, y,
w, w,
shadowEdge); shadowEdge);
@ -341,7 +341,7 @@ void DropShadower::setShadowImage (Image* const src,
const int w, const int w,
const int h, const int h,
const int sx, const int sx,
const int sy) const int sy) throw()
{ {
shadowImageSections[num] = new Image (Image::ARGB, w, h, true); shadowImageSections[num] = new Image (Image::ARGB, w, h, true);

View file

@ -101,7 +101,7 @@ private:
void setShadowImage (Image* const src, void setShadowImage (Image* const src,
const int num, const int num,
const int w, const int h, const int w, const int h,
const int sx, const int sy); const int sx, const int sy) throw();
void bringShadowWindowsToFront(); void bringShadowWindowsToFront();
void deleteShadowWindows(); void deleteShadowWindows();

View file

@ -57,9 +57,11 @@ ResizableWindow::ResizableWindow (const String& name,
{ {
setBackgroundColour (backgroundColour_); setBackgroundColour (backgroundColour_);
const Rectangle mainMonArea (Desktop::getInstance().getMainMonitorArea());
defaultConstrainer.setSizeLimits (200, 200, defaultConstrainer.setSizeLimits (200, 200,
Desktop::getInstance().getMainMonitorArea().getWidth(), mainMonArea.getWidth(),
Desktop::getInstance().getMainMonitorArea().getHeight()); mainMonArea.getHeight());
defaultConstrainer.setMinimumOnscreenAmounts (0x10000, 16, 24, 16); defaultConstrainer.setMinimumOnscreenAmounts (0x10000, 16, 24, 16);
@ -101,13 +103,10 @@ void ResizableWindow::setContentComponent (Component* const newContentComponent,
if (contentComponent != newContentComponent) if (contentComponent != newContentComponent)
{ {
if (contentComponent != 0) if (deleteOldOne)
{ delete contentComponent;
if (deleteOldOne) else
delete contentComponent; removeChildComponent (contentComponent);
else
removeChildComponent (contentComponent);
}
contentComponent = newContentComponent; contentComponent = newContentComponent;
@ -269,18 +268,22 @@ void ResizableWindow::setResizeLimits (const int newMinimumWidth,
void ResizableWindow::setConstrainer (ComponentBoundsConstrainer* newConstrainer) void ResizableWindow::setConstrainer (ComponentBoundsConstrainer* newConstrainer)
{ {
constrainer = newConstrainer; if (constrainer != newConstrainer)
{
constrainer = newConstrainer;
const bool shouldBeResizable = resizableCorner != 0 || resizableBorder != 0; const bool useBottomRightCornerResizer = resizableCorner != 0;
const bool useBottomRightCornerResizer = resizableCorner != 0; const bool shouldBeResizable = useBottomRightCornerResizer || resizableBorder != 0;
deleteAndZero (resizableCorner); deleteAndZero (resizableCorner);
deleteAndZero (resizableBorder); deleteAndZero (resizableBorder);
setResizable (shouldBeResizable, useBottomRightCornerResizer); setResizable (shouldBeResizable, useBottomRightCornerResizer);
if (getPeer() != 0) ComponentPeer* const peer = getPeer();
getPeer()->setConstrainer (newConstrainer); if (peer != 0)
peer->setConstrainer (newConstrainer);
}
} }
void ResizableWindow::setBoundsConstrained (int x, int y, int w, int h) void ResizableWindow::setBoundsConstrained (int x, int y, int w, int h)
@ -326,8 +329,9 @@ void ResizableWindow::lookAndFeelChanged()
{ {
Component::addToDesktop (getDesktopWindowStyleFlags()); Component::addToDesktop (getDesktopWindowStyleFlags());
if (getPeer() != 0) ComponentPeer* const peer = getPeer();
getPeer()->setConstrainer (constrainer); if (peer != 0)
peer->setConstrainer (constrainer);
} }
} }
@ -394,21 +398,21 @@ void ResizableWindow::setFullScreen (const bool shouldBeFullScreen)
bool ResizableWindow::isMinimised() const bool ResizableWindow::isMinimised() const
{ {
ComponentPeer* const nw = getPeer(); ComponentPeer* const peer = getPeer();
return (nw != 0) && nw->isMinimised(); return (peer != 0) && peer->isMinimised();
} }
void ResizableWindow::setMinimised (const bool shouldMinimise) void ResizableWindow::setMinimised (const bool shouldMinimise)
{ {
if (shouldMinimise != isMinimised()) if (shouldMinimise != isMinimised())
{ {
ComponentPeer* const nw = getPeer(); ComponentPeer* const peer = getPeer();
if (nw != 0) if (peer != 0)
{ {
updateLastPos(); updateLastPos();
nw->setMinimised (shouldMinimise); peer->setMinimised (shouldMinimise);
} }
else else
{ {
@ -441,7 +445,7 @@ const String ResizableWindow::getWindowStateAsString()
String s; String s;
if (isFullScreen()) if (isFullScreen())
s << T("fs "); s << "fs ";
s << lastNonFullScreenPos.getX() << T(' ') s << lastNonFullScreenPos.getX() << T(' ')
<< lastNonFullScreenPos.getY() << T(' ') << lastNonFullScreenPos.getY() << T(' ')
@ -464,10 +468,10 @@ bool ResizableWindow::restoreWindowStateFromString (const String& s)
if (tokens.size() != 4 + n) if (tokens.size() != 4 + n)
return false; return false;
Rectangle r (tokens[n].getIntValue(), const Rectangle r (tokens[n].getIntValue(),
tokens[n + 1].getIntValue(), tokens[n + 1].getIntValue(),
tokens[n + 2].getIntValue(), tokens[n + 2].getIntValue(),
tokens[n + 3].getIntValue()); tokens[n + 3].getIntValue());
if (r.isEmpty()) if (r.isEmpty())
return false; return false;

View file

@ -51,10 +51,10 @@ static const Graphics::ResamplingQuality defaultQuality = Graphics::mediumResamp
&& (int) x <= MAXIMUM_COORD \ && (int) x <= MAXIMUM_COORD \
&& (int) y >= MINIMUM_COORD \ && (int) y >= MINIMUM_COORD \
&& (int) y <= MAXIMUM_COORD \ && (int) y <= MAXIMUM_COORD \
&& (int) w >= 0 \ && (int) w >= MINIMUM_COORD \
&& (int) w < MAXIMUM_COORD \ && (int) w <= MAXIMUM_COORD \
&& (int) h >= 0 \ && (int) h >= MINIMUM_COORD \
&& (int) h < MAXIMUM_COORD); && (int) h <= MAXIMUM_COORD);
//============================================================================== //==============================================================================

View file

@ -115,31 +115,9 @@ public:
/** Checks whether AMD 3DNOW instructions are available. */ /** Checks whether AMD 3DNOW instructions are available. */
static bool has3DNow() throw(); static bool has3DNow() throw();
/** True if the chip has hyperthreading. /** Returns the number of CPUs.
Probably only uber-geeks will care less about this.
*/ */
static bool hasHyperThreading() throw(); static int getNumCpus() throw();
/** Checks whether there are multiple processors in the box.
@see getNumLogicalCpus
*/
static int getNumPhysicalCpus() throw();
/** Counts the number of logical processors.
May give a different result to getNumPhysicalCpus()...
*/
static int getNumLogicalCpus() throw();
/** Returns a bitmask for the physical processors.
This mask shows which of the logical processors are actually physical.
@see Thread::setAffinityMask
*/
static uint32 getPhysicalAffinityMask() throw();
/** Returns a clock-cycle tick counter, if available. /** Returns a clock-cycle tick counter, if available.

View file

@ -241,7 +241,7 @@ int64 Time::secondsToHighResolutionTicks (const double seconds) throw()
//============================================================================== //==============================================================================
const Time Time::getCurrentTime() throw() const Time JUCE_CALLTYPE Time::getCurrentTime() throw()
{ {
return Time (currentTimeMillis()); return Time (currentTimeMillis());
} }

View file

@ -103,7 +103,7 @@ public:
@see currentTimeMillis @see currentTimeMillis
*/ */
static const Time getCurrentTime() throw(); static const Time JUCE_CALLTYPE getCurrentTime() throw();
/** Returns the time as a number of milliseconds. /** Returns the time as a number of milliseconds.

View file

@ -767,7 +767,7 @@ public:
@see SpecialLocationType @see SpecialLocationType
*/ */
static const File getSpecialLocation (const SpecialLocationType type); static const File JUCE_CALLTYPE getSpecialLocation (const SpecialLocationType type);
//============================================================================== //==============================================================================
/** Returns a temporary file in the system's temp directory. /** Returns a temporary file in the system's temp directory.

View file

@ -769,13 +769,17 @@ const String String::operator+ (const tchar characterToAppend) const throw()
const String JUCE_PUBLIC_FUNCTION operator+ (const char* const string1, const String JUCE_PUBLIC_FUNCTION operator+ (const char* const string1,
const String& string2) throw() const String& string2) throw()
{ {
return String (string1) + string2; String s (string1);
s += string2;
return s;
} }
const String JUCE_PUBLIC_FUNCTION operator+ (const juce_wchar* const string1, const String JUCE_PUBLIC_FUNCTION operator+ (const juce_wchar* const string1,
const String& string2) throw() const String& string2) throw()
{ {
return String (string1) + string2; String s (string1);
s += string2;
return s;
} }
//============================================================================== //==============================================================================

View file

@ -192,10 +192,10 @@ public:
//============================================================================== //==============================================================================
// this can be called from any thread that needs to pause.. // this can be called from any thread that needs to pause..
static void sleep (int milliseconds) throw(); static void JUCE_CALLTYPE sleep (int milliseconds) throw();
/** Yields the calling thread's current time-slot. */ /** Yields the calling thread's current time-slot. */
static void yield() throw(); static void JUCE_CALLTYPE yield() throw();
//============================================================================== //==============================================================================
/** Makes the thread wait for a notification. /** Makes the thread wait for a notification.