Skip to content

Commit

Permalink
Revert "SkJpegCodec: Add SkJpegSourceMgr"
Browse files Browse the repository at this point in the history
This reverts commit 7d0c572.

Reason for revert: Chrome roller failing

Original change's description:
> SkJpegCodec: Add SkJpegSourceMgr
>
> The current skjpeg_source_mgr (in SkJpegUtility.cpp/h) is effectively
> two implementations (buffered vs in-memory) controlled via if
> statements.
>
> Turn these into two implementations of a pure virtual interface
> SkJpegSourceMgr. The reason for this it that there will be a third
> interface added for buffered non-seekable sources (which will
> run an SkJpegSegmentScanner on the data as it is read).
>
> Leave the pre-existing skjpeg_source_mgr in place because it may
> be used in other places. It will be removed separately.
>
> Bug: skia:14031
> Change-Id: Iae87c0da307dfec50c95168c50486c807d335526
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/633461
> Reviewed-by: Brian Osman <[email protected]>
> Commit-Queue: Christopher Cameron <[email protected]>

Bug: skia:14031
Change-Id: I55e020bdcae3ba557f2e90fab9d150ec47f22921
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/635576
Auto-Submit: Brian Osman <[email protected]>
Commit-Queue: Rubber Stamper <[email protected]>
Bot-Commit: Rubber Stamper <[email protected]>
  • Loading branch information
brianosman authored and SkCQ committed Jan 30, 2023
1 parent 86b7e4b commit 9b3a9f2
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 222 deletions.
1 change: 0 additions & 1 deletion BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1208,7 +1208,6 @@ optional("jpeg_decode") {
sources = [
"src/codec/SkJpegCodec.cpp",
"src/codec/SkJpegDecoderMgr.cpp",
"src/codec/SkJpegSourceMgr.cpp",
"src/codec/SkJpegUtility.cpp",
]
if (skia_use_jpeg_gainmaps) {
Expand Down
2 changes: 0 additions & 2 deletions src/codec/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ DECODE_JPEG_FILES = [
"SkJpegCodec.h",
"SkJpegDecoderMgr.cpp",
"SkJpegDecoderMgr.h",
"SkJpegSourceMgr.cpp",
"SkJpegSourceMgr.h",
"SkJpegUtility.cpp",
"SkJpegUtility.h",
"SkParseEncodedOrigin.cpp",
Expand Down
60 changes: 3 additions & 57 deletions src/codec/SkJpegDecoderMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,12 @@
#include "src/codec/SkJpegDecoderMgr.h"

#include "src/codec/SkCodecPriv.h"
#include "src/codec/SkJpegSourceMgr.h"
#include "src/codec/SkJpegUtility.h"

#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
#include "include/android/SkAndroidFrameworkUtils.h"
#endif

#include <cstddef>
#include <utility>

class SkStream;

/*
Expand Down Expand Up @@ -46,9 +42,6 @@ static void progress_monitor(j_common_ptr info) {
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// JpegDecoderMgr

bool JpegDecoderMgr::returnFalse(const char caller[]) {
print_message((j_common_ptr) &fDInfo, caller);
return false;
Expand Down Expand Up @@ -84,12 +77,10 @@ bool JpegDecoderMgr::getEncodedColor(SkEncodedInfo::Color* outColor) {
}
}

SkJpegSourceMgr* JpegDecoderMgr::getSourceMgr() {
return fSrcMgr.fSourceMgr.get();
}

JpegDecoderMgr::JpegDecoderMgr(SkStream* stream)
: fSrcMgr(SkJpegSourceMgr::Make(stream)), fInit(false) {
: fSrcMgr(stream)
, fInit(false)
{
// Error manager must be set before any calls to libjeg in order to handle failures
fDInfo.err = jpeg_std_error(&fErrorMgr);
fErrorMgr.error_exit = skjpeg_err_exit;
Expand All @@ -109,48 +100,3 @@ JpegDecoderMgr::~JpegDecoderMgr() {
jpeg_destroy_decompress(&fDInfo);
}
}

////////////////////////////////////////////////////////////////////////////////////////////////////
// JpegDecoderMgr::SourceMgr

// static
void JpegDecoderMgr::SourceMgr::InitSource(j_decompress_ptr dinfo) {
JpegDecoderMgr::SourceMgr* src = (JpegDecoderMgr::SourceMgr*)dinfo->src;
src->fSourceMgr->initSource(src->next_input_byte, src->bytes_in_buffer);
}

// static
void JpegDecoderMgr::SourceMgr::SkipInputData(j_decompress_ptr dinfo, long num_bytes_long) {
JpegDecoderMgr::SourceMgr* src = (JpegDecoderMgr::SourceMgr*)dinfo->src;
size_t num_bytes = static_cast<size_t>(num_bytes_long);
if (!src->fSourceMgr->skipInputBytes(num_bytes, src->next_input_byte, src->bytes_in_buffer)) {
SkCodecPrintf("Failure to skip.\n");
src->next_input_byte = nullptr;
src->bytes_in_buffer = 0;
dinfo->err->error_exit((j_common_ptr)dinfo);
}
}

// static
boolean JpegDecoderMgr::SourceMgr::FillInputBuffer(j_decompress_ptr dinfo) {
JpegDecoderMgr::SourceMgr* src = (JpegDecoderMgr::SourceMgr*)dinfo->src;
if (!src->fSourceMgr->fillInputBuffer(src->next_input_byte, src->bytes_in_buffer)) {
SkCodecPrintf("Failure to fill input buffer.\n");
src->next_input_byte = nullptr;
src->bytes_in_buffer = 0;
return false;
}
return true;
}

// static
void JpegDecoderMgr::SourceMgr::TermSource(j_decompress_ptr dinfo) {}

JpegDecoderMgr::SourceMgr::SourceMgr(std::unique_ptr<SkJpegSourceMgr> sourceMgr)
: fSourceMgr(std::move(sourceMgr)) {
init_source = JpegDecoderMgr::SourceMgr::InitSource;
fill_input_buffer = JpegDecoderMgr::SourceMgr::FillInputBuffer;
skip_input_data = JpegDecoderMgr::SourceMgr::SkipInputData;
resync_to_restart = jpeg_resync_to_restart;
term_source = JpegDecoderMgr::SourceMgr::TermSource;
}
20 changes: 2 additions & 18 deletions src/codec/SkJpegDecoderMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,12 @@
#include "include/private/SkEncodedInfo.h"
#include "include/private/base/SkNoncopyable.h"
#include "src/codec/SkJpegPriv.h"
#include "src/codec/SkJpegSourceMgr.h"
#include "src/codec/SkJpegUtility.h"

extern "C" {
#include "jpeglib.h"
#include "jmorecfg.h"
}

#include <memory>

class SkStream;

class JpegDecoderMgr : SkNoncopyable {
Expand Down Expand Up @@ -69,23 +66,10 @@ class JpegDecoderMgr : SkNoncopyable {
*/
jpeg_decompress_struct* dinfo() { return &fDInfo; }

// Get the source manager.
SkJpegSourceMgr* getSourceMgr();

private:
// Wrapper that calls into the full SkJpegSourceMgr interface.
struct SourceMgr : jpeg_source_mgr {
static void InitSource(j_decompress_ptr dinfo);
static void SkipInputData(j_decompress_ptr dinfo, long num_bytes_long);
static boolean FillInputBuffer(j_decompress_ptr dinfo);
static void TermSource(j_decompress_ptr dinfo);

SourceMgr(std::unique_ptr<SkJpegSourceMgr> mgr);
std::unique_ptr<SkJpegSourceMgr> fSourceMgr;
};

jpeg_decompress_struct fDInfo;
SourceMgr fSrcMgr;
skjpeg_source_mgr fSrcMgr;
skjpeg_error_mgr fErrorMgr;
jpeg_progress_mgr fProgressMgr;
bool fInit;
Expand Down
110 changes: 0 additions & 110 deletions src/codec/SkJpegSourceMgr.cpp

This file was deleted.

34 changes: 0 additions & 34 deletions src/codec/SkJpegSourceMgr.h

This file was deleted.

0 comments on commit 9b3a9f2

Please sign in to comment.