diff --git a/src/apps/processcontroller/Jamfile b/src/apps/processcontroller/Jamfile index c1c7ab2dcf..a68ac32b68 100644 --- a/src/apps/processcontroller/Jamfile +++ b/src/apps/processcontroller/Jamfile @@ -1,6 +1,6 @@ SubDir HAIKU_TOP src apps processcontroller ; -SetSubDirSupportedPlatformsBeOSCompatible ; +UsePrivateSystemHeaders ; Application ProcessController : AutoIcon.cpp diff --git a/src/apps/processcontroller/PCWorld.h b/src/apps/processcontroller/PCWorld.h index dab9dcb4a9..e46d171da6 100644 --- a/src/apps/processcontroller/PCWorld.h +++ b/src/apps/processcontroller/PCWorld.h @@ -1,20 +1,20 @@ /* ProcessController © 2000, Georges-Edouard Berenger, All Rights Reserved. - Copyright (C) 2004 beunited.org + Copyright (C) 2004 beunited.org - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #ifndef _PCWORLD_H_ #define _PCWORLD_H_ @@ -42,7 +42,5 @@ extern const char* kPCSemaphoreName; extern thread_id id; -extern "C" int _kget_cpu_state_(int cpu); -extern "C" int _kset_cpu_state_(int cpu, int enabled); #endif // _PCWORLD_H_ diff --git a/src/apps/processcontroller/ProcessController.cpp b/src/apps/processcontroller/ProcessController.cpp index 622f824f48..7cf4d8e59c 100644 --- a/src/apps/processcontroller/ProcessController.cpp +++ b/src/apps/processcontroller/ProcessController.cpp @@ -21,18 +21,9 @@ #include "ProcessController.h" -#include "AutoIcon.h" -#include "Colors.h" -#include "IconMenuItem.h" -#include "MemoryBarMenu.h" -#include "MemoryBarMenuItem.h" -#include "PCWorld.h" -#include "Preferences.h" -#include "QuitMenu.h" -#include "TeamBarMenu.h" -#include "TeamBarMenuItem.h" -#include "ThreadBarMenu.h" -#include "Utilities.h" +#include +#include +#include #include #include @@ -49,9 +40,21 @@ #include #include -#include -#include -#include +#include + +#include "AutoIcon.h" +#include "Colors.h" +#include "IconMenuItem.h" +#include "MemoryBarMenu.h" +#include "MemoryBarMenuItem.h" +#include "PCWorld.h" +#include "Preferences.h" +#include "QuitMenu.h" +#include "TeamBarMenu.h" +#include "TeamBarMenuItem.h" +#include "ThreadBarMenu.h" +#include "Utilities.h" + const char* kDeskbarItemName = "ProcessController"; const char* kClassName = "ProcessController"; @@ -340,7 +343,7 @@ ProcessController::MessageReceived(BMessage *message) if (message->FindInt32 ("cpu", &cpu) == B_OK) { bool last = true; for (int p = 0; p < gCPUcount; p++) { - if (p != cpu && _kget_cpu_state_(p)) { + if (p != cpu && _kern_cpu_enabled(p)) { last = false; break; } @@ -350,7 +353,7 @@ ProcessController::MessageReceived(BMessage *message) "That's no Fun!", NULL, NULL, B_WIDTH_AS_USUAL, B_WARNING_ALERT); alert->Go(); } else - _kset_cpu_state_(cpu, !_kget_cpu_state_(cpu)); + _kern_set_cpu_enabled(cpu, !_kern_cpu_enabled(cpu)); } break; } @@ -674,7 +677,7 @@ thread_popup(void *arg) BMessage* m = new BMessage ('CPU '); m->AddInt32 ("cpu", i); item = new IconMenuItem (gPCView->fProcessorIcon, item_name, m); - if (_kget_cpu_state_(i)) + if (_kern_cpu_enabled(i)) item->SetMarked (true); item->SetTarget(gPCView); addtopbottom(item); diff --git a/src/apps/pulse/CPUButton.cpp b/src/apps/pulse/CPUButton.cpp index 28bbab9123..574200a0f8 100644 --- a/src/apps/pulse/CPUButton.cpp +++ b/src/apps/pulse/CPUButton.cpp @@ -10,11 +10,16 @@ #include "CPUButton.h" + +#include + +#include + +#include + #include "PulseApp.h" #include "PulseView.h" #include "Common.h" -#include -#include CPUButton::CPUButton(BRect rect, const char *name, const char *label, BMessage *message) @@ -173,13 +178,13 @@ status_t CPUButton::Invoke(BMessage *message) { if (!LastEnabledCPU(fCPU)) { - _kset_cpu_state_(fCPU, Value()); + _kern_set_cpu_enabled(fCPU, Value()); } else { BAlert *alert = new BAlert(NULL, "You can't disable the last active CPU.", "OK"); alert->Go(NULL); SetValue(!Value()); } - + return B_OK; } @@ -216,7 +221,7 @@ CPUButton::MessageReceived(BMessage *message) } case PV_REPLICANT_PULSE: { // Make sure we're consistent with our CPU - if (_kget_cpu_state_(fCPU) != Value() && !IsTracking()) + if (_kern_cpu_enabled(fCPU) != Value() && !IsTracking()) SetValue(!Value()); break; } diff --git a/src/apps/pulse/Jamfile b/src/apps/pulse/Jamfile index 64e29bf5d7..60e1f36421 100644 --- a/src/apps/pulse/Jamfile +++ b/src/apps/pulse/Jamfile @@ -1,7 +1,6 @@ SubDir HAIKU_TOP src apps pulse ; -SetSubDirSupportedPlatformsBeOSCompatible ; - +UsePrivateSystemHeaders ; UsePrivateHeaders shared ; if ! $(TARGET_PLATFORM_HAIKU_COMPATIBLE) { UseHeaders [ FDirName $(HAIKU_TOP) headers os kernel ] : true ; @@ -22,8 +21,8 @@ Application Pulse : ProgressBar.cpp PulseApp.cpp PulseView.cpp - PulseWindow.cpp + PulseWindow.cpp - : be - : Pulse.rdef + : be + : Pulse.rdef ; diff --git a/src/apps/pulse/PulseApp.cpp b/src/apps/pulse/PulseApp.cpp index faa84ea7d2..29b9dbc5a3 100644 --- a/src/apps/pulse/PulseApp.cpp +++ b/src/apps/pulse/PulseApp.cpp @@ -12,19 +12,22 @@ #include "PulseApp.h" -#include "Common.h" -#include "PulseWindow.h" -#include "DeskbarPulseView.h" - -#include -#include -#include #include #include #include #include +#include +#include +#include + +#include + +#include "Common.h" +#include "PulseWindow.h" +#include "DeskbarPulseView.h" + PulseApp::PulseApp(int argc, char **argv) : BApplication(APP_SIGNATURE) @@ -60,7 +63,7 @@ PulseApp::PulseApp(int argc, char **argv) uint32 rgb = strtoul(optarg, NULL, 0); rgb = rgb << 8; rgb |= 0x000000ff; - + switch (option_index) { case 2: framecolor = rgb; @@ -90,7 +93,7 @@ PulseApp::PulseApp(int argc, char **argv) break; } } - + if (deskbar) { prefs->window_mode = DESKBAR_MODE; if (activecolor != 0) @@ -171,7 +174,7 @@ LastEnabledCPU(int my_cpu) for (int x = 0; x < sys_info.cpu_count; x++) { if (x == my_cpu) continue; - if (_kget_cpu_state_(x) == 1) + if (_kern_cpu_enabled(x) == 1) return false; } return true; @@ -211,7 +214,7 @@ LoadInDeskbar() delete deskbar; return false; } - + // Must be 16 pixels high, the width is retrieved from the Prefs class int width = pulseapp->prefs->deskbar_icon_width; int min_width = GetMinimumViewWidth(); @@ -219,7 +222,7 @@ LoadInDeskbar() pulseapp->prefs->deskbar_icon_width = min_width; width = min_width; } - + BRect rect(0, 0, width - 1, 15); DeskbarPulseView *replicant = new DeskbarPulseView(rect); status_t err = deskbar->AddItem(replicant); diff --git a/src/apps/pulse/PulseView.cpp b/src/apps/pulse/PulseView.cpp index 689acd4c92..d62b2aa5e9 100644 --- a/src/apps/pulse/PulseView.cpp +++ b/src/apps/pulse/PulseView.cpp @@ -9,13 +9,19 @@ //**************************************************************************************** #include "PulseView.h" -#include "Common.h" -#include "PulseApp.h" -#include + #include #include #include +#include + +#include + +#include "Common.h" +#include "PulseApp.h" + + PulseView::PulseView(BRect rect, const char *name) : BView(rect, name, B_FOLLOW_ALL_SIDES, B_WILL_DRAW | B_PULSE_NEEDED | B_FRAME_EVENTS) { @@ -33,7 +39,7 @@ PulseView::PulseView(BRect rect, const char *name) : PulseView::PulseView(BMessage *message) : BView(message) { SetResizingMode(B_FOLLOW_ALL_SIDES); SetFlags(B_WILL_DRAW | B_PULSE_NEEDED); - + popupmenu = NULL; cpu_menu_items = NULL; Init(); @@ -46,14 +52,14 @@ void PulseView::Init() { mode2 = new BMenuItem("", NULL, 0, 0); preferences = new BMenuItem("Preferences" B_UTF8_ELLIPSIS, new BMessage(PV_PREFERENCES), 0, 0); about = new BMenuItem("About Pulse" B_UTF8_ELLIPSIS, new BMessage(PV_ABOUT), 0, 0); - + popupmenu->AddItem(mode1); popupmenu->AddItem(mode2); popupmenu->AddSeparatorItem(); - + system_info sys_info; get_system_info(&sys_info); - + // Only add menu items to control CPUs on an SMP machine if (sys_info.cpu_count >= 2) { cpu_menu_items = new BMenuItem *[sys_info.cpu_count]; @@ -67,7 +73,7 @@ void PulseView::Init() { } popupmenu->AddSeparatorItem(); } - + popupmenu->AddItem(preferences); popupmenu->AddItem(about); } @@ -77,7 +83,7 @@ void PulseView::MouseDown(BPoint point) { uint32 buttons; MakeFocus(true); GetMouse(&cursor, &buttons, true); - + if (buttons & B_SECONDARY_MOUSE_BUTTON) { ConvertToScreen(&point); // Use the asynchronous version so we don't interfere with @@ -98,11 +104,11 @@ void PulseView::Update() { if (cpu_time < 0) cpu_time = 0; if (cpu_time > 1) cpu_time = 1; cpu_times[x] = cpu_time; - + if (sys_info.cpu_count >= 2) { - if (!_kget_cpu_state_(x) && cpu_menu_items[x]->IsMarked()) + if (!_kern_cpu_enabled(x) && cpu_menu_items[x]->IsMarked()) cpu_menu_items[x]->SetMarked(false); - if (_kget_cpu_state_(x) && !cpu_menu_items[x]->IsMarked()) + if (_kern_cpu_enabled(x) && !cpu_menu_items[x]->IsMarked()) cpu_menu_items[x]->SetMarked(true); } } @@ -111,9 +117,9 @@ void PulseView::Update() { void PulseView::ChangeCPUState(BMessage *message) { int which = message->FindInt32("which"); - + if (!LastEnabledCPU(which)) { - _kset_cpu_state_(which, (int)!cpu_menu_items[which]->IsMarked()); + _kern_set_cpu_enabled(which, (int)!cpu_menu_items[which]->IsMarked()); } else { BAlert *alert = new BAlert(NULL, "You can't disable the last active CPU.", "OK"); alert->Go(NULL); diff --git a/src/apps/pulse/PulseView.h b/src/apps/pulse/PulseView.h index 9268560afe..b61922a886 100644 --- a/src/apps/pulse/PulseView.h +++ b/src/apps/pulse/PulseView.h @@ -15,8 +15,6 @@ #include #include -extern "C" int _kget_cpu_state_(int cpu); -extern "C" int _kset_cpu_state_(int cpu, int enabled); class PulseView : public BView { public: @@ -25,15 +23,15 @@ class PulseView : public BView { ~PulseView(); virtual void MouseDown(BPoint point); void ChangeCPUState(BMessage *message); - + protected: void Init(); void Update(); - + BPopUpMenu *popupmenu; BMenuItem *mode1, *mode2, *preferences, *about; BMenuItem **cpu_menu_items; - + double cpu_times[B_MAX_CPU_COUNT]; bigtime_t prev_active[B_MAX_CPU_COUNT]; bigtime_t prev_time; diff --git a/src/apps/showimage/Filter.cpp b/src/apps/showimage/Filter.cpp index d47b15378c..eac0e09fa2 100644 --- a/src/apps/showimage/Filter.cpp +++ b/src/apps/showimage/Filter.cpp @@ -15,9 +15,9 @@ #include #include -#include "Filter.h" +#include -extern "C" int _kget_cpu_state_(int cpu); +#include "Filter.h" // Implementation of FilterThread @@ -44,7 +44,7 @@ FilterThread::~FilterThread() fFilter->FilterThreadDone(); } -status_t +status_t FilterThread::worker_thread(void* data) { FilterThread* thread = (FilterThread*)data; @@ -87,12 +87,12 @@ Filter::Filter(BBitmap* image, BMessenger listener, uint32 what) , fDestImage(NULL) { fCPUCount = NumberOfActiveCPUs(); - + fWaitForThreads = create_sem(0, "wait_for_threads"); - + #if TIME_FILTER fStopWatch = NULL; - #endif + #endif } Filter::~Filter() @@ -123,19 +123,19 @@ void Filter::Start(bool async) { if (fStarted || fSrcImage == NULL) return; - + #if TIME_FILTER fStopWatch = new BStopWatch("Filter Time"); #endif - + fN = NumberOfThreads(); fNumberOfThreads = fN; - fIsRunning = true; + fIsRunning = true; fStarted = true; // start first filter thread new FilterThread(this, 0, fN, !async); - + if (!async) { Wait(); } @@ -238,7 +238,7 @@ Filter::NumberOfActiveCPUs() const count = info.cpu_count; int32 cpuCount = 0; for (int i = 0; i < count; i ++) { - if (_kget_cpu_state_(i)) + if (_kern_cpu_enabled(i)) cpuCount++; } if (cpuCount == 0) @@ -271,19 +271,19 @@ Scaler::CreateDestImage(BBitmap* srcImage) BRect dest(0, 0, fRect.IntegerWidth(), fRect.IntegerHeight()); BBitmap* destImage = new BBitmap(dest, fDither ? B_CMAP8 : srcImage->ColorSpace()); - + if (!IsBitmapValid(destImage)) { delete destImage; return NULL; } - - if (fDither) + + if (fDither) { BRect dest_rect(0, 0, fRect.IntegerWidth(), fRect.IntegerHeight()); fScaledImage = new BBitmap(dest_rect, srcImage->ColorSpace()); if (!IsBitmapValid(fScaledImage)) { delete destImage; - delete fScaledImage; + delete fScaledImage; fScaledImage = NULL; return NULL; } @@ -330,17 +330,17 @@ Scaler::ScaleBilinear(intType fromRow, int32 toRow) src = GetSrcImage(); dest = fScaledImage; - + srcW = src->Bounds().IntegerWidth(); srcH = src->Bounds().IntegerHeight(); destW = dest->Bounds().IntegerWidth(); destH = dest->Bounds().IntegerHeight(); - + srcBits = (uchar*)src->Bits(); destBits = (uchar*)dest->Bits(); srcBPR = src->BytesPerRow(); destBPR = dest->BytesPerRow(); - + columnData = new ColumnData[destW]; cd = columnData; for (i = 0; i < destW; i ++, cd++) { @@ -351,7 +351,7 @@ Scaler::ScaleBilinear(intType fromRow, int32 toRow) } destDataRow = destBits + fromRow * destBPR; - + for (y = fromRow; IsRunning() && y <= toRow; y ++, destDataRow += destBPR) { float row; intType srcRow; @@ -368,7 +368,7 @@ Scaler::ScaleBilinear(intType fromRow, int32 toRow) srcData = srcBits + srcRow * srcBPR; destData = destDataRow; - + if (y < destH) { float a0, a1; const uchar *a, *b, *c, *d; @@ -378,10 +378,10 @@ Scaler::ScaleBilinear(intType fromRow, int32 toRow) b = a + kBPP; c = a + srcBPR; d = c + kBPP; - + a0 = columnData[x].alpha0; a1 = columnData[x].alpha1; - + destData[0] = static_cast( (a[0] * a0 + b[0] * a1) * alpha0 + (c[0] * a0 + d[0] * a1) * alpha1); @@ -395,11 +395,11 @@ Scaler::ScaleBilinear(intType fromRow, int32 toRow) (a[3] * a0 + b[3] * a1) * alpha0 + (c[3] * a0 + d[3] * a1) * alpha1); } - + // right column a = srcData + srcW * kBPP; c = a + srcBPR; - + destData[0] = static_cast(a[0] * alpha0 + c[0] * alpha1); destData[1] = static_cast(a[1] * alpha0 + c[1] * alpha1); destData[2] = static_cast(a[2] * alpha0 + c[2] * alpha1); @@ -410,16 +410,16 @@ Scaler::ScaleBilinear(intType fromRow, int32 toRow) for (x = 0; x < destW; x ++, destData += kBPP) { a = srcData + columnData[x].srcColumn * kBPP; b = a + kBPP; - + a0 = columnData[x].alpha0; a1 = columnData[x].alpha1; - + destData[0] = static_cast(a[0] * a0 + b[0] * a1); destData[1] = static_cast(a[1] * a0 + b[1] * a1); destData[2] = static_cast(a[2] * a0 + b[2] * a1); destData[3] = static_cast(a[3] * a0 + b[3] * a1); } - + // bottom, right pixel a = srcData + srcW * kBPP; @@ -428,9 +428,9 @@ Scaler::ScaleBilinear(intType fromRow, int32 toRow) destData[2] = a[2]; destData[3] = a[3]; } - + } - + delete[] columnData; } @@ -464,22 +464,22 @@ Scaler::ScaleBilinearFP(intType fromRow, int32 toRow) src = GetSrcImage(); dest = fScaledImage; - + srcW = src->Bounds().IntegerWidth(); srcH = src->Bounds().IntegerHeight(); destW = dest->Bounds().IntegerWidth(); destH = dest->Bounds().IntegerHeight(); - + srcBits = (uchar*)src->Bits(); destBits = (uchar*)dest->Bits(); srcBPR = src->BytesPerRow(); destBPR = dest->BytesPerRow(); - - fixed_point fpSrcW = to_fixed_point(srcW); + + fixed_point fpSrcW = to_fixed_point(srcW); fixed_point fpDestW = to_fixed_point(destW); fixed_point fpSrcH = to_fixed_point(srcH); fixed_point fpDestH = to_fixed_point(destH); - + columnData = new ColumnDataFP[destW]; cd = columnData; for (i = 0; i < destW; i ++, cd++) { @@ -490,7 +490,7 @@ Scaler::ScaleBilinearFP(intType fromRow, int32 toRow) } destDataRow = destBits + fromRow * destBPR; - + for (y = fromRow; IsRunning() && y <= toRow; y ++, destDataRow += destBPR) { fixed_point row; intType srcRow; @@ -514,7 +514,7 @@ Scaler::ScaleBilinearFP(intType fromRow, int32 toRow) (c[i] * a0 + d[i] * a1) * alpha1)) #define V2(i) from_fixed_point(a[i] * alpha0 + c[i] * alpha1); #define H2(i) from_fixed_point(a[i] * a0 + b[i] * a1); - + if (y < destH) { fixed_point a0, a1; const uchar *a, *b, *c, *d; @@ -524,20 +524,20 @@ Scaler::ScaleBilinearFP(intType fromRow, int32 toRow) b = a + kBPP; c = a + srcBPR; d = c + kBPP; - + a0 = columnData[x].alpha0; a1 = columnData[x].alpha1; - + destData[0] = I4(0); destData[1] = I4(1); destData[2] = I4(2); destData[3] = I4(3); } - + // right column a = srcData + srcW * kBPP; c = a + srcBPR; - + destData[0] = V2(0); destData[1] = V2(1); destData[2] = V2(2); @@ -548,16 +548,16 @@ Scaler::ScaleBilinearFP(intType fromRow, int32 toRow) for (x = 0; x < destW; x ++, destData += kBPP) { a = srcData + columnData[x].srcColumn * kBPP; b = a + kBPP; - + a0 = columnData[x].alpha0; a1 = columnData[x].alpha1; - + destData[0] = H2(0); destData[1] = H2(1); destData[2] = H2(2); destData[3] = H2(3); } - + // bottom, right pixel a = srcData + srcW * kBPP; @@ -566,9 +566,9 @@ Scaler::ScaleBilinearFP(intType fromRow, int32 toRow) destData[2] = a[2]; destData[3] = a[3]; } - + } - + delete[] columnData; } @@ -578,15 +578,15 @@ Scaler::RowValues(float* sum, const uchar* src, intType srcW, intType fromX, int sum[0] = a0X * src[0]; sum[1] = a0X * src[1]; sum[2] = a0X * src[2]; - + src += kBPP; - + for (int32 x = fromX+1; x < toX; x ++, src += kBPP) { sum[0] += src[0]; sum[1] += src[1]; sum[2] += src[2]; } - + if (toX <= srcW) { sum[0] += a1X * src[0]; sum[1] += a1X * src[1]; @@ -620,19 +620,19 @@ Scaler::DownScaleBilinear(intType fromRow, int32 toRow) src = GetSrcImage(); dest = fScaledImage; - + srcW = src->Bounds().IntegerWidth(); srcH = src->Bounds().IntegerHeight(); destW = dest->Bounds().IntegerWidth(); destH = dest->Bounds().IntegerHeight(); - + srcBits = (uchar*)src->Bits(); destBits = (uchar*)dest->Bits(); srcBPR = src->BytesPerRow(); destBPR = dest->BytesPerRow(); - + destDataRow = destBits + fromRow * destBPR; - + const float deltaX = (srcW + 1.0) / (destW + 1.0); const float deltaY = (srcH + 1.0) / (destH + 1.0); const float deltaXY = deltaX * deltaY; @@ -642,61 +642,61 @@ Scaler::DownScaleBilinear(intType fromRow, int32 toRow) for (x = 0; x <= destW; x ++, cd ++) { const float fFromX = x * deltaX; const float fToX = fFromX + deltaX; - + cd->from = (intType)fFromX; cd->to = (intType)fToX; - + cd->alpha0 = 1.0 - (fFromX - cd->from); - cd->alpha1 = fToX - cd->to; + cd->alpha1 = fToX - cd->to; } - + for (y = fromRow; IsRunning() && y <= toRow; y ++, destDataRow += destBPR) { const float fFromY = y * deltaY; const float fToY = fFromY + deltaY; - + const intType fromY = (intType)fFromY; const intType toY = (intType)fToY; - + const float a0Y = 1.0 - (fFromY - fromY); - const float a1Y = fToY - toY; - + const float a1Y = fToY - toY; + const uchar* srcDataRow = srcBits + fromY * srcBPR; destData = destDataRow; - + cd = columnData; for (x = 0; x <= destW; x ++, destData += kBPP, cd ++) { const intType fromX = cd->from; const intType toX = cd->to; - + const float a0X = cd->alpha0; const float a1X = cd->alpha1; srcData = srcDataRow + fromX * kBPP; - + float totalSum[3]; float sum[3]; - + RowValues(sum, srcData, srcW, fromX, toX, a0X, a1X, kBPP); totalSum[0] = a0Y * sum[0]; totalSum[1] = a0Y * sum[1]; totalSum[2] = a0Y * sum[2]; - + srcData += srcBPR; - + for (int32 r = fromY+1; r < toY; r ++, srcData += srcBPR) { RowValues(sum, srcData, srcW, fromX, toX, a0X, a1X, kBPP); totalSum[0] += sum[0]; totalSum[1] += sum[1]; totalSum[2] += sum[2]; } - + if (toY <= srcH) { RowValues(sum, srcData, srcW, fromX, toX, a0X, a1X, kBPP); totalSum[0] += a1Y * sum[0]; totalSum[1] += a1Y * sum[1]; totalSum[2] += a1Y * sum[2]; } - + destData[0] = static_cast(totalSum[0] / deltaXY); destData[1] = static_cast(totalSum[1] / deltaXY); destData[2] = static_cast(totalSum[2] / deltaXY); @@ -715,7 +715,7 @@ typedef struct { intType error[3]; } DitheringColumnData; -uchar +uchar Scaler::Limit(intType value) { if (value < 0) { @@ -749,7 +749,7 @@ Scaler::Dither(int32 fromRow, int32 toRow) DitheringColumnData* cd; BScreen screen; intType error[3], err[3]; - + src = fScaledImage; dest = GetDestImage(); @@ -757,20 +757,20 @@ Scaler::Dither(int32 fromRow, int32 toRow) ASSERT(dest->ColorSpace() == B_CMAP8); ASSERT(src->Bounds().IntegerWidth() == dest->Bounds().IntegerWidth()); ASSERT(src->Bounds().IntegerHeight() == dest->Bounds().IntegerHeight()); - + destW = dest->Bounds().IntegerWidth(); destH = dest->Bounds().IntegerHeight(); - + srcBits = (uchar*)src->Bits(); srcBPR = src->BytesPerRow(); destBits = (uchar*)dest->Bits(); destBPR = dest->BytesPerRow(); - + // Allocate space for sentinel at left and right bounds, // so that columnData[-1] and columnData[destW+1] can be safely accessed columnData0 = new DitheringColumnData[destW+3]; columnData = columnData0 + 1; - + // clear error cd = columnData; for (x = destW; x >= 0; x --, cd ++) { @@ -787,38 +787,38 @@ Scaler::Dither(int32 fromRow, int32 toRow) for (x = 0; x <= destW; x ++, srcData += kBPP, destData += 1) { rgb_color color, actualColor; uint8 index; - + color.red = Limit(srcData[2] + error[0] / 16); color.green = Limit(srcData[1] + error[1] / 16); color.blue = Limit(srcData[0] + error[2] / 16); - + index = screen.IndexForColor(color); actualColor = screen.ColorForIndex(index); - + *destData = index; - + err[0] = color.red - actualColor.red; err[1] = color.green -actualColor.green; err[2] = color.blue -actualColor.blue; - + // distribute error // get error for next pixel cd = &columnData[x+1]; error[0] = cd->error[0] + 7 * err[0]; error[1] = cd->error[1] + 7 * err[1]; error[2] = cd->error[2] + 7 * err[2]; - + // set error for right pixel below current pixel cd->error[0] = err[0]; cd->error[1] = err[1]; cd->error[2] = err[2]; - + // add error for pixel below current pixel cd --; cd->error[0] += 5 * err[0]; cd->error[1] += 5 * err[1]; cd->error[2] += 5 * err[2]; - + // add error for left pixel below current pixel cd --; cd->error[0] += 3 * err[0]; @@ -837,38 +837,38 @@ Scaler::Dither(int32 fromRow, int32 toRow) for (x = 0; x <= destW; x ++, srcData -= kBPP, destData -= 1) { rgb_color color, actualColor; uint8 index; - + color.red = Limit(srcData[2] + error[0] / 16); color.green = Limit(srcData[1] + error[1] / 16); color.blue = Limit(srcData[0] + error[2] / 16); - + index = screen.IndexForColor(color); actualColor = screen.ColorForIndex(index); - + *destData = index; - + err[0] = color.red - actualColor.red; err[1] = color.green -actualColor.green; err[2] = color.blue -actualColor.blue; - + // distribute error // get error for next pixel cd = &columnData[x-1]; error[0] = cd->error[0] + 7 * err[0]; error[1] = cd->error[1] + 7 * err[1]; error[2] = cd->error[2] + 7 * err[2]; - + // set error for left pixel below current pixel cd->error[0] = err[0]; cd->error[1] = err[1]; cd->error[2] = err[2]; - + // add error for pixel below current pixel cd ++; cd->error[0] += 5 * err[0]; cd->error[1] += 5 * err[1]; cd->error[2] += 5 * err[2]; - + // add error for right pixel below current pixel cd ++; cd->error[0] += 3 * err[0]; @@ -888,7 +888,7 @@ Scaler::GetNumberOfUnits() void Scaler::Run(int32 i, int32 n) -{ +{ int32 from, to, height, imageHeight; imageHeight = GetDestImage()->Bounds().IntegerHeight() + 1; height = imageHeight / n; @@ -930,28 +930,28 @@ ImageProcessor::CreateDestImage(BBitmap* /* srcImage */) color_space cs; BBitmap* bm; BRect rect; - + if (GetSrcImage() == NULL) return NULL; - + cs = GetSrcImage()->ColorSpace(); - fBPP = BytesPerPixel(cs); + fBPP = BytesPerPixel(cs); if (fBPP < 1) return NULL; - + fWidth = GetSrcImage()->Bounds().IntegerWidth(); fHeight = GetSrcImage()->Bounds().IntegerHeight(); - + if (fOp == kRotateClockwise || fOp == kRotateCounterClockwise) { rect.Set(0, 0, fHeight, fWidth); } else { rect.Set(0, 0, fWidth, fHeight); } - + bm = new BBitmap(rect, cs); if (!IsBitmapValid(bm)) { delete bm; return NULL; } - + fSrcBPR = GetSrcImage()->BytesPerRow(); fDestBPR = bm->BytesPerRow(); @@ -964,7 +964,7 @@ ImageProcessor::GetNumberOfUnits() return GetSrcImage()->Bounds().IntegerHeight() + 1; } -int32 +int32 ImageProcessor::BytesPerPixel(color_space cs) const { switch (cs) { @@ -1042,7 +1042,7 @@ ImageProcessor::Run(int32 i, int32 n) } else { to = from + height - 1; } - + int32 x, y, destX, destY; const uchar* src = (uchar*)GetSrcImage()->Bits(); uchar* dest = (uchar*)GetDestImage()->Bits(); diff --git a/src/apps/showimage/Jamfile b/src/apps/showimage/Jamfile index 7a0f47a559..797ff0903b 100644 --- a/src/apps/showimage/Jamfile +++ b/src/apps/showimage/Jamfile @@ -1,10 +1,9 @@ SubDir HAIKU_TOP src apps showimage ; +UsePrivateSystemHeaders ; UsePrivateHeaders tracker shared ; UsePublicHeaders [ FDirName be_apps Tracker ] ; -SetSubDirSupportedPlatformsBeOSCompatible ; - Application ShowImage : ShowImageApp.cpp ShowImageSettings.cpp