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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « include/codec/SkCodec.h ('k') | include/codec/SkScanlineDecoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright 2015 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7 #ifndef SkScaledCodec_DEFINED
8 #define SkScaledCodec_DEFINED
9
10 #include "SkCodec.h"
11 #include "SkScanlineDecoder.h"
12
13 class SkScanlineDecoder;
14 class SkStream;
15
16 /**
17 * This class implements scaling, by sampling scanlines in the y direction.
18 * x-wise sampling is implemented in the swizzler, when getScanlines() is called .
19 */
20 class SkScaledCodec : public SkCodec {
21 public:
22 static SkCodec* NewFromStream(SkStream*);
23 static SkCodec* NewFromData(SkData*);
24
25 virtual ~SkScaledCodec();
26
27 /**
28 * returns whether a destination's dimensions are supported for down samplin g
29 */
30 static bool DimensionsSupportedForSampling(const SkImageInfo& srcInfo,
31 const SkImageInfo& dstInfo) {
32 // heights must be equal as no native y sampling is supported
33 if (dstInfo.height() != srcInfo.height()) {
34 return false;
35 }
36 // only support down sampling, dstWidth cannot be larger that srcWidth
37 if(dstInfo.width() > srcInfo.width()) {
38 return false;
39 }
40 return true;
41 }
42
43 static void ComputeSampleSize(const SkImageInfo& dstInfo, const SkImageInfo& srcInfo,
44 int* sampleSizeX, int* sampleSizeY);
45
46 protected:
47 /**
48 * Recommend a set of destination dimensions given a requested scale
49 */
50 SkISize onGetScaledDimensions(float desiredScale) const override;
51
52 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo lor*, int*)
53 override;
54 SkEncodedFormat onGetEncodedFormat() const override {
55 return fScanlineDecoder->getEncodedFormat();
56 }
57
58 bool onReallyHasAlpha() const override {
59 return fScanlineDecoder->reallyHasAlpha();
60 }
61
62 private:
63
64 SkAutoTDelete<SkScanlineDecoder> fScanlineDecoder;
65
66 explicit SkScaledCodec(SkScanlineDecoder*);
67
68 typedef SkCodec INHERITED;
69 };
70 #endif // SkScaledCodec_DEFINED
OLDNEW
« 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