diff --git a/api/Makefile.am b/api/Makefile.am index 370fe89491..f4199f8185 100644 --- a/api/Makefile.am +++ b/api/Makefile.am @@ -9,25 +9,29 @@ AM_LDFLAGS = @GLUT_LIBS@ api_files= \ boinc_api.C +# graphics library for monolithic apps graphics_api_files = \ graphics_api.C \ graphics_data.C \ graphics_impl.C \ - reduce.C \ + reduce_main.C \ + reduce_lib.C \ gutil.C \ x_opengl.C +# library for main-program part of split apps graphics_lib_files = \ graphics_lib.C \ graphics_data.C \ - reduce.C + reduce_main.C +# library for shared-library part of split apps graphics_impl_files = \ graphics_data.C \ graphics_impl.C \ graphics_impl_lib.C \ gutil.C \ - reduce.C \ + reduce_lib.C \ x_opengl.C EXTRA_DIST = \ diff --git a/api/reduce.C b/api/reduce_lib.C similarity index 74% rename from api/reduce.C rename to api/reduce_lib.C index 546632aaff..e154a83a72 100644 --- a/api/reduce.C +++ b/api/reduce_lib.C @@ -1,236 +1,34 @@ -// Copyright 2003 Regents of the University of California +// The contents of this file are subject to the BOINC Public License +// Version 1.0 (the "License"); you may not use this file except in +// compliance with the License. You may obtain a copy of the License at +// http://boinc.berkeley.edu/license_1.0.txt +// +// Software distributed under the License is distributed on an "AS IS" +// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the +// License for the specific language governing rights and limitations +// under the License. +// +// The Original Code is the Berkeley Open Infrastructure for Network Computing. +// +// The Initial Developer of the Original Code is the SETI@home project. +// Portions created by the SETI@home project are Copyright (C) 2002 +// University of California at Berkeley. All Rights Reserved. +// +// Contributor(s): +// -// SETI_BOINC is free software; you can redistribute it and/or modify it under -// the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2, or (at your option) any later -// version. - -// SETI_BOINC 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 General Public License for -// more details. - -// You should have received a copy of the GNU General Public License along -// with SETI_BOINC; see the file COPYING. If not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +// shared-library part of the implementation of REDUCE #ifdef _WIN32 -#include "boinc_win.h" #include #endif -#ifndef _WIN32 -#include -#include -#include -#include - -#include -#include -#include -#include #include -#ifdef __APPLE_CC__ -#include -#endif -#endif - -//#include "std_fixes.h" #include "boinc_gl.h" #include "gutil.h" #include "reduce.h" -REDUCED_ARRAY::REDUCED_ARRAY() { - rdata = 0; - ftemp = 0; - itemp = 0; - reduce_method = REDUCE_METHOD_AVG; -} - -REDUCED_ARRAY::~REDUCED_ARRAY() { - if (rdata) free(rdata); - if (ftemp) free(ftemp); - if (itemp) free(itemp); -} - -// (mx, my) are maximum reduced dimensions -// (typically based on window size, e.g. half of window size in pixels) -// -void REDUCED_ARRAY::set_max_dims(int mx, int my) { - rdimx_max = mx; - rdimy_max = my; - rdimx = rdimx_max; - rdimy = rdimy_max; -} - -// Prepare to receive a source array. -// (sx, sy) are dimensions of source array -// -void REDUCED_ARRAY::init_data(int sx, int sy) { - sdimx = sx; - sdimy = sy; - if (sdimx > rdimx_max) { - rdimx = rdimx_max; - } else { - rdimx = sdimx; - } - if (sdimy > rdimy_max) { - rdimy = rdimy_max; - } else { - rdimy = sdimy; - } - rdata = (float*)realloc(rdata, rdimx*rdimy*sizeof(float)); - ftemp = (float*)realloc(ftemp, rdimx*sizeof(float)); - itemp = (int*)realloc(itemp, rdimx*sizeof(int)); - nvalid_rows = 0; - ndrawn_rows = 0; - scury = 0; - last_ry = 0; - last_ry_count = 0; - rdata_max = 0; - rdata_min = (float)1e20; -} - -bool REDUCED_ARRAY::full() { - return nvalid_rows==rdimy; -} - -void REDUCED_ARRAY::reset() { - nvalid_rows = 0; - ndrawn_rows = 0; - scury = 0; - last_ry = 0; - last_ry_count = 0; -} - -void REDUCED_ARRAY::init_display( - GRAPH_STYLE st, float* p, float* s, double h0, double dh, float trans, - char* xl, char* yl, char* zl -) { - memcpy(draw_pos, p, sizeof(draw_pos)); - memcpy(draw_size, s, sizeof(draw_size)); - draw_deltax = draw_size[0]/rdimx; - draw_deltaz = draw_size[2]/rdimy; - hue0 = h0; - dhue = dh; - alpha = trans; - draw_style = st; - xlabel=xl; - ylabel=yl; - zlabel=zl; -} - -// reduce a single row. This is called only if sdimx > rdimx; -// -void REDUCED_ARRAY::reduce_source_row(float* in, float* out) { - int i, ri; - - memset(out, 0, rdimx*sizeof(float)); - memset(itemp, 0, rdimx*sizeof(int)); - for (i=0; i 1) out[i] /= itemp[i]; - } - } -} - -void REDUCED_ARRAY::update_max(int row) { - int i; - float* p = rrow(row); - - for (i=0; i rdata_max) rdata_max = p[i]; - if (p[i] < rdata_min) rdata_min = p[i]; - } -} - -// Add a row of data from the source array -// -void REDUCED_ARRAY::add_source_row(float* in) { - float* p; - int i, ry; - - if (scury >= sdimy) { - printf("too many calls to add_source_row()!\n"); - *(int*)0 = 0; - } - if (rdimy == sdimy) { - ry = scury; - if (rdimx == sdimx) { - memcpy(rrow(ry), in, rdimx*sizeof(float)); - } else { - reduce_source_row(in, rrow(ry)); - } - update_max(ry); - nvalid_rows++; - } else { - ry = (scury*rdimy)/sdimy; - if (scury == 0) memset(rrow(0), 0, rdimx*sizeof(float)); - - // if we've moved into a new row, finish up the previous one - // - if (ry > last_ry) { - p = rrow(last_ry); - if (last_ry_count > 1) { - for (i=0; i 1) { - for (i=0; i +#endif + +#ifndef _WIN32 +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#ifdef __APPLE_CC__ +#include +#endif +#endif + +//#include "std_fixes.h" +#include "boinc_gl.h" +#include "gutil.h" +#include "reduce.h" + +REDUCED_ARRAY::REDUCED_ARRAY() { + rdata = 0; + ftemp = 0; + itemp = 0; + reduce_method = REDUCE_METHOD_AVG; +} + +REDUCED_ARRAY::~REDUCED_ARRAY() { + if (rdata) free(rdata); + if (ftemp) free(ftemp); + if (itemp) free(itemp); +} + +// (mx, my) are maximum reduced dimensions +// (typically based on window size, e.g. half of window size in pixels) +// +void REDUCED_ARRAY::set_max_dims(int mx, int my) { + rdimx_max = mx; + rdimy_max = my; + rdimx = rdimx_max; + rdimy = rdimy_max; +} + +// Prepare to receive a source array. +// (sx, sy) are dimensions of source array +// +void REDUCED_ARRAY::init_data(int sx, int sy) { + sdimx = sx; + sdimy = sy; + if (sdimx > rdimx_max) { + rdimx = rdimx_max; + } else { + rdimx = sdimx; + } + if (sdimy > rdimy_max) { + rdimy = rdimy_max; + } else { + rdimy = sdimy; + } + rdata = (float*)realloc(rdata, rdimx*rdimy*sizeof(float)); + ftemp = (float*)realloc(ftemp, rdimx*sizeof(float)); + itemp = (int*)realloc(itemp, rdimx*sizeof(int)); + nvalid_rows = 0; + ndrawn_rows = 0; + scury = 0; + last_ry = 0; + last_ry_count = 0; + rdata_max = 0; + rdata_min = (float)1e20; +} + +bool REDUCED_ARRAY::full() { + return nvalid_rows==rdimy; +} + +void REDUCED_ARRAY::reset() { + nvalid_rows = 0; + ndrawn_rows = 0; + scury = 0; + last_ry = 0; + last_ry_count = 0; +} + +void REDUCED_ARRAY::init_display( + GRAPH_STYLE st, float* p, float* s, double h0, double dh, float trans, + char* xl, char* yl, char* zl +) { + memcpy(draw_pos, p, sizeof(draw_pos)); + memcpy(draw_size, s, sizeof(draw_size)); + draw_deltax = draw_size[0]/rdimx; + draw_deltaz = draw_size[2]/rdimy; + hue0 = h0; + dhue = dh; + alpha = trans; + draw_style = st; + xlabel=xl; + ylabel=yl; + zlabel=zl; +} + +// reduce a single row. This is called only if sdimx > rdimx; +// +void REDUCED_ARRAY::reduce_source_row(float* in, float* out) { + int i, ri; + + memset(out, 0, rdimx*sizeof(float)); + memset(itemp, 0, rdimx*sizeof(int)); + for (i=0; i 1) out[i] /= itemp[i]; + } + } +} + +void REDUCED_ARRAY::update_max(int row) { + int i; + float* p = rrow(row); + + for (i=0; i rdata_max) rdata_max = p[i]; + if (p[i] < rdata_min) rdata_min = p[i]; + } +} + +// Add a row of data from the source array +// +void REDUCED_ARRAY::add_source_row(float* in) { + float* p; + int i, ry; + + if (scury >= sdimy) { + printf("too many calls to add_source_row()!\n"); + *(int*)0 = 0; + } + if (rdimy == sdimy) { + ry = scury; + if (rdimx == sdimx) { + memcpy(rrow(ry), in, rdimx*sizeof(float)); + } else { + reduce_source_row(in, rrow(ry)); + } + update_max(ry); + nvalid_rows++; + } else { + ry = (scury*rdimy)/sdimy; + if (scury == 0) memset(rrow(0), 0, rdimx*sizeof(float)); + + // if we've moved into a new row, finish up the previous one + // + if (ry > last_ry) { + p = rrow(last_ry); + if (last_ry_count > 1) { + for (i=0; i 1) { + for (i=0; i