Path: blob/master/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/EncoderManager.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 EncoderManager_h_Included26#define EncoderManager_h_Included2728#import <Metal/Metal.h>2930#include "RenderOptions.h"3132@class MTLContex;3334/**35* The EncoderManager class used to obtain MTLRenderCommandEncoder (or MTLBlitCommandEncoder) corresponding36* to the current state of MTLContext.37*38* Due to performance issues (creation of MTLRenderCommandEncoder isn't cheap), each getXXXEncoder invocation39* updates properties of common (cached) encoder and returns this encoder.40*41* Base method getEncoder does the following:42* 1. Checks whether common encoder must be closed and recreated (some of encoder properties is 'persistent',43* for example destination, stencil, or any other property of MTLRenderPassDescriptor)44* 2. Updates 'mutable' properties encoder: pipelineState (with corresponding buffers), clip, transform, e.t.c. To avoid45* unnecessary calls of [encoder setXXX] this manager compares requested state with cached one.46*/47@interface EncoderManager : NSObject48- (id _Nonnull)init;49- (void)dealloc;5051- (void)setContext:(MTLContex * _Nonnull)mtlc;5253// returns encoder that renders/fills geometry with current paint and composite54- (id<MTLRenderCommandEncoder> _Nonnull)getRenderEncoder:(const BMTLSDOps * _Nonnull)dstOps;5556- (id<MTLRenderCommandEncoder> _Nonnull)getAARenderEncoder:(const BMTLSDOps * _Nonnull)dstOps;5758- (id<MTLRenderCommandEncoder> _Nonnull)getRenderEncoder:(id<MTLTexture> _Nonnull)dest59isDstOpaque:(bool)isOpaque;6061- (id<MTLRenderCommandEncoder> _Nonnull)getAAShaderRenderEncoder:(const BMTLSDOps * _Nonnull)dstOps;6263// returns encoder that renders/fills geometry with current composite and with given texture64// (user must call [encoder setFragmentTexture] before any rendering)65- (id<MTLRenderCommandEncoder> _Nonnull)getTextureEncoder:(const BMTLSDOps * _Nonnull)dstOps66isSrcOpaque:(bool)isSrcOpaque;6768- (id<MTLRenderCommandEncoder> _Nonnull) getTextureEncoder:(id<MTLTexture> _Nonnull)dest69isSrcOpaque:(bool)isSrcOpaque70isDstOpaque:(bool)isDstOpaque;7172- (id<MTLRenderCommandEncoder> _Nonnull) getLCDEncoder:(id<MTLTexture> _Nonnull)dest73isSrcOpaque:(bool)isSrcOpaque74isDstOpaque:(bool)isDstOpaque;7576- (id<MTLRenderCommandEncoder> _Nonnull)getTextureEncoder:(id<MTLTexture> _Nonnull)dest77isSrcOpaque:(bool)isSrcOpaque78isDstOpaque:(bool)isDstOpaque79interpolation:(int)interpolation;8081- (id<MTLRenderCommandEncoder> _Nonnull)getTextureEncoder:(id<MTLTexture> _Nonnull)dest82isSrcOpaque:(bool)isSrcOpaque83isDstOpaque:(bool)isDstOpaque84interpolation:(int)interpolation85isAA:(jboolean)isAA;8687- (id<MTLRenderCommandEncoder> _Nonnull)getTextEncoder:(const BMTLSDOps * _Nonnull)dstOps88isSrcOpaque:(bool)isSrcOpaque;8990// Base method to obtain any MTLRenderCommandEncoder91- (id<MTLRenderCommandEncoder> _Nonnull) getEncoder:(id<MTLTexture> _Nonnull)dest92isDestOpaque:(jboolean)isDestOpaque93renderOptions:(const RenderOptions * _Nonnull)renderOptions;9495- (id<MTLBlitCommandEncoder> _Nonnull)createBlitEncoder;9697- (void)endEncoder;98@end99100#endif // EncoderManager_h_Included101102103