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

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

Issue 1738513002: start on pre-upload data (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: stuff Created 4 years, 9 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 | « no previous file | include/gpu/GrContext.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 <functional>
11 #include "SkFilterQuality.h" 12 #include "SkFilterQuality.h"
12 #include "SkImageInfo.h" 13 #include "SkImageInfo.h"
13 #include "SkImageEncoder.h" 14 #include "SkImageEncoder.h"
14 #include "SkRefCnt.h" 15 #include "SkRefCnt.h"
15 #include "SkScalar.h" 16 #include "SkScalar.h"
16 #include "SkShader.h" 17 #include "SkShader.h"
17 18
18 class SkData; 19 class SkData;
19 class SkCanvas; 20 class SkCanvas;
20 class SkColorTable; 21 class SkColorTable;
21 class SkImageGenerator; 22 class SkImageGenerator;
22 class SkPaint; 23 class SkPaint;
23 class SkPicture; 24 class SkPicture;
24 class SkPixelSerializer; 25 class SkPixelSerializer;
25 class SkString; 26 class SkString;
26 class SkSurface; 27 class SkSurface;
28 class GrCaps;
27 class GrContext; 29 class GrContext;
28 class GrTexture; 30 class GrTexture;
29 31
32 class SkImage;
33 class SkImageTextureData {
34 public:
35 SkImage* newImage(GrContext* context, SkBudgeted) const;
36
37 private:
38 uint32_t fContextUniqueID;
39 uint32_t fImageUniqueID;
40 std::function<void(SkPixmap*)> fPixmapGenerator;
41
42 friend class SkImage;
43 };
44
45 class GrContextThreadSafeProxy;
46
30 /** 47 /**
31 * SkImage is an abstraction for drawing a rectagle of pixels, though the 48 * SkImage is an abstraction for drawing a rectagle of pixels, though the
32 * particular type of image could be actually storing its data on the GPU, or 49 * particular type of image could be actually storing its data on the GPU, or
33 * as drawing commands (picture or PDF or otherwise), ready to be played back 50 * as drawing commands (picture or PDF or otherwise), ready to be played back
34 * into another canvas. 51 * into another canvas.
35 * 52 *
36 * The content of SkImage is always immutable, though the actual storage may 53 * The content of SkImage is always immutable, though the actual storage may
37 * change, if for example that image can be re-created via encoded data or 54 * change, if for example that image can be re-created via encoded data or
38 * other means. 55 * other means.
39 * 56 *
40 * SkImage always has a non-zero dimensions. If there is a request to create a new image, either 57 * SkImage always has a non-zero dimensions. If there is a request to create a new image, either
41 * directly or via SkSurface, and either of the requested dimensions are zero, then NULL will be 58 * directly or via SkSurface, and either of the requested dimensions are zero, then NULL will be
42 * returned. 59 * returned.
43 */ 60 */
44 class SK_API SkImage : public SkRefCnt { 61 class SK_API SkImage : public SkRefCnt {
45 public: 62 public:
46 typedef SkImageInfo Info; 63 typedef SkImageInfo Info;
47 typedef void* ReleaseContext; 64 typedef void* ReleaseContext;
48 65
66 SkImageTextureData* newImageTextureData(
67 const GrContextThreadSafeProxy&,
68 const std::function<void*(size_t, const SkImage*)>& allocate =
69 std::function<void*(size_t, const SkImage*)>()) const;
70
49 static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowByt es, 71 static SkImage* NewRasterCopy(const Info&, const void* pixels, size_t rowByt es,
50 SkColorTable* ctable = NULL); 72 SkColorTable* ctable = NULL);
51 static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes); 73 static SkImage* NewRasterData(const Info&, SkData* pixels, size_t rowBytes);
52 74
53 typedef void (*RasterReleaseProc)(const void* pixels, ReleaseContext); 75 typedef void (*RasterReleaseProc)(const void* pixels, ReleaseContext);
54 76
55 /** 77 /**
56 * Return a new Image referencing the specified pixels. These must remain v alid and unchanged 78 * Return a new Image referencing the specified pixels. These must remain v alid and unchanged
57 * until the specified release-proc is called, indicating that Skia no long er has a reference 79 * until the specified release-proc is called, indicating that Skia no long er has a reference
58 * to the pixels. 80 * to the pixels.
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 * deleted after the function returns. The image will have the dimensions o f the y texture. 160 * deleted after the function returns. The image will have the dimensions o f the y texture.
139 */ 161 */
140 static SkImage* NewFromYUVTexturesCopy(GrContext*, SkYUVColorSpace, 162 static SkImage* NewFromYUVTexturesCopy(GrContext*, SkYUVColorSpace,
141 const GrBackendObject yuvTextureHandl es[3], 163 const GrBackendObject yuvTextureHandl es[3],
142 const SkISize yuvSizes[3], 164 const SkISize yuvSizes[3],
143 GrSurfaceOrigin); 165 GrSurfaceOrigin);
144 166
145 static SkImage* NewFromPicture(const SkPicture*, const SkISize& dimensions, 167 static SkImage* NewFromPicture(const SkPicture*, const SkISize& dimensions,
146 const SkMatrix*, const SkPaint*); 168 const SkMatrix*, const SkPaint*);
147 169
170 static SkImage* NewTextureFromPixmap(GrContext*, const SkPixmap&, SkBudgeted budgeted);
171
148 //////////////////////////////////////////////////////////////////////////// /////////////////// 172 //////////////////////////////////////////////////////////////////////////// ///////////////////
149 173
150 int width() const { return fWidth; } 174 int width() const { return fWidth; }
151 int height() const { return fHeight; } 175 int height() const { return fHeight; }
152 SkISize dimensions() const { return SkISize::Make(fWidth, fHeight); } 176 SkISize dimensions() const { return SkISize::Make(fWidth, fHeight); }
153 SkIRect bounds() const { return SkIRect::MakeWH(fWidth, fHeight); } 177 SkIRect bounds() const { return SkIRect::MakeWH(fWidth, fHeight); }
154 uint32_t uniqueID() const { return fUniqueID; } 178 uint32_t uniqueID() const { return fUniqueID; }
155 virtual bool isOpaque() const { return false; } 179 virtual bool isOpaque() const { return false; }
156 180
157 /** 181 /**
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 367
344 private: 368 private:
345 const int fWidth; 369 const int fWidth;
346 const int fHeight; 370 const int fHeight;
347 const uint32_t fUniqueID; 371 const uint32_t fUniqueID;
348 372
349 typedef SkRefCnt INHERITED; 373 typedef SkRefCnt INHERITED;
350 }; 374 };
351 375
352 #endif 376 #endif
OLDNEW
« no previous file with comments | « no previous file | include/gpu/GrContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698