OLD | NEW |
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 SkSurface_DEFINED | 8 #ifndef SkSurface_DEFINED |
9 #define SkSurface_DEFINED | 9 #define SkSurface_DEFINED |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 * of the requested dimensions are zero, then NULL will be returned. | 29 * of the requested dimensions are zero, then NULL will be returned. |
30 */ | 30 */ |
31 class SK_API SkSurface : public SkRefCnt { | 31 class SK_API SkSurface : public SkRefCnt { |
32 public: | 32 public: |
33 /** | 33 /** |
34 * Create a new surface, using the specified pixels/rowbytes as its | 34 * Create a new surface, using the specified pixels/rowbytes as its |
35 * backend. | 35 * backend. |
36 * | 36 * |
37 * If the requested surface cannot be created, or the request is not a | 37 * If the requested surface cannot be created, or the request is not a |
38 * supported configuration, NULL will be returned. | 38 * supported configuration, NULL will be returned. |
| 39 * |
| 40 * Callers are responsible for initialiazing the surface pixels. |
39 */ | 41 */ |
40 static sk_sp<SkSurface> MakeRasterDirect(const SkImageInfo&, void* pixels, s
ize_t rowBytes, | 42 static sk_sp<SkSurface> MakeRasterDirect(const SkImageInfo&, void* pixels, s
ize_t rowBytes, |
41 const SkSurfaceProps* = nullptr); | 43 const SkSurfaceProps* = nullptr); |
42 | 44 |
43 /** | 45 /** |
44 * The same as NewRasterDirect, but also accepts a call-back routine, which
is invoked | 46 * The same as NewRasterDirect, but also accepts a call-back routine, which
is invoked |
45 * when the surface is deleted, and is passed the pixel memory and the spec
ified context. | 47 * when the surface is deleted, and is passed the pixel memory and the spec
ified context. |
46 */ | 48 */ |
47 static sk_sp<SkSurface> MakeRasterDirectReleaseProc(const SkImageInfo&, void
* pixels, size_t rowBytes, | 49 static sk_sp<SkSurface> MakeRasterDirectReleaseProc(const SkImageInfo&, void
* pixels, size_t rowBytes, |
48 void (*releaseProc)(void* pixel
s, void* context), | 50 void (*releaseProc)(void* pixel
s, void* context), |
49 void* context, const SkSurfaceP
rops* = nullptr); | 51 void* context, const SkSurfaceP
rops* = nullptr); |
50 | 52 |
51 /** | 53 /** |
52 * Return a new surface, with the memory for the pixels automatically alloc
ated, but respecting | 54 * Return a new surface, with the memory for the pixels automatically alloc
ated and |
53 * the specified rowBytes. If rowBytes==0, then a default value will be cho
sen. If a non-zero | 55 * zero-initialized, but respecting the specified rowBytes. If rowBytes==0,
then a default |
54 * rowBytes is specified, then any images snapped off of this surface (via
newImageSnapshot()) | 56 * value will be chosen. If a non-zero rowBytes is specified, then any imag
es snapped off of |
55 * are guaranteed to have the same rowBytes. | 57 * this surface (via makeImageSnapshot()) are guaranteed to have the same r
owBytes. |
56 * | 58 * |
57 * If the requested surface cannot be created, or the request is not a | 59 * If the requested surface cannot be created, or the request is not a |
58 * supported configuration, NULL will be returned. | 60 * supported configuration, NULL will be returned. |
59 */ | 61 */ |
60 static sk_sp<SkSurface> MakeRaster(const SkImageInfo&, size_t rowBytes, cons
t SkSurfaceProps*); | 62 static sk_sp<SkSurface> MakeRaster(const SkImageInfo&, size_t rowBytes, cons
t SkSurfaceProps*); |
61 | 63 |
62 /** | 64 /** |
63 * Allocate a new surface, automatically computing the rowBytes. | 65 * Allocate a new surface, automatically computing the rowBytes. |
64 */ | 66 */ |
65 static sk_sp<SkSurface> MakeRaster(const SkImageInfo&, const SkSurfaceProps*
= nullptr); | 67 static sk_sp<SkSurface> MakeRaster(const SkImageInfo& info, |
| 68 const SkSurfaceProps* props = nullptr) { |
| 69 return MakeRaster(info, 0, props); |
| 70 } |
66 | 71 |
67 /** | 72 /** |
68 * Helper version of NewRaster. It creates a SkImageInfo with the | 73 * Helper version of NewRaster. It creates a SkImageInfo with the |
69 * specified width and height, and populates the rest of info to match | 74 * specified width and height, and populates the rest of info to match |
70 * pixels in SkPMColor format. | 75 * pixels in SkPMColor format. |
71 */ | 76 */ |
72 static sk_sp<SkSurface> MakeRasterN32Premul(int width, int height, | 77 static sk_sp<SkSurface> MakeRasterN32Premul(int width, int height, |
73 const SkSurfaceProps* props = nu
llptr) { | 78 const SkSurfaceProps* props = nu
llptr) { |
74 return MakeRaster(SkImageInfo::MakeN32Premul(width, height), props); | 79 return MakeRaster(SkImageInfo::MakeN32Premul(width, height), props); |
75 } | 80 } |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 private: | 371 private: |
367 const SkSurfaceProps fProps; | 372 const SkSurfaceProps fProps; |
368 const int fWidth; | 373 const int fWidth; |
369 const int fHeight; | 374 const int fHeight; |
370 uint32_t fGenerationID; | 375 uint32_t fGenerationID; |
371 | 376 |
372 typedef SkRefCnt INHERITED; | 377 typedef SkRefCnt INHERITED; |
373 }; | 378 }; |
374 | 379 |
375 #endif | 380 #endif |
OLD | NEW |