Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
ygopro
Commits
fb4737c6
Commit
fb4737c6
authored
May 05, 2025
by
mercury233
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update imageScaleNNAA, add OpenMP
parent
50d5877f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
27 deletions
+31
-27
gframe/image_manager.cpp
gframe/image_manager.cpp
+30
-27
gframe/premake5.lua
gframe/premake5.lua
+1
-0
No files found.
gframe/image_manager.cpp
View file @
fb4737c6
#include "image_manager.h"
#include "image_manager.h"
#include "game.h"
#include "game.h"
#include <thread>
#include <thread>
#ifdef _OPENMP
#include <omp.h>
#endif
namespace
ygo
{
namespace
ygo
{
...
@@ -128,25 +131,27 @@ void ImageManager::ResizeTexture() {
...
@@ -128,25 +131,27 @@ void ImageManager::ResizeTexture() {
}
}
// function by Warr1024, from https://github.com/minetest/minetest/issues/2419 , modified
// function by Warr1024, from https://github.com/minetest/minetest/issues/2419 , modified
void
imageScaleNNAA
(
irr
::
video
::
IImage
*
src
,
irr
::
video
::
IImage
*
dest
)
{
void
imageScaleNNAA
(
irr
::
video
::
IImage
*
src
,
irr
::
video
::
IImage
*
dest
)
{
double
sx
,
sy
,
minsx
,
maxsx
,
minsy
,
maxsy
,
area
,
ra
,
ga
,
ba
,
aa
,
pw
,
ph
,
pa
;
const
irr
::
core
::
dimension2d
<
irr
::
u32
>
srcDim
=
src
->
getDimension
();
irr
::
u32
dy
,
dx
;
const
irr
::
core
::
dimension2d
<
irr
::
u32
>
destDim
=
dest
->
getDimension
();
irr
::
video
::
SColor
pxl
;
// Cache
rectsngle boundarie
s.
// Cache
scale ratio
s.
double
sw
=
src
->
getDimension
().
Width
*
1.0
;
const
double
rx
=
(
double
)
srcDim
.
Width
/
destDim
.
Width
;
double
sh
=
src
->
getDimension
().
Height
*
1.0
;
const
double
ry
=
(
double
)
srcDim
.
Height
/
destDim
.
Height
;
// Walk each destination image pixel.
#pragma omp parallel
// Note: loop y around x for better cache locality.
{
irr
::
core
::
dimension2d
<
irr
::
u32
>
dim
=
dest
->
getDimension
();
double
sx
,
sy
,
minsx
,
maxsx
,
minsy
,
maxsy
,
area
,
ra
,
ga
,
ba
,
aa
,
pw
,
ph
,
pa
;
for
(
dy
=
0
;
dy
<
dim
.
Height
;
dy
++
)
irr
::
video
::
SColor
pxl
,
npxl
;
for
(
dx
=
0
;
dx
<
dim
.
Width
;
dx
++
)
{
// Walk each destination image pixel.
#pragma omp for schedule(dynamic)
for
(
irr
::
s32
dy
=
0
;
dy
<
destDim
.
Height
;
dy
++
)
{
for
(
irr
::
s32
dx
=
0
;
dx
<
destDim
.
Width
;
dx
++
)
{
// Calculate floating-point source rectangle bounds.
// Calculate floating-point source rectangle bounds.
minsx
=
dx
*
sw
/
dim
.
Width
;
minsx
=
dx
*
rx
;
maxsx
=
minsx
+
sw
/
dim
.
Width
;
maxsx
=
minsx
+
rx
;
minsy
=
dy
*
sh
/
dim
.
Height
;
minsy
=
dy
*
ry
;
maxsy
=
minsy
+
sh
/
dim
.
Height
;
maxsy
=
minsy
+
ry
;
// Total area, and integral of r, g, b values over that area,
// Total area, and integral of r, g, b values over that area,
// initialized to zero, to be summed up in next loops.
// initialized to zero, to be summed up in next loops.
...
@@ -157,9 +162,8 @@ void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) {
...
@@ -157,9 +162,8 @@ void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) {
aa
=
0
;
aa
=
0
;
// Loop over the integral pixel positions described by those bounds.
// Loop over the integral pixel positions described by those bounds.
for
(
sy
=
floor
(
minsy
);
sy
<
maxsy
;
sy
++
)
for
(
sy
=
floor
(
minsy
);
sy
<
maxsy
;
sy
++
)
{
for
(
sx
=
floor
(
minsx
);
sx
<
maxsx
;
sx
++
)
{
for
(
sx
=
floor
(
minsx
);
sx
<
maxsx
;
sx
++
)
{
// Calculate width, height, then area of dest pixel
// Calculate width, height, then area of dest pixel
// that's covered by this source pixel.
// that's covered by this source pixel.
pw
=
1
;
pw
=
1
;
...
@@ -183,21 +187,20 @@ void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) {
...
@@ -183,21 +187,20 @@ void imageScaleNNAA(irr::video::IImage *src, irr::video::IImage *dest) {
ba
+=
pa
*
pxl
.
getBlue
();
ba
+=
pa
*
pxl
.
getBlue
();
aa
+=
pa
*
pxl
.
getAlpha
();
aa
+=
pa
*
pxl
.
getAlpha
();
}
}
}
// Set the destination image pixel to the average color.
// Set the destination image pixel to the average color.
if
(
area
>
0
)
{
if
(
area
>
0
)
{
pxl
.
setRed
(
ra
/
area
+
0.5
);
npxl
.
set
((
irr
::
u32
)(
aa
/
area
+
0.5
),
pxl
.
setGreen
(
ga
/
area
+
0.5
);
(
irr
::
u32
)(
ra
/
area
+
0.5
),
pxl
.
setBlue
(
ba
/
area
+
0.5
);
(
irr
::
u32
)(
ga
/
area
+
0.5
),
pxl
.
setAlpha
(
aa
/
area
+
0.5
);
(
irr
::
u32
)(
ba
/
area
+
0.5
)
);
}
else
{
}
else
{
pxl
.
setRed
(
0
);
npxl
.
set
(
0
);
pxl
.
setGreen
(
0
);
pxl
.
setBlue
(
0
);
pxl
.
setAlpha
(
0
);
}
}
dest
->
setPixel
(
dx
,
dy
,
pxl
);
dest
->
setPixel
(
dx
,
dy
,
n
pxl
);
}
}
}
}
// end of parallel region
}
}
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureFromFile
(
const
char
*
file
,
irr
::
s32
width
,
irr
::
s32
height
)
{
irr
::
video
::
ITexture
*
ImageManager
::
GetTextureFromFile
(
const
char
*
file
,
irr
::
s32
width
,
irr
::
s32
height
)
{
if
(
mainGame
->
gameConf
.
use_image_scale
)
{
if
(
mainGame
->
gameConf
.
use_image_scale
)
{
...
...
gframe/premake5.lua
View file @
fb4737c6
...
@@ -5,6 +5,7 @@ project "YGOPro"
...
@@ -5,6 +5,7 @@ project "YGOPro"
kind
"WindowedApp"
kind
"WindowedApp"
cppdialect
"C++14"
cppdialect
"C++14"
rtti
"Off"
rtti
"Off"
openmp
"On"
files
{
"*.cpp"
,
"*.h"
}
files
{
"*.cpp"
,
"*.h"
}
includedirs
{
"../ocgcore"
}
includedirs
{
"../ocgcore"
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment