1 /*
2 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25
26 #ifndef MTLPaints_h_Included
27 #define MTLPaints_h_Included
28
29 #import <Metal/Metal.h>
30
31 #include "MTLSurfaceDataBase.h"
32
33 #define sun_java2d_SunGraphics2D_PAINT_UNDEFINED -1
34
35 @class MTLComposite;
36 @class MTLClip;
37 @class MTLPipelineStatesStorage;
38
39 /**
40 * The MTLPaint class represents paint mode (color, gradient, e.t.c.)
41 * */
42
43 @interface MTLPaint : NSObject
44 - (id)init;
45 - (BOOL)isEqual:(MTLPaint *)other; // used to compare requested with cached
46 - (void)copyFrom:(MTLPaint *)other; // used to save cached
47 - (NSString *)getDescription;
48 - (jint)getColor;
49 - (void)reset;
50
51 - (void)setColor:(jint)pixelColor;
52 - (void)setGradientUseMask:(jboolean)useMask
53 cyclic:(jboolean)cyclic
54 p0:(jdouble)p0
55 p1:(jdouble)p1
56 p3:(jdouble)p3
57 pixel1:(jint)pixel1
58 pixel2:(jint)pixel2;
59
60 - (void)setLinearGradient:(jboolean)useMask
61 linear:(jboolean)linear
62 cycleMethod:(jboolean)cycleMethod
63 numStops:(jint)numStops
64 p0:(jfloat)p0
65 p1:(jfloat)p1
66 p3:(jfloat)p3
67 fractions:(void *)fractions
68 pixels:(void *)pixels;
69
70 - (void)setRadialGradient:(jboolean)useMask
71 linear:(jboolean)linear
72 cycleMethod:(jboolean)cycleMethod
73 numStops:(jint)numStops
74 m00:(jfloat)m00
75 m01:(jfloat)m01
76 m02:(jfloat)m02
77 m10:(jfloat)m10
78 m11:(jfloat)m11
79 m12:(jfloat)m12
80 focusX:(jfloat)focusX
81 fractions:(void *)fractions
82 pixels:(void *)pixels;
83
84 - (void)setTexture:(jboolean)useMask
85 textureID:(id<MTLTexture>)textureID
86 filter:(jboolean)filter
87 xp0:(jdouble)xp0
88 xp1:(jdouble)xp1
89 xp3:(jdouble)xp3
90 yp0:(jdouble)yp0
91 yp1:(jdouble)yp1
92 yp3:(jdouble)yp3;
93
94 // For the current paint mode and passed composite (and flags):
95 // 1. Selects vertex+fragment shader (and corresponding pipelineDesc) and set pipelineState
96 // 2. Prepares corresponding buffers of vertex and fragment shaders
97 - (void)setPipelineState:(id<MTLRenderCommandEncoder>)encoder
98 composite:(MTLComposite *)composite
99 isStencilUsed:(jboolean)isStencilUsed
100 isTexture:(jboolean)isTexture
101 srcFlags:(const SurfaceRasterFlags *)srcFlags
102 dstFlags:(const SurfaceRasterFlags *)dstFlags
103 pipelineStateStorage:(MTLPipelineStatesStorage *)pipelineStateStorage;
104
105 - (void)setXorModePipelineState:(id<MTLRenderCommandEncoder>)encoder
106 composite:(MTLComposite *)composite
107 isStencilUsed:(jboolean)isStencilUsed
108 isTexture:(jboolean)isTexture
109 srcFlags:(const SurfaceRasterFlags *)srcFlags
110 dstFlags:(const SurfaceRasterFlags *)dstFlags
111 pipelineStateStorage:(MTLPipelineStatesStorage *)pipelineStateStorage;
112 @end
113
114 #endif /* MTLPaints_h_Included */