<commit_before>package com.serenegiant.gl;
/*
 * libcommon
 * utility/helper classes for myself
 *
 * Copyright (c) 2014-2022 saki <EMAIL>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
*/

import android.opengl.GLES20;
import android.opengl.Matrix;

import com.serenegiant.egl.EGLBase;
import com.serenegiant.glutils.IRendererCommon;
import com.serenegiant.system.Time;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Size;

/**
 * Surface等の描画先のオブジェクトと関係する設定を保持するためのホルダークラス
 * 同じ内容のクラスだったからEffectRendererHolder/RendererHolderのインナークラスを外に出した
 */
public class RendererTarget implements IRendererCommon {

	/**
	 * ファクトリーメソッド
	 * @param egl
	 * @param surface Surface/SurfaceHolder/SurfaceTexture/SurfaceView/TextureWrapper/IGLSurface/ISurfaceのいずれかまたはその子クラス
	 * @param maxFps 0以下なら最大描画フレームレート制限なし, あまり正確じゃない
	 * @return
	 */
	public static RendererTarget newInstance(
		@NonNull final EGLBase egl,
		@NonNull final Object surface, final float maxFps) {

		return (maxFps > 0)
			? new RendererTargetHasWait(egl, surface, maxFps)
			: new RendererTarget(egl, surface);	// no limitation of maxFps
	}

	/** 元々の分配描画用Surface */
	private Object mSurface;
	private final boolean mOwnSurface;
	/** 分配描画用Surfaceを元に生成したOpenGL|ESで描画する為のEglSurface */
	private ISurface mTargetSurface;
	@Size(min=16)
	@NonNull
	private final float[] mMvpMatrix = new float[16];
	private volatile boolean mEnable = true;
	@MirrorMode
	private int mMirror = MIRROR_NORMAL;

	/**
	 * コンストラクタ, ファクトリーメソッドの使用を強制するためprotected
	 * @param egl
	 * @param surface Surface/SurfaceHolder/SurfaceTexture/SurfaceView/TextureWrapper/IGLSurface/ISurfaceのいずれかまたはその子クラス
	 */
	protected RendererTarget(@NonNull final EGLBase egl, @NonNull final Object surface) {
		mSurface = surface;
		if (surface instanceof ISurface) {	// IGLSurfaceはISurfaceの子なのでここに含む
			mTargetSurface = (ISurface)surface;
			mOwnSurface = false;
		} else if (surface instanceof TextureWrapper) {
			final TextureWrapper wrapper = (TextureWrapper)surface;
			mTargetSurface = GLSurface.wrap(egl.isGLES3(),
				wrapper.texTarget,
				wrapper.texUnit, wrapper.texId, wrapper.width, wrapper.height, false);
			mOwnSurface = true;
		} else {<commit_msg>改行を修正<commit_after>package com.serenegiant.gl;
/*
 * libcommon
 * utility/helper classes for myself
 *
 * Copyright (c) 2014-2022 saki <EMAIL>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
*/

import android.opengl.GLES20;
import android.opengl.Matrix;

import com.serenegiant.egl.EGLBase;
import com.serenegiant.glutils.IRendererCommon;
import com.serenegiant.system.Time;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.Size;

/**
 * Surface等の描画先のオブジェクトと関係する設定を保持するためのホルダークラス
 * 同じ内容のクラスだったからEffectRendererHolder/RendererHolderのインナークラスを外に出した
 */
public class RendererTarget implements IRendererCommon {

	/**
	 * ファクトリーメソッド
	 * @param egl
	 * @param surface Surface/SurfaceHolder/SurfaceTexture/SurfaceView/TextureWrapper/IGLSurface/ISurfaceのいずれかまたはその子クラス
	 * @param maxFps 0以下なら最大描画フレームレート制限なし, あまり正確じゃない
	 * @return
	 */
	public static RendererTarget newInstance(
		@NonNull final EGLBase egl,
		@NonNull final Object surface, final float maxFps) {

		return (maxFps > 0)
			? new RendererTargetHasWait(egl, surface, maxFps)
			: new RendererTarget(egl, surface);	// no limitation of maxFps
	}

	/** 元々の分配描画用Surface */
	private Object mSurface;
	private final boolean mOwnSurface;
	/** 分配描画用Surfaceを元に生成したOpenGL|ESで描画する為のEglSurface */
	private ISurface mTargetSurface;
	@Size(min=16)
	@NonNull
	private final float[] mMvpMatrix = new float[16];
	private volatile boolean mEnable = true;
	@MirrorMode
	private int mMirror = MIRROR_NORMAL;

	/**
	 * コンストラクタ, ファクトリーメソッドの使用を強制するためprotected
	 * @param egl
	 * @param surface Surface/SurfaceHolder/SurfaceTexture/SurfaceView/TextureWrapper/IGLSurface/ISurfaceのいずれかまたはその子クラス
	 */
	protected RendererTarget(@NonNull final EGLBase egl, @NonNull final Object surface) {
		mSurface = surface;
		if (surface instanceof ISurface) {	// IGLSurfaceはISurfaceの子なのでここに含む
			mTargetSurface = (ISurface)surface;
			mOwnSurface = false;
		} else if (surface instanceof TextureWrapper) {
			final TextureWrapper wrapper = (TextureWrapper)surface;
			mTargetSurface = GLSurface.wrap(egl.isGLES3(),
				wrapper.texTarget, wrapper.texUnit, wrapper.texId,
				wrapper.width, wrapper.height, false);
			mOwnSurface = true;
		} else {
{'fraction_non_alphanumeric': 0.08519195612431445, 'fraction_numerical': 0.007678244972577696, 'mean_word_length': 4.728795811518324, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4439284', 'n_tokens_mistral': 2043, 'n_tokens_neox': 1917, 'n_words': 460}