[Haiku-commits] r31044 - in haiku/trunk/src/apps: processcontroller pulse showimage
bonefish at mail.berlios.de
bonefish at mail.berlios.de
Sun Jun 14 13:55:30 CEST 2009
Author: bonefish
Date: 2009-06-14 13:55:24 +0200 (Sun, 14 Jun 2009)
New Revision: 31044
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31044&view=rev
Modified:
haiku/trunk/src/apps/processcontroller/Jamfile
haiku/trunk/src/apps/processcontroller/PCWorld.h
haiku/trunk/src/apps/processcontroller/ProcessController.cpp
haiku/trunk/src/apps/pulse/CPUButton.cpp
haiku/trunk/src/apps/pulse/Jamfile
haiku/trunk/src/apps/pulse/PulseApp.cpp
haiku/trunk/src/apps/pulse/PulseView.cpp
haiku/trunk/src/apps/pulse/PulseView.h
haiku/trunk/src/apps/showimage/Filter.cpp
haiku/trunk/src/apps/showimage/Jamfile
Log:
Don't use private BeOS syscalls.
Modified: haiku/trunk/src/apps/processcontroller/Jamfile
===================================================================
--- haiku/trunk/src/apps/processcontroller/Jamfile 2009-06-14 11:10:36 UTC (rev 31043)
+++ haiku/trunk/src/apps/processcontroller/Jamfile 2009-06-14 11:55:24 UTC (rev 31044)
@@ -1,6 +1,6 @@
SubDir HAIKU_TOP src apps processcontroller ;
-SetSubDirSupportedPlatformsBeOSCompatible ;
+UsePrivateSystemHeaders ;
Application ProcessController :
AutoIcon.cpp
Modified: haiku/trunk/src/apps/processcontroller/PCWorld.h
===================================================================
--- haiku/trunk/src/apps/processcontroller/PCWorld.h 2009-06-14 11:10:36 UTC (rev 31043)
+++ haiku/trunk/src/apps/processcontroller/PCWorld.h 2009-06-14 11:55:24 UTC (rev 31044)
@@ -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 thread_id id;
-extern "C" int _kget_cpu_state_(int cpu);
-extern "C" int _kset_cpu_state_(int cpu, int enabled);
#endif // _PCWORLD_H_
Modified: haiku/trunk/src/apps/processcontroller/ProcessController.cpp
===================================================================
--- haiku/trunk/src/apps/processcontroller/ProcessController.cpp 2009-06-14 11:10:36 UTC (rev 31043)
+++ haiku/trunk/src/apps/processcontroller/ProcessController.cpp 2009-06-14 11:55:24 UTC (rev 31044)
@@ -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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <Alert.h>
#include <Bitmap.h>
@@ -49,10 +40,22 @@
#include <Screen.h>
#include <TextView.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#include <syscalls.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"
+
+
const char* kDeskbarItemName = "ProcessController";
const char* kClassName = "ProcessController";
@@ -340,7 +343,7 @@
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 @@
"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 @@
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);
Modified: haiku/trunk/src/apps/pulse/CPUButton.cpp
===================================================================
--- haiku/trunk/src/apps/pulse/CPUButton.cpp 2009-06-14 11:10:36 UTC (rev 31043)
+++ haiku/trunk/src/apps/pulse/CPUButton.cpp 2009-06-14 11:55:24 UTC (rev 31044)
@@ -10,11 +10,16 @@
#include "CPUButton.h"
+
+#include <stdlib.h>
+
+#include <Alert.h>
+
+#include <syscalls.h>
+
#include "PulseApp.h"
#include "PulseView.h"
#include "Common.h"
-#include <interface/Alert.h>
-#include <stdlib.h>
CPUButton::CPUButton(BRect rect, const char *name, const char *label, BMessage *message)
@@ -173,13 +178,13 @@
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 @@
}
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;
}
Modified: haiku/trunk/src/apps/pulse/Jamfile
===================================================================
--- haiku/trunk/src/apps/pulse/Jamfile 2009-06-14 11:10:36 UTC (rev 31043)
+++ haiku/trunk/src/apps/pulse/Jamfile 2009-06-14 11:55:24 UTC (rev 31044)
@@ -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 @@
ProgressBar.cpp
PulseApp.cpp
PulseView.cpp
- PulseWindow.cpp
+ PulseWindow.cpp
- : be
- : Pulse.rdef
+ : be
+ : Pulse.rdef
;
Modified: haiku/trunk/src/apps/pulse/PulseApp.cpp
===================================================================
--- haiku/trunk/src/apps/pulse/PulseApp.cpp 2009-06-14 11:10:36 UTC (rev 31043)
+++ haiku/trunk/src/apps/pulse/PulseApp.cpp 2009-06-14 11:55:24 UTC (rev 31044)
@@ -12,20 +12,23 @@
#include "PulseApp.h"
-#include "Common.h"
-#include "PulseWindow.h"
-#include "DeskbarPulseView.h"
-#include <Alert.h>
-#include <Rect.h>
-#include <Deskbar.h>
-
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <getopt.h>
+#include <Alert.h>
+#include <Rect.h>
+#include <Deskbar.h>
+#include <syscalls.h>
+
+#include "Common.h"
+#include "PulseWindow.h"
+#include "DeskbarPulseView.h"
+
+
PulseApp::PulseApp(int argc, char **argv)
: BApplication(APP_SIGNATURE)
{
@@ -60,7 +63,7 @@
uint32 rgb = strtoul(optarg, NULL, 0);
rgb = rgb << 8;
rgb |= 0x000000ff;
-
+
switch (option_index) {
case 2:
framecolor = rgb;
@@ -90,7 +93,7 @@
break;
}
}
-
+
if (deskbar) {
prefs->window_mode = DESKBAR_MODE;
if (activecolor != 0)
@@ -171,7 +174,7 @@
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 @@
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 @@
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);
Modified: haiku/trunk/src/apps/pulse/PulseView.cpp
===================================================================
--- haiku/trunk/src/apps/pulse/PulseView.cpp 2009-06-14 11:10:36 UTC (rev 31043)
+++ haiku/trunk/src/apps/pulse/PulseView.cpp 2009-06-14 11:55:24 UTC (rev 31044)
@@ -9,13 +9,19 @@
//****************************************************************************************
#include "PulseView.h"
-#include "Common.h"
-#include "PulseApp.h"
-#include <interface/Alert.h>
+
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <Alert.h>
+
+#include <syscalls.h>
+
+#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(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 @@
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 @@
}
popupmenu->AddSeparatorItem();
}
-
+
popupmenu->AddItem(preferences);
popupmenu->AddItem(about);
}
@@ -77,7 +83,7 @@
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 @@
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::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);
Modified: haiku/trunk/src/apps/pulse/PulseView.h
===================================================================
--- haiku/trunk/src/apps/pulse/PulseView.h 2009-06-14 11:10:36 UTC (rev 31043)
+++ haiku/trunk/src/apps/pulse/PulseView.h 2009-06-14 11:55:24 UTC (rev 31044)
@@ -15,8 +15,6 @@
#include <interface/PopUpMenu.h>
#include <interface/MenuItem.h>
-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 @@
~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;
Modified: haiku/trunk/src/apps/showimage/Filter.cpp
===================================================================
--- haiku/trunk/src/apps/showimage/Filter.cpp 2009-06-14 11:10:36 UTC (rev 31043)
+++ haiku/trunk/src/apps/showimage/Filter.cpp 2009-06-14 11:55:24 UTC (rev 31044)
@@ -15,11 +15,11 @@
#include <Debug.h>
#include <Screen.h>
+#include <syscalls.h>
+
#include "Filter.h"
-extern "C" int _kget_cpu_state_(int cpu);
-
// Implementation of FilterThread
FilterThread::FilterThread(Filter* filter, int32 i, int32 n, bool runInCurrentThread)
: fFilter(filter)
@@ -44,7 +44,7 @@
fFilter->FilterThreadDone();
}
-status_t
+status_t
FilterThread::worker_thread(void* data)
{
FilterThread* thread = (FilterThread*)data;
@@ -87,12 +87,12 @@
, fDestImage(NULL)
{
fCPUCount = NumberOfActiveCPUs();
-
+
fWaitForThreads = create_sem(0, "wait_for_threads");
-
+
#if TIME_FILTER
fStopWatch = NULL;
- #endif
+ #endif
}
Filter::~Filter()
@@ -123,19 +123,19 @@
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 @@
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 @@
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 @@
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 @@
}
destDataRow = destBits + fromRow * destBPR;
-
+
for (y = fromRow; IsRunning() && y <= toRow; y ++, destDataRow += destBPR) {
float row;
intType srcRow;
@@ -368,7 +368,7 @@
srcData = srcBits + srcRow * srcBPR;
destData = destDataRow;
-
+
if (y < destH) {
float a0, a1;
const uchar *a, *b, *c, *d;
@@ -378,10 +378,10 @@
b = a + kBPP;
c = a + srcBPR;
d = c + kBPP;
-
+
a0 = columnData[x].alpha0;
a1 = columnData[x].alpha1;
-
+
destData[0] = static_cast<uchar>(
(a[0] * a0 + b[0] * a1) * alpha0 +
(c[0] * a0 + d[0] * a1) * alpha1);
@@ -395,11 +395,11 @@
(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<uchar>(a[0] * alpha0 + c[0] * alpha1);
destData[1] = static_cast<uchar>(a[1] * alpha0 + c[1] * alpha1);
destData[2] = static_cast<uchar>(a[2] * alpha0 + c[2] * alpha1);
@@ -410,16 +410,16 @@
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<uchar>(a[0] * a0 + b[0] * a1);
destData[1] = static_cast<uchar>(a[1] * a0 + b[1] * a1);
destData[2] = static_cast<uchar>(a[2] * a0 + b[2] * a1);
destData[3] = static_cast<uchar>(a[3] * a0 + b[3] * a1);
}
-
+
// bottom, right pixel
a = srcData + srcW * kBPP;
@@ -428,9 +428,9 @@
destData[2] = a[2];
destData[3] = a[3];
}
-
+
}
-
+
delete[] columnData;
}
@@ -464,22 +464,22 @@
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 @@
}
destDataRow = destBits + fromRow * destBPR;
-
+
for (y = fromRow; IsRunning() && y <= toRow; y ++, destDataRow += destBPR) {
fixed_point row;
intType srcRow;
@@ -514,7 +514,7 @@
(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 @@
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 @@
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 @@
destData[2] = a[2];
destData[3] = a[3];
}
-
+
}
-
+
delete[] columnData;
}
@@ -578,15 +578,15 @@
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 @@
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 @@
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<uchar>(totalSum[0] / deltaXY);
destData[1] = static_cast<uchar>(totalSum[1] / deltaXY);
destData[2] = static_cast<uchar>(totalSum[2] / deltaXY);
@@ -715,7 +715,7 @@
intType error[3];
} DitheringColumnData;
-uchar
+uchar
Scaler::Limit(intType value)
{
if (value < 0) {
@@ -749,7 +749,7 @@
DitheringColumnData* cd;
BScreen screen;
intType error[3], err[3];
-
+
src = fScaledImage;
dest = GetDestImage();
@@ -757,20 +757,20 @@
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 @@
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 @@
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 @@
void
Scaler::Run(int32 i, int32 n)
-{
+{
int32 from, to, height, imageHeight;
imageHeight = GetDestImage()->Bounds().IntegerHeight() + 1;
height = imageHeight / n;
@@ -930,28 +930,28 @@
color_space cs;
BBitmap* bm;
BRect rect;
[... truncated: 68 lines follow ...]
More information about the Haiku-commits
mailing list