add a scanner, but this seems to be a wrong solution. Change open-source head

This commit is contained in:
Youmu Liu
2026-07-07 18:20:38 +08:00
parent b053567eb7
commit 1705d7c245
276 changed files with 3468 additions and 7205 deletions
+25 -36
View File
@@ -1,30 +1,10 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------------
// file="AutoTexture"
// Project: StgSharp
// AuthorGroup: Nitload
// Copyright (c) Nitload. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// Copyright (c) Nitload.
// SPDX-License-Identifier: MIT
// -----------------------------------------------------------------------------
using StgSharp.Collections;
using StgSharp.Graphics;
using System;
@@ -40,9 +20,9 @@ namespace StgSharp.Graphics.OpenGL
{
/// <summary>
/// A collection of a sets of OpenGL textures. The collection can automatically select one of
/// the texture with minimum costs to upgrade pixels to BufferHandle. Usually <see
/// the texture with minimum costs to upgrade pixels to BufferHandle. Usually <see ///
/// cref="AutoTextureGL" /> is used for <see cref="IImageProvider" /> loading, but not for
/// target of <see cref="OpenGLFunction.FrameBufferTexture2d(FrameBufferTarget, uint,
/// target of <see cref="OpenGLFunction.FrameBufferTexture2d(FrameBufferTarget, uint, ///
/// Texture2DTarget, GlHandle, int)" />.
/// </summary>
public sealed class AutoTextureGL
@@ -60,7 +40,9 @@ namespace StgSharp.Graphics.OpenGL
private TextureProperty _textureProperty;
private AutoTextureGL(TextureGL texture)
private AutoTextureGL(
TextureGL texture
)
{
texturePackage = texture;
_size = texture.Count;
@@ -70,7 +52,10 @@ namespace StgSharp.Graphics.OpenGL
propertyCache = new TextureProperty[_size];
}
public AutoTextureGL(int textureObjectSize, [NotNull]glRender binding)
public AutoTextureGL(
int textureObjectSize,
[NotNull]glRender binding
)
{
this._size = textureObjectSize;
imageIndexMap = new BidirectionalDictionary<Image, int>();
@@ -86,20 +71,22 @@ namespace StgSharp.Graphics.OpenGL
set => _textureProperty = value;
}
private OpenGLFunction GL
{
get => texturePackage.GL;
}
private OpenGLFunction GL => texturePackage.GL;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void SelectTextureAndBind(Image i)
public void SelectTextureAndBind(
Image i
)
{
TextureProperty property = _textureProperty;
SelectTextureAndBind(i, property);
}
public void SelectTextureAndBind([NotNull]Image i, TextureProperty property)
public void SelectTextureAndBind(
[NotNull]Image i,
TextureProperty property
)
{
// usable texture with image match
if (imageIndexMap.TryGetValue(i, out int index))
@@ -148,7 +135,9 @@ namespace StgSharp.Graphics.OpenGL
}
}
public static AutoTextureGL ToAuto([NotNull]TextureGL texture)
public static AutoTextureGL ToAuto(
[NotNull]TextureGL texture
)
{
if (texture.IndexOfCurrentTexture != -1) {
throw new InvalidOperationException("Texture to be converted has been editted.");