OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright 2016 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 | |
8 #ifndef SkSpecialImage_DEFINED | |
9 #define SkSpecialImage_DEFINED | |
10 | |
11 #include "SkRefCnt.h" | |
12 | |
13 class GrTexture; | |
14 class SkBitmap; | |
15 class SkCanvas; | |
16 class SkImage; | |
17 struct SkImageInfo; | |
18 class SkPaint; | |
19 class SkSpecialSurface; | |
20 | |
21 /** | |
22 * This is a restricted form of SkImage solely intended for internal use. It | |
23 * differs from SkImage in that: | |
24 * - it can only be backed by raster or gpu (no generators) | |
25 * - it can be backed by a GrTexture larger than its nominal bounds | |
bsalomon
2016/01/13 21:39:17
Should we generalize to allow a irect subset rathe
robertphillips
2016/01/14 19:58:55
Done.
| |
26 * - it can't be drawn tiled | |
bsalomon
2016/01/13 21:39:17
Need a restriction on filtering too (no MIPS).
robertphillips
2016/01/14 14:43:59
Done.
| |
27 * It is similar to SkImage in that it abstracts how the pixels are stored/repre sented. | |
28 * | |
29 * Note: the contents of the backing storage outside of the upper-right width x height | |
30 * rect are undefined. | |
31 */ | |
32 class SkSpecialImage : public SkRefCnt { | |
33 public: | |
34 int width() const { return fWidth; } | |
35 int height() const { return fHeight; } | |
36 | |
37 /** | |
38 * Draw this SpecialImage into the canvas. | |
39 */ | |
40 void draw(SkCanvas*, int x, int y, const SkPaint*) const; | |
41 | |
42 /** | |
43 * If the SpecialImage is backed by cpu pixels, return the const address | |
44 * of those pixels and, if not null, return the ImageInfo and rowBytes. | |
45 * The returned address is only valid while the image object is in scope. | |
46 * The returned ImageInfo represents the backing memory. Use 'width' & 'hei ght' | |
47 * to get the active portion's dimensions. | |
48 * | |
49 * On failure, returns NULL and the info and rowBytes parameters are | |
50 * ignored. | |
51 */ | |
52 const void* peekPixels(SkImageInfo* info, size_t* rowBytes) const; | |
reed1
2016/01/14 13:52:55
nit:
bool peekPixels(SkPixmap*) const;
robertphillips
2016/01/14 19:58:55
Done.
| |
53 | |
54 /** | |
55 * If the SpecialImage is backed by a gpu texture, return that texture. | |
56 * The active portion of the texture can be retrieved via 'width' & 'height '. | |
57 */ | |
58 GrTexture* peekTexture() const; | |
59 | |
60 static SkSpecialImage* New(int width, int height, const SkImage*); | |
61 static SkSpecialImage* New(int width, int height, const SkBitmap&); | |
reed1
2016/01/14 13:52:55
Does this ever copy the pixels from the bitmap?
robertphillips
2016/01/14 19:58:55
No.
| |
62 static SkSpecialImage* New(int width, int height, GrTexture*); | |
63 | |
64 /** | |
65 * Create a new surface with a backend that is compatible with this image. | |
66 */ | |
67 SkSpecialSurface* newSurface(const SkImageInfo&) const; | |
68 | |
69 protected: | |
70 SkSpecialImage(int width, int height) : fWidth(width), fHeight(height) { } | |
71 | |
72 private: | |
73 const int fWidth; | |
74 const int fHeight; | |
75 | |
76 typedef SkRefCnt INHERITED; | |
77 }; | |
78 | |
79 #endif | |
80 | |
OLD | NEW |