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

Side by Side Diff: include/core/SkImage.h

Issue 15002004: add encodeData() to SkImageEncoder, and add encoding to SkImage (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | include/images/SkImageEncoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #ifndef SkImage_DEFINED 8 #ifndef SkImage_DEFINED
9 #define SkImage_DEFINED 9 #define SkImage_DEFINED
10 10
11 #include "SkRefCnt.h" 11 #include "SkRefCnt.h"
12 #include "SkScalar.h" 12 #include "SkScalar.h"
13 13
14 class SkData; 14 class SkData;
15 class SkCanvas; 15 class SkCanvas;
16 class SkPaint; 16 class SkPaint;
17 class SkShader; 17 class SkShader;
18 class GrContext; 18 class GrContext;
19 class GrTexture; 19 class GrTexture;
20 20
21 // need for TileMode 21 // need for TileMode
22 #include "SkShader.h" 22 #include "SkShader.h"
23 23
24 ////// EXPERIMENTAL
25
26 /** 24 /**
27 * SkImage is an abstraction for drawing a rectagle of pixels, though the 25 * SkImage is an abstraction for drawing a rectagle of pixels, though the
28 * particular type of image could be actually storing its data on the GPU, or 26 * particular type of image could be actually storing its data on the GPU, or
29 * as drawing commands (picture or PDF or otherwise), ready to be played back 27 * as drawing commands (picture or PDF or otherwise), ready to be played back
30 * into another canvas. 28 * into another canvas.
31 * 29 *
32 * The content of SkImage is always immutable, though the actual storage may 30 * The content of SkImage is always immutable, though the actual storage may
33 * change, if for example that image can be re-created via encoded data or 31 * change, if for example that image can be re-created via encoded data or
34 * other means. 32 * other means.
35 */ 33 */
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 * does not affect the reference count of the GrTexture object. 75 * does not affect the reference count of the GrTexture object.
78 * Will return NULL if the image does not use a texture. 76 * Will return NULL if the image does not use a texture.
79 */ 77 */
80 GrTexture* getTexture(); 78 GrTexture* getTexture();
81 79
82 SkShader* newShaderClamp() const; 80 SkShader* newShaderClamp() const;
83 SkShader* newShader(SkShader::TileMode, SkShader::TileMode) const; 81 SkShader* newShader(SkShader::TileMode, SkShader::TileMode) const;
84 82
85 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*); 83 void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*);
86 84
85 enum EncodeType {
86 kBMP_EncodeType,
87 kGIF_EncodeType,
88 kICO_EncodeType,
89 kJPEG_EncodeType,
90 kPNG_EncodeType,
91 kWBMP_EncodeType,
92 kWEBP_EncodeType,
93 };
94 /**
95 * Encode the image's pixels and return the result as a new SkData, which
96 * the caller must manage (i.e. call unref() when they are done).
97 *
98 * If the image type cannot be encoded, or the requested encoder type is
99 * not supported, this will return NULL.
100 */
101 SkData* encode(EncodeType t = kPNG_EncodeType, int quality = 80) const;
102
87 protected: 103 protected:
88 SkImage(int width, int height) : 104 SkImage(int width, int height) :
89 fWidth(width), 105 fWidth(width),
90 fHeight(height), 106 fHeight(height),
91 fUniqueID(NextUniqueID()) { 107 fUniqueID(NextUniqueID()) {
92 108
93 SkASSERT(width >= 0); 109 SkASSERT(width >= 0);
94 SkASSERT(height >= 0); 110 SkASSERT(height >= 0);
95 } 111 }
96 112
97 private: 113 private:
98 const int fWidth; 114 const int fWidth;
99 const int fHeight; 115 const int fHeight;
100 const uint32_t fUniqueID; 116 const uint32_t fUniqueID;
101 117
102 static uint32_t NextUniqueID(); 118 static uint32_t NextUniqueID();
103 119
104 typedef SkRefCnt INHERITED; 120 typedef SkRefCnt INHERITED;
105 }; 121 };
106 122
107 #endif 123 #endif
OLDNEW
« no previous file with comments | « no previous file | include/images/SkImageEncoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698