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

Side by Side Diff: include/codec/SkScaledCodec.h

Issue 1260673002: SkScaledCodec class (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix sample function for 565 images 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
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 class SkScaledCodec : public SkCodec {
17 public:
18 static SkCodec* NewFromStream(SkStream*);
19 static SkCodec* NewFromData(SkData*);
20
21 virtual ~SkScaledCodec();
22
23 // returns a sample size based on the input src and dst dimensions
24 // can only down sample, so dstDimension must be <= than srcDimension
25 static int GetSampleSize(int srcDimension, int dstDimension) {
26 SkASSERT(dstDimension <= srcDimension);
27 return srcDimension / dstDimension;
28 }
29 static bool DimensionsSupportedForSampling(const SkImageInfo& srcInfo,
scroggo 2015/07/31 19:31:58 nit: newline between functions.
emmaleer 2015/07/31 20:43:09 Acknowledged.
30 const SkImageInfo& dstInfo){
scroggo 2015/07/31 19:31:58 nit: space between ) and {
emmaleer 2015/07/31 20:43:09 Acknowledged.
31 // heights must be equal as no native y sampling is supported
32 if (dstInfo.height() != srcInfo.height()) {
33 return false;
34 }
35 // only support down sampling, dstWidth cannot be larger that srcWidth
36 if(dstInfo.width() > srcInfo.width()) {
37 return false;
38 }
39 return true;
40 }
41
42 protected:
43 // Recommend a set of destination dimensions given a requested scale
44 SkISize onGetScaledDimensions(float desiredScale) const override;
45
46 Result onGetPixels(const SkImageInfo&, void*, size_t, const Options&, SkPMCo lor*, int*)
47 override;
48 SkEncodedFormat onGetEncodedFormat() const override{
49 return fCodec->getEncodedFormat();
50 }
51
52 SkScanlineDecoder* onGetScanlineDecoder(const SkImageInfo& dstInfo, const Op tions& options,
53 SkPMColor ctable[], int* ctableCount ) override {
54 return fCodec->getScanlineDecoder(dstInfo, &options, ctable, ctableCount );
55 }
56 bool onReallyHasAlpha() const override{
scroggo 2015/07/31 19:31:58 nit: There should be a newline before this method.
emmaleer 2015/07/31 20:43:09 Acknowledged.
57 return fCodec->reallyHasAlpha();
58 }
59
60 private:
61 SkAutoTDelete<SkCodec> fCodec;
62
63 SkScaledCodec(SkCodec*);
64
65
scroggo 2015/07/31 19:31:58 nit: Unnecessary newline.
emmaleer 2015/07/31 20:43:09 Acknowledged.
66 typedef SkCodec INHERITED;
67 };
68 #endif // SkScaledCodec_DEFINED
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698