Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
gThumb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
91
Issues
91
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
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
GNOME
gThumb
Commits
69fe61d0
Commit
69fe61d0
authored
Jun 28, 2013
by
Paolo Bacchilega
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jpeg loader: cancel the image loading faster
added other points where the cancellable is checked
parent
b35be8c9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
26 deletions
+42
-26
extensions/cairo_io/cairo-image-surface-jpeg.c
extensions/cairo_io/cairo-image-surface-jpeg.c
+42
-26
No files found.
extensions/cairo_io/cairo-image-surface-jpeg.c
View file @
69fe61d0
...
...
@@ -273,7 +273,7 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream,
while
(
srcinfo
.
output_scanline
<
srcinfo
.
output_height
)
{
if
(
g_cancellable_is_cancelled
(
cancellable
))
break
;
goto
stop_loading
;
n_lines
=
jpeg_read_scanlines
(
&
srcinfo
,
buffer
,
srcinfo
.
rec_outbuf_height
);
...
...
@@ -282,6 +282,9 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream,
p_surface
=
surface_row
;
p_buffer
=
buffer_row
[
l
];
if
(
g_cancellable_is_cancelled
(
cancellable
))
goto
stop_loading
;
for
(
x
=
0
;
x
<
srcinfo
.
output_width
;
x
++
)
{
if
(
srcinfo
.
saw_Adobe_marker
)
{
c
=
p_buffer
[
0
];
...
...
@@ -318,7 +321,7 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream,
{
while
(
srcinfo
.
output_scanline
<
srcinfo
.
output_height
)
{
if
(
g_cancellable_is_cancelled
(
cancellable
))
break
;
goto
stop_loading
;
n_lines
=
jpeg_read_scanlines
(
&
srcinfo
,
buffer
,
srcinfo
.
rec_outbuf_height
);
...
...
@@ -327,6 +330,9 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream,
p_surface
=
surface_row
;
p_buffer
=
buffer_row
[
l
];
if
(
g_cancellable_is_cancelled
(
cancellable
))
goto
stop_loading
;
for
(
x
=
0
;
x
<
srcinfo
.
output_width
;
x
++
)
{
r
=
g
=
b
=
p_buffer
[
0
];
pixel
=
CAIRO_RGBA_TO_UINT32
(
r
,
g
,
b
,
0xff
);
...
...
@@ -347,7 +353,7 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream,
{
while
(
srcinfo
.
output_scanline
<
srcinfo
.
output_height
)
{
if
(
g_cancellable_is_cancelled
(
cancellable
))
break
;
goto
stop_loading
;
n_lines
=
jpeg_read_scanlines
(
&
srcinfo
,
buffer
,
srcinfo
.
rec_outbuf_height
);
...
...
@@ -356,6 +362,9 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream,
p_surface
=
surface_row
;
p_buffer
=
buffer_row
[
l
];
if
(
g_cancellable_is_cancelled
(
cancellable
))
goto
stop_loading
;
for
(
x
=
0
;
x
<
srcinfo
.
output_width
;
x
++
)
{
r
=
p_buffer
[
0
];
g
=
p_buffer
[
1
];
...
...
@@ -391,7 +400,7 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream,
while
(
srcinfo
.
output_scanline
<
srcinfo
.
output_height
)
{
if
(
g_cancellable_is_cancelled
(
cancellable
))
break
;
goto
stop_loading
;
n_lines
=
jpeg_read_scanlines
(
&
srcinfo
,
buffer
,
srcinfo
.
rec_outbuf_height
);
...
...
@@ -400,6 +409,9 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream,
p_surface
=
surface_row
;
p_buffer
=
buffer_row
[
l
];
if
(
g_cancellable_is_cancelled
(
cancellable
))
goto
stop_loading
;
for
(
x
=
0
;
x
<
srcinfo
.
output_width
;
x
++
)
{
Y
=
p_buffer
[
0
];
Cb
=
p_buffer
[
1
];
...
...
@@ -443,7 +455,7 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream,
while
(
srcinfo
.
output_scanline
<
srcinfo
.
output_height
)
{
if
(
g_cancellable_is_cancelled
(
cancellable
))
break
;
goto
stop_loading
;
n_lines
=
jpeg_read_scanlines
(
&
srcinfo
,
buffer
,
srcinfo
.
rec_outbuf_height
);
...
...
@@ -452,6 +464,9 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream,
p_surface
=
surface_row
;
p_buffer
=
buffer_row
[
l
];
if
(
g_cancellable_is_cancelled
(
cancellable
))
goto
stop_loading
;
for
(
x
=
0
;
x
<
srcinfo
.
output_width
;
x
++
)
{
Y
=
p_buffer
[
0
];
Cb
=
p_buffer
[
1
];
...
...
@@ -491,24 +506,11 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream,
break
;
}
if
(
!
g_cancellable_is_cancelled
(
cancellable
))
{
cairo_surface_mark_dirty
(
surface
);
/* Scale to the requested size */
if
(
load_scaled
)
{
cairo_surface_t
*
scaled
;
int
width
;
int
height
;
stop_loading:
width
=
destination_width
;
height
=
destination_height
;
scale_keeping_ratio
(
&
width
,
&
height
,
requested_size
,
requested_size
,
TRUE
);
scaled
=
_cairo_image_surface_scale
(
surface
,
width
,
height
,
SCALE_FILTER_BEST
,
NULL
);
cairo_surface_mark_dirty
(
surface
);
cairo_surface_destroy
(
surface
);
surface
=
scaled
;
}
if
(
!
g_cancellable_is_cancelled
(
cancellable
))
{
/* Set the original dimensions */
...
...
@@ -528,18 +530,32 @@ _cairo_image_surface_create_from_jpeg (GInputStream *istream,
if
(
original_height
!=
NULL
)
*
original_height
=
srcinfo
.
image_height
;
}
jpeg_finish_decompress
(
&
srcinfo
);
jpeg_destroy_decompress
(
&
srcinfo
);
/* Scale to the requested size */
if
(
load_scaled
)
{
cairo_surface_t
*
scaled
;
int
width
;
int
height
;
width
=
destination_width
;
height
=
destination_height
;
scale_keeping_ratio
(
&
width
,
&
height
,
requested_size
,
requested_size
,
TRUE
);
scaled
=
_cairo_image_surface_scale
(
surface
,
width
,
height
,
SCALE_FILTER_BEST
,
NULL
);
cairo_surface_destroy
(
surface
);
surface
=
scaled
;
}
/*_cairo_image_surface_set_attribute_int (surface, "Image::Rotation", rotation); FIXME*/
/* FIXME _cairo_image_surface_set_attribute (surface, "Jpeg::ColorSpace", jpeg_color_space_name (srcinfo.jpeg_color_space)); */
gth_image_set_cairo_surface
(
image
,
surface
);
jpeg_finish_decompress
(
&
srcinfo
);
jpeg_destroy_decompress
(
&
srcinfo
);
}
else
{
jpeg_destroy
((
j_common_ptr
)
&
srcinfo
);
jpeg_destroy
_decompress
(
&
srcinfo
);
g_set_error_literal
(
error
,
G_IO_ERROR
,
G_IO_ERROR_CANCELLED
,
""
);
}
...
...
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