summaryrefslogtreecommitdiff
path: root/plugins/threaded/src/threaded_internal.h
blob: 3df3e2d5997d40dd43c5c49f9404871f837053de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
//---------------------------------------------------------------------------------
//
//  Little Color Management System, multithreaded extensions
//  Copyright (c) 1998-2023 Marti Maria Saguer, all rights reserved
//
// This program 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 3 of the License, or
// (at your option) any later version.
// 
// This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------------

#ifndef _THREADED_INTERNAL_H
#define _THREADED_INTERNAL_H

#include "lcms2_threaded.h"

// This plugin requires lcms 2.14 or greater
#define REQUIRED_LCMS_VERSION 2140

// Unused parameter warning suppression
#define UNUSED_PARAMETER(x) ((void)x) 

// For testbed
#define CMSCHECKPOINT CMSAPI

// The specification for "inline" is section 6.7.4 of the C99 standard (ISO/IEC 9899:1999).
// unfortunately VisualC++ does not conform that
#if defined(_MSC_VER) || defined(__BORLANDC__)
#   define cmsINLINE __inline
#else
#   define cmsINLINE static inline
#endif

// Holds all parameters for a threadable transform fragment
typedef struct {

	struct _cmstransform_struct* CMMcargo;

	const void* InputBuffer;
	void* OutputBuffer;

	cmsUInt32Number  PixelsPerLine;
	cmsUInt32Number  LineCount;
	const cmsStride* Stride;

} _cmsWorkSlice;

// Count the number of threads needed for this job
cmsUInt32Number _cmsThrCountSlices(struct _cmstransform_struct* CMMcargo, cmsInt32Number MaxWorkers, 
								   cmsUInt32Number PixelsPerLine, cmsUInt32Number LineCount, 
								   cmsStride* Stride);

// Split work following several expert rules
cmsBool		    _cmsThrSplitWork(const _cmsWorkSlice* master, cmsInt32Number nslices, _cmsWorkSlice slices[]);

// Thread primitives
cmsHANDLE       _cmsThrCreateWorker(cmsContext ContextID, _cmsTransform2Fn worker, _cmsWorkSlice* param);
void            _cmsThrJoinWorker(cmsContext ContextID, cmsHANDLE hWorker);
cmsInt32Number  _cmsThrIdealThreadCount(void);

// The scheduler
void  _cmsThrScheduler(struct _cmstransform_struct* CMMcargo,
				       const void* InputBuffer,
				       void* OutputBuffer,
				       cmsUInt32Number PixelsPerLine,
				       cmsUInt32Number LineCount,
				       const cmsStride* Stride);
#endif