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

Unified Diff: include/codec/SkScaledCodec.h

Issue 1260673002: SkScaledCodec class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Stop DM from running large interlaced images on 32-bit Ubuntu GCE bots b/c they are running out of … Created 5 years, 4 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
« no previous file with comments | « include/codec/SkCodec.h ('k') | include/codec/SkScanlineDecoder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include/codec/SkScaledCodec.h
diff --git a/include/codec/SkScaledCodec.h b/include/codec/SkScaledCodec.h
new file mode 100644
index 0000000000000000000000000000000000000000..1bcdf085b213f7eaab1cb9d9eca51a491138c58f
--- /dev/null
+++ b/include/codec/SkScaledCodec.h
@@ -0,0 +1,70 @@
+/*
+ * 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 SkScaledCodec_DEFINED
+#define SkScaledCodec_DEFINED
+
+#include "SkCodec.h"
+#include "SkScanlineDecoder.h"
+
+class SkScanlineDecoder;
+class SkStream;
+
+/**
+ * This class implements scaling, by sampling scanlines in the y direction.
+ * x-wise sampling is implemented in the swizzler, when getScanlines() is called.
+ */
+class SkScaledCodec : public SkCodec {
+public:
+ static SkCodec* NewFromStream(SkStream*);
+ static SkCodec* NewFromData(SkData*);
+
+ virtual ~SkScaledCodec();
+
+ /**
+ * returns whether a destination's dimensions are supported for down sampling
+ */
+ static bool DimensionsSupportedForSampling(const SkImageInfo& srcInfo,
+ const SkImageInfo& dstInfo) {
+ // heights must be equal as no native y sampling is supported
+ if (dstInfo.height() != srcInfo.height()) {
+ return false;
+ }
+ // only support down sampling, dstWidth cannot be larger that srcWidth
+ if(dstInfo.width() > srcInfo.width()) {
+ return false;
+ }
+ return true;
+ }
+
+ static void ComputeSampleSize(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo,
+ int* sampleSizeX, int* sampleSizeY);
+
+protected:
+ /**
+ * Recommend a set of destination dimensions given a requested scale
+ */
+ SkISize onGetScaledDimensions(float desiredScale) const override;
+
+ Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMColor*, int*)
+ override;
+ SkEncodedFormat onGetEncodedFormat() const override {
+ return fScanlineDecoder->getEncodedFormat();
+ }
+
+ bool onReallyHasAlpha() const override {
+ return fScanlineDecoder->reallyHasAlpha();
+ }
+
+private:
+
+ SkAutoTDelete<SkScanlineDecoder> fScanlineDecoder;
+
+ explicit SkScaledCodec(SkScanlineDecoder*);
+
+ typedef SkCodec INHERITED;
+};
+#endif // SkScaledCodec_DEFINED
« no previous file with comments | « include/codec/SkCodec.h ('k') | include/codec/SkScanlineDecoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698