Skip to content

Commit eb5f21e

Browse files
rphilliSkCQ
authored andcommitted
Revert "[rust png] Extract minimal SkPngCodecBase."
This reverts commit df5bc81. Reason for revert: Appears to be blocking Skia's roll into Flutter with: wasm-ld: error: canvaskit/obj/flutter/third_party/skia/src/codec/png_decode.SkPngCodec.o: undefined symbol: SkPngCodecBase::SkPngCodecBase(SkEncodedInfo&&, skcms_PixelFormat, std::__2::unique_ptr<SkStream, std::__2::default_delete<SkStream>>) wasm-ld: error: canvaskit/obj/flutter/third_party/skia/src/codec/png_decode.SkPngCodec.o: undefined symbol: SkPngCodecBase::SkPngCodecBase(SkEncodedInfo&&, skcms_PixelFormat, std::__2::unique_ptr<SkStream, std::__2::default_delete<SkStream>>) wasm-ld: error: canvaskit/obj/flutter/third_party/skia/src/codec/png_decode.SkPngCodec.o: undefined symbol: SkPngCodecBase::~SkPngCodecBase() wasm-ld: error: canvaskit/obj/flutter/third_party/skia/src/codec/png_decode.SkPngCodec.o: undefined symbol: SkPngCodecBase::onGetEncodedFormat() const wasm-ld: error: canvaskit/obj/flutter/third_party/skia/src/codec/png_decode.SkPngCodec.o: undefined symbol: SkPngCodecBase::onGetEncodedFormat() const wasm-ld: error: canvaskit/obj/flutter/third_party/skia/src/codec/png_decode.SkPngCodec.o: undefined symbol: SkPngCodecBase::onGetEncodedFormat() const Original change's description: > [rust png] Extract minimal `SkPngCodecBase`. > > This CL extracts a minimal `SkPngCodecBase` - a common base class > of `SkPngCodec` and `SkPngRustCodec` with functionality shared by both > of these derived classes. > > Bug: chromium:356879515 > Change-Id: I05508e61c278784c9800145eb7829845f5967dd2 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/888477 > Commit-Queue: Łukasz Anforowicz <[email protected]> > Reviewed-by: Leon Scroggins <[email protected]> Bug: chromium:356879515 Change-Id: I3df12f32093f3f69c38231f3246a06d7514b80d3 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://skia-review.googlesource.com/c/skia/+/891596 Auto-Submit: Robert Phillips <[email protected]> Commit-Queue: Rubber Stamper <[email protected]> Bot-Commit: Rubber Stamper <[email protected]>
1 parent df5bc81 commit eb5f21e

File tree

8 files changed

+53
-113
lines changed

8 files changed

+53
-113
lines changed

experimental/rust_png/impl/SkPngRustCodec.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,15 @@ std::unique_ptr<SkPngRustCodec> SkPngRustCodec::MakeFromStream(std::unique_ptr<S
152152
SkPngRustCodec::SkPngRustCodec(SkEncodedInfo&& encodedInfo,
153153
std::unique_ptr<SkStream> stream,
154154
rust::Box<rust_png::Reader> reader)
155-
: SkPngCodecBase(std::move(encodedInfo), kInvalidSkcmsPixelFormat, std::move(stream))
155+
: SkCodec(std::move(encodedInfo), kInvalidSkcmsPixelFormat, std::move(stream))
156156
, fReader(std::move(reader)) {}
157157

158158
SkPngRustCodec::~SkPngRustCodec() = default;
159159

160+
SkEncodedImageFormat SkPngRustCodec::onGetEncodedFormat() const {
161+
return SkEncodedImageFormat::kPNG;
162+
}
163+
160164
SkCodec::Result SkPngRustCodec::onGetPixels(const SkImageInfo& dstInfo,
161165
void* dst,
162166
size_t rowBytes,

experimental/rust_png/impl/SkPngRustCodec.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@
1010
#include <memory>
1111

1212
#include "experimental/rust_png/ffi/FFI.rs.h"
13-
#include "src/codec/SkPngCodecBase.h"
13+
#include "include/codec/SkCodec.h"
14+
#include "include/codec/SkEncodedImageFormat.h"
1415
#include "third_party/rust/cxx/v1/cxx.h"
1516

1617
struct SkEncodedInfo;
@@ -21,7 +22,7 @@ class SkStream;
2122
// Rust)
2223
// * Skia's `SkSwizzler` and `skcms_Transform` (pixel format and color space
2324
// transformations implemented in C++).
24-
class SkPngRustCodec : public SkPngCodecBase {
25+
class SkPngRustCodec : public SkCodec {
2526
public:
2627
static std::unique_ptr<SkPngRustCodec> MakeFromStream(std::unique_ptr<SkStream>, Result*);
2728

@@ -32,6 +33,7 @@ class SkPngRustCodec : public SkPngCodecBase {
3233

3334
private:
3435
// SkCodec overrides:
36+
SkEncodedImageFormat onGetEncodedFormat() const override;
3537
Result onGetPixels(const SkImageInfo& info,
3638
void* pixels,
3739
size_t rowBytes,

gn/codec.gni

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,5 @@ skia_codec_jpeg_xmp = [
100100
skia_codec_png = [
101101
"$_src/codec/SkPngCodec.cpp",
102102
"$_src/codec/SkPngCodec.h",
103-
"$_src/codec/SkPngCodecBase.cpp",
104-
"$_src/codec/SkPngCodecBase.h",
105103
"$_src/codec/SkPngPriv.h",
106104
]

src/codec/BUILD.bazel

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,6 @@ skia_filegroup(
532532
srcs = [
533533
"SkPngCodec.cpp",
534534
"SkPngCodec.h",
535-
"SkPngCodecBase.cpp",
536-
"SkPngCodecBase.h",
537535
],
538536
)
539537

src/codec/SkPngCodec.cpp

Lines changed: 35 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -508,18 +508,15 @@ static SkCodec::Result log_and_return_error(bool success) {
508508

509509
class SkPngNormalDecoder : public SkPngCodec {
510510
public:
511-
SkPngNormalDecoder(SkEncodedInfo&& info,
512-
std::unique_ptr<SkStream> stream,
513-
SkPngChunkReader* reader,
514-
png_structp png_ptr,
515-
png_infop info_ptr,
516-
int bitDepth)
517-
: SkPngCodec(std::move(info), std::move(stream), reader, png_ptr, info_ptr, bitDepth)
518-
, fRowsWrittenToOutput(0)
519-
, fDst(nullptr)
520-
, fRowBytes(0)
521-
, fFirstRow(0)
522-
, fLastRow(0) {}
511+
SkPngNormalDecoder(SkEncodedInfo&& info, std::unique_ptr<SkStream> stream,
512+
SkPngChunkReader* reader, png_structp png_ptr, png_infop info_ptr, int bitDepth)
513+
: INHERITED(std::move(info), std::move(stream), reader, png_ptr, info_ptr, bitDepth)
514+
, fRowsWrittenToOutput(0)
515+
, fDst(nullptr)
516+
, fRowBytes(0)
517+
, fFirstRow(0)
518+
, fLastRow(0)
519+
{}
523520

524521
static void AllRowsCallback(png_structp png_ptr, png_bytep row, png_uint_32 rowNum, int /*pass*/) {
525522
GetDecoder(png_ptr)->allRowsCallback(row, rowNum);
@@ -539,6 +536,8 @@ class SkPngNormalDecoder : public SkPngCodec {
539536
int fLastRow;
540537
int fRowsNeeded;
541538

539+
using INHERITED = SkPngCodec;
540+
542541
static SkPngNormalDecoder* GetDecoder(png_structp png_ptr) {
543542
return static_cast<SkPngNormalDecoder*>(png_get_progressive_ptr(png_ptr));
544543
}
@@ -625,20 +624,17 @@ class SkPngNormalDecoder : public SkPngCodec {
625624

626625
class SkPngInterlacedDecoder : public SkPngCodec {
627626
public:
628-
SkPngInterlacedDecoder(SkEncodedInfo&& info,
629-
std::unique_ptr<SkStream> stream,
630-
SkPngChunkReader* reader,
631-
png_structp png_ptr,
632-
png_infop info_ptr,
633-
int bitDepth,
634-
int numberPasses)
635-
: SkPngCodec(std::move(info), std::move(stream), reader, png_ptr, info_ptr, bitDepth)
636-
, fNumberPasses(numberPasses)
637-
, fFirstRow(0)
638-
, fLastRow(0)
639-
, fLinesDecoded(0)
640-
, fInterlacedComplete(false)
641-
, fPng_rowbytes(0) {}
627+
SkPngInterlacedDecoder(SkEncodedInfo&& info, std::unique_ptr<SkStream> stream,
628+
SkPngChunkReader* reader, png_structp png_ptr,
629+
png_infop info_ptr, int bitDepth, int numberPasses)
630+
: INHERITED(std::move(info), std::move(stream), reader, png_ptr, info_ptr, bitDepth)
631+
, fNumberPasses(numberPasses)
632+
, fFirstRow(0)
633+
, fLastRow(0)
634+
, fLinesDecoded(0)
635+
, fInterlacedComplete(false)
636+
, fPng_rowbytes(0)
637+
{}
642638

643639
static void InterlacedRowCallback(png_structp png_ptr, png_bytep row, png_uint_32 rowNum, int pass) {
644640
auto decoder = static_cast<SkPngInterlacedDecoder*>(png_get_progressive_ptr(png_ptr));
@@ -656,6 +652,8 @@ class SkPngInterlacedDecoder : public SkPngCodec {
656652
size_t fPng_rowbytes;
657653
AutoTMalloc<png_byte> fInterlaceBuffer;
658654

655+
using INHERITED = SkPngCodec;
656+
659657
// FIXME: Currently sharing interlaced callback for all rows and subset. It's not
660658
// as expensive as the subset version of non-interlaced, but it still does extra
661659
// work.
@@ -1004,21 +1002,17 @@ void AutoCleanPng::infoCallback(size_t idatLength) {
10041002
this->releasePngPtrs();
10051003
}
10061004

1007-
SkPngCodec::SkPngCodec(SkEncodedInfo&& encodedInfo,
1008-
std::unique_ptr<SkStream> stream,
1009-
SkPngChunkReader* chunkReader,
1010-
void* png_ptr,
1011-
void* info_ptr,
1012-
int bitDepth)
1013-
: SkPngCodecBase(
1014-
std::move(encodedInfo), png_select_xform_format(encodedInfo), std::move(stream))
1015-
, fPngChunkReader(SkSafeRef(chunkReader))
1016-
, fPng_ptr(png_ptr)
1017-
, fInfo_ptr(info_ptr)
1018-
, fColorXformSrcRow(nullptr)
1019-
, fBitDepth(bitDepth)
1020-
, fIdatLength(0)
1021-
, fDecodedIdat(false) {}
1005+
SkPngCodec::SkPngCodec(SkEncodedInfo&& encodedInfo, std::unique_ptr<SkStream> stream,
1006+
SkPngChunkReader* chunkReader, void* png_ptr, void* info_ptr, int bitDepth)
1007+
: INHERITED(std::move(encodedInfo), png_select_xform_format(encodedInfo), std::move(stream))
1008+
, fPngChunkReader(SkSafeRef(chunkReader))
1009+
, fPng_ptr(png_ptr)
1010+
, fInfo_ptr(info_ptr)
1011+
, fColorXformSrcRow(nullptr)
1012+
, fBitDepth(bitDepth)
1013+
, fIdatLength(0)
1014+
, fDecodedIdat(false)
1015+
{}
10221016

10231017
SkPngCodec::~SkPngCodec() {
10241018
this->destroyReadStruct();

src/codec/SkPngCodec.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
#ifndef SkPngCodec_DEFINED
88
#define SkPngCodec_DEFINED
99

10-
#include <cstddef>
11-
#include <cstdint>
12-
#include <memory>
13-
1410
#include "include/codec/SkCodec.h"
11+
#include "include/codec/SkEncodedImageFormat.h"
1512
#include "include/core/SkRefCnt.h"
1613
#include "include/private/base/SkTemplates.h"
17-
#include "src/codec/SkPngCodecBase.h"
14+
15+
#include <cstddef>
16+
#include <cstdint>
17+
#include <memory>
1818

1919
class SkColorPalette;
2020
class SkPngChunkReader;
@@ -24,7 +24,7 @@ class SkSwizzler;
2424
struct SkEncodedInfo;
2525
struct SkImageInfo;
2626

27-
class SkPngCodec : public SkPngCodecBase {
27+
class SkPngCodec : public SkCodec {
2828
public:
2929
static bool IsPng(const void*, size_t);
3030

@@ -56,6 +56,7 @@ class SkPngCodec : public SkPngCodecBase {
5656

5757
Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, int*)
5858
override;
59+
SkEncodedImageFormat onGetEncodedFormat() const override { return SkEncodedImageFormat::kPNG; }
5960
bool onRewind() override;
6061

6162
SkSampler* getSampler(bool createIfNecessary) override;
@@ -121,5 +122,7 @@ class SkPngCodec : public SkPngCodecBase {
121122

122123
size_t fIdatLength;
123124
bool fDecodedIdat;
125+
126+
using INHERITED = SkCodec;
124127
};
125128
#endif // SkPngCodec_DEFINED

src/codec/SkPngCodecBase.cpp

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/codec/SkPngCodecBase.h

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)