Path: blob/master/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/common.h
41159 views
/*1* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425#ifndef COMMON_H26#define COMMON_H2728#include <simd/simd.h>2930#define PGRAM_VERTEX_COUNT 631#define QUAD_VERTEX_COUNT 432#define GRAD_MAX_FRACTIONS 123334enum GradCycleMethod {35GradNoCycle = 0,36GradReflect = 1,37GradRepeat = 238};39enum VertexAttributes {40VertexAttributePosition = 0,41VertexAttributeTexPos = 1,42VertexAttributeITexPos = 243};4445enum BufferIndex {46MeshVertexBuffer = 0,47FrameUniformBuffer = 1,48MatrixBuffer = 249};5051struct FrameUniforms {52vector_float4 color;53};5455struct TransformMatrix {56matrix_float4x4 transformMatrix;57};5859struct GradFrameUniforms {60vector_float3 params;61vector_float4 color1;62vector_float4 color2;63int isCyclic;64float extraAlpha;65};6667struct LinGradFrameUniforms {68vector_float3 params;69float fract[GRAD_MAX_FRACTIONS];70vector_float4 color[GRAD_MAX_FRACTIONS];71int numFracts;72int isLinear;73int cycleMethod;74float extraAlpha;75};7677struct RadGradFrameUniforms {78float fract[GRAD_MAX_FRACTIONS];79vector_float4 color[GRAD_MAX_FRACTIONS];80int numFracts;81int isLinear;82int cycleMethod;83vector_float3 m0;84vector_float3 m1;85vector_float3 precalc;86float extraAlpha;87};8889struct Vertex {90float position[2];91};9293struct TxtVertex {94float position[2];95float txtpos[2];96};9798struct AAVertex {99float position[2];100float otxtpos[2];101float itxtpos[2];102};103104// These values are mapped from AffineTransformOp105#define INTERPOLATION_NEAREST_NEIGHBOR 1106#define INTERPOLATION_BILINEAR 2107// #define INTERPOLATION_BICUBIC 3108// NOTE: Metal samplers doesn't supports bicubic interpolation109// see table 2.7 from https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf110// (probably we need to implement separate fragment shader with bicubic interpolation)111112struct TxtFrameUniforms {113vector_float4 color;114int mode; // NOTE: consider to use bit fields115int isSrcOpaque;116int isDstOpaque;117float extraAlpha;118};119120struct TxtFrameOpRescaleUniforms {121vector_float4 color;122float extraAlpha;123124int isSrcOpaque;125int isNonPremult;126127vector_float4 normScaleFactors;128vector_float4 normOffsets;129};130131struct TxtFrameOpConvolveUniforms {132float extraAlpha;133int isSrcOpaque;134vector_float4 imgEdge;135int kernelSize;136int isEdgeZeroFill;137};138139struct TxtFrameOpLookupUniforms {140float extraAlpha;141int isSrcOpaque;142vector_float4 offset;143int isUseSrcAlpha;144int isNonPremult;145};146147struct AnchorData148{149vector_float3 xParams;150vector_float3 yParams;151};152153struct LCDFrameUniforms {154vector_float3 src_adj;155vector_float3 gamma;156vector_float3 invgamma;157};158159struct SwizzleUniforms {160unsigned char swizzle[4];161unsigned char hasAlpha;162};163#endif164165166