4632N/A/*
4632N/A * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
4632N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4632N/A *
4632N/A * This code is free software; you can redistribute it and/or modify it
4632N/A * under the terms of the GNU General Public License version 2 only, as
4632N/A * published by the Free Software Foundation. Oracle designates this
4632N/A * particular file as subject to the "Classpath" exception as provided
4632N/A * by Oracle in the LICENSE file that accompanied this code.
4632N/A *
4632N/A * This code is distributed in the hope that it will be useful, but WITHOUT
4632N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
4632N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
4632N/A * version 2 for more details (a copy is included in the LICENSE file that
4632N/A * accompanied this code).
4632N/A *
4632N/A * You should have received a copy of the GNU General Public License version
4632N/A * 2 along with this work; if not, write to the Free Software Foundation,
4632N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
4632N/A *
4632N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
4632N/A * or visit www.oracle.com if you need additional information or have any
4632N/A * questions.
4632N/A */
4632N/A
4632N/A#import "SurfaceData.h"
4632N/A#import "BufImgSurfaceData.h"
4632N/A#import "AWTFont.h"
4632N/A#import <Cocoa/Cocoa.h>
4632N/A
4632N/A// these flags are not defined on Tiger on PPC, so we need to make them a no-op
4632N/A#if !defined(kCGBitmapByteOrder32Host)
4632N/A#define kCGBitmapByteOrder32Host 0
4632N/A#endif
4632N/A#if !defined(kCGBitmapByteOrder16Host)
4632N/A#define kCGBitmapByteOrder16Host 0
4632N/A#endif
4632N/A
4632N/A// NOTE : Modify the printSurfaceDataDiagnostics API if you change this enum
4632N/Aenum SDRenderType
4632N/A{
4632N/A SD_Nothing,
4632N/A SD_Stroke,
4632N/A SD_Fill,
4632N/A SD_EOFill,
4632N/A SD_Shade,
4632N/A SD_Pattern,
4632N/A SD_Image,
4632N/A SD_Text,
4632N/A SD_CopyArea,
4632N/A SD_Queue,
4632N/A SD_External
4632N/A};
4632N/Atypedef enum SDRenderType SDRenderType;
4632N/A
4632N/Astruct _stateShadingInfo
4632N/A{
4632N/A CGPoint start;
4632N/A CGPoint end;
4632N/A CGFloat colors[8];
4632N/A BOOL cyclic;
4632N/A CGFloat length; // of the total segment (used by the cyclic gradient)
4632N/A CGFloat period; // of the cycle (used by the cyclic gradient)
4632N/A CGFloat offset; // of the cycle from the start (used by the cyclic gradient)
4632N/A};
4632N/Atypedef struct _stateShadingInfo StateShadingInfo;
4632N/A
4632N/Astruct _statePatternInfo
4632N/A{
4632N/A CGFloat tx;
4632N/A CGFloat ty;
4632N/A CGFloat sx;
4632N/A CGFloat sy;
4632N/A jint width;
4632N/A jint height;
4632N/A jobject sdata;
4632N/A};
4632N/Atypedef struct _statePatternInfo StatePatternInfo;
4632N/A
4632N/Astruct _stateGraphicsInfo
4632N/A{
4632N/A BOOL adjustedLineWidth;
4632N/A BOOL adjustedAntialias;
4632N/A BOOL antialiased;
4632N/A jint interpolation;
4632N/A BOOL simpleColor;
4632N/A BOOL simpleStroke;
4632N/A CGAffineTransform ctm;
4632N/A CGFloat offsetX;
4632N/A CGFloat offsetY;
4632N/A struct CGPoint* batchedLines;
4632N/A UInt32 batchedLinesCount;
4632N/A};
4632N/Atypedef struct _stateGraphicsInfo StateGraphicsInfo;
4632N/A
4632N/Atypedef struct _QuartzSDOps QuartzSDOps;
4632N/Atypedef void BeginContextFunc(JNIEnv *env, QuartzSDOps *qsdo, SDRenderType renderType);
4632N/Atypedef void FinishContextFunc(JNIEnv *env, QuartzSDOps *qsdo);
4632N/Astruct _QuartzSDOps
4632N/A{
4632N/A BufImgSDOps sdo; // must be the first entry!
4632N/A
4632N/A BeginContextFunc* BeginSurface; // used to set graphics states (clip, color, stroke, etc...)
4632N/A FinishContextFunc* FinishSurface; // used to finish drawing primitives
4632N/A BOOL newContext;
4632N/A CGContextRef cgRef;
4632N/A
4632N/A jint* javaGraphicsStates;
4632N/A jobject javaGraphicsStatesObjects;
4632N/A
4632N/A SDRenderType renderType;
4632N/A
4632N/A // rdar://problem/5214320
4632N/A // Gradient/Texture fills of Java GeneralPath don't respect the even odd winding rule (quartz pipeline).
4632N/A BOOL isEvenOddFill; // Tracks whether the original render type passed into
4632N/A // SetUpCGContext(...) is SD_EOFILL.
4632N/A // The reason for this field is because SetUpCGContext(...) can
4632N/A // change the render type after calling SetUpPaint(...), and right
4632N/A // after that, the possibly new render type is then assigned into
4632N/A // qsdo->renderType. Sigh!!!
4632N/A // This field is potentially used within CompleteCGContext(...) or
4632N/A // its callees.
4632N/A
4632N/A StateShadingInfo* shadingInfo; // tracks shading and its parameters
4632N/A StatePatternInfo* patternInfo; // tracks pattern and its parameters
4632N/A StateGraphicsInfo graphicsStateInfo; // tracks other graphics state
4632N/A
4632N/A BOOL syncContentsToLayer; // should changed pixels be synced to a CALayer
4632N/A CGRect updateRect; // used by the layer synchronization code to track update rects.
4632N/A};
4632N/A
4632N/Avoid SetUpCGContext(JNIEnv *env, QuartzSDOps *qsdo, SDRenderType renderType);
4632N/ASDRenderType DoShapeUsingCG(CGContextRef cgRef, jint *types, jfloat *coords, jint numtypes, BOOL fill, CGFloat offsetX, CGFloat offsetY);
4632N/ASDRenderType SetUpPaint(JNIEnv *env, QuartzSDOps *qsdo, SDRenderType renderType);
4632N/Avoid CompleteCGContext(JNIEnv *env, QuartzSDOps *qsdo);
4632N/A
4632N/ANSColor* ByteParametersToNSColor(JNIEnv* env, jint *javaGraphicsStates, NSColor* defColor);
4632N/A
4632N/A#define JNF_COCOA_RENDERER_EXIT(env) \
4632N/A} @catch(NSException *localException) { \
4632N/A qsdo->FinishSurface(env, qsdo); \
4632N/A [JNFException throwToJava:env exception:localException]; \
4632N/A} \
4632N/A if (_token) JNFNativeMethodExit(_token); \
4632N/A}