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
Open sidebar
halo
external_skia
Commits
05427c28
Commit
05427c28
authored
15 years ago
by
Wei-Ta Chen
Browse files
Options
Download
Email Patches
Plain Diff
Fix
http://b/2154737
by setting the size of memory buffer used for jpeg decode in Skia.
parent
ea8eb95a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
src/images/SkImageDecoder_libjpeg.cpp
src/images/SkImageDecoder_libjpeg.cpp
+27
-0
No files found.
src/images/SkImageDecoder_libjpeg.cpp
View file @
05427c28
...
...
@@ -29,6 +29,13 @@ extern "C" {
#include "jerror.h"
}
#ifdef ANDROID
#include <cutils/properties.h>
// Key to lookup the size of memory buffer set in system property
static
const
char
KEY_MEM_CAP
[]
=
"ro.media.dec.jpeg.memcap"
;
#endif
// this enables timing code to report milliseconds for an encode
//#define TIME_ENCODE
//#define TIME_DECODE
...
...
@@ -191,6 +198,22 @@ static boolean skmem_resync_to_restart(j_decompress_ptr cinfo, int desired) {
static
void
skmem_term_source
(
j_decompress_ptr
/*cinfo*/
)
{}
#ifdef ANDROID
/* Check if the memory cap property is set.
If so, use the memory size for jpeg decode.
*/
static
void
overwrite_mem_buffer_size
(
j_decompress_ptr
cinfo
)
{
int
len
=
0
;
char
value
[
PROPERTY_VALUE_MAX
];
int
memCap
;
len
=
property_get
(
KEY_MEM_CAP
,
value
,
""
);
if
(
len
>
0
&&
sscanf
(
value
,
"%d"
,
&
memCap
)
==
1
)
{
cinfo
->
mem
->
max_memory_to_use
=
memCap
;
}
}
#endif
///////////////////////////////////////////////////////////////////////////////
sk_source_mgr
::
sk_source_mgr
(
SkStream
*
stream
,
SkImageDecoder
*
decoder
)
:
fStream
(
stream
)
{
...
...
@@ -286,6 +309,10 @@ bool SkJPEGImageDecoder::onDecode(SkStream* stream, SkBitmap* bm,
jpeg_create_decompress
(
&
cinfo
);
autoClean
.
set
(
&
cinfo
);
#ifdef ANDROID
overwrite_mem_buffer_size
(
&
cinfo
);
#endif
//jpeg_stdio_src(&cinfo, file);
cinfo
.
src
=
&
sk_stream
;
...
...
This diff is collapsed.
Click to expand it.
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