Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(122)

Unified Diff: src/codec/SkScaledCodec.h

Issue 1406223002: Create an SkAndroidCodec API separate from SkCodec (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/codec/SkScaledCodec.h
diff --git a/src/codec/SkScaledCodec.h b/src/codec/SkScaledCodec.h
new file mode 100644
index 0000000000000000000000000000000000000000..543c24ed06fdb6f3ae12d611570623317f564bd9
--- /dev/null
+++ b/src/codec/SkScaledCodec.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2015 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+#ifndef SkSampledCodec_DEFINED
+#define SkSampledCodec_DEFINED
+
+#include "SkAndroidCodec.h"
+#include "SkCodec.h"
+
+/**
+ * This class implements the functionality of SkAndroidCodec. Scaling will
+ * be provided by sampling if it cannot be provided by fCodec.
+ */
+class SkSampledCodec : public SkAndroidCodec {
scroggo 2015/10/16 21:13:55 I think this should be in the file SkSampledCodec.
msarett 2015/10/19 16:06:10 Agreed. I didn't want to modify and rename a file
+public:
+
+ explicit SkSampledCodec(SkCodec*);
+
+ virtual ~SkSampledCodec() {}
+
+protected:
+
+ SkEncodedFormat onGetEncodedFormat() const override { return fCodec->getEncodedFormat(); };
+
+ SkISize onGetSampledDimensions(int sampleSize) const override;
+
+ bool onGetSubset(SkIRect* desiredSubset) const override { return true; }
+
+ SkISize onGetSampledSubsetDimensions(int sampleSize, const SkIRect& subset) const override;
+
+ SkCodec::Result onGetAndroidPixels(const SkImageInfo& info, void* pixels, size_t rowBytes,
+ AndroidOptions& options) override;
+
+private:
+
+ /**
+ * This fulfills the same contract as onGetAndroidPixels().
+ *
+ * We call this function from onGetAndroidPixels() if we have determined
+ * that fCodec does not support the requested scale, and we need to
+ * provide the scale by sampling.
+ */
+ SkCodec::Result sampledDecode(const SkImageInfo& info, void* pixels, size_t rowBytes,
+ AndroidOptions& options);
+
+ SkAutoTDelete<SkCodec> fCodec;
+
+ typedef SkAndroidCodec INHERITED;
+};
+#endif // SkSampledCodec_DEFINED

Powered by Google App Engine
This is Rietveld 408576698