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

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

Issue 2066903003: Document SkSurface::MakeRaster's memory initialization (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 4 years, 6 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 | tests/SurfaceTest.cpp » ('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 SkSurface_DEFINED 8 #ifndef SkSurface_DEFINED
9 #define SkSurface_DEFINED 9 #define SkSurface_DEFINED
10 10
(...skipping 13 matching lines...) Expand all
24 * 24 *
25 * To draw into a canvas, first create the appropriate type of Surface, and 25 * To draw into a canvas, first create the appropriate type of Surface, and
26 * then request the canvas from the surface. 26 * then request the canvas from the surface.
27 * 27 *
28 * SkSurface always has non-zero dimensions. If there is a request for a new su rface, and either 28 * SkSurface always has non-zero dimensions. If there is a request for a new su rface, and either
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
reed1 2016/07/01 20:11:42 Lets document that do or do not zero-init this mem
f(malita) 2016/07/05 15:39:53 Done.
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 */ 39 */
40 static sk_sp<SkSurface> MakeRasterDirect(const SkImageInfo&, void* pixels, s ize_t rowBytes, 40 static sk_sp<SkSurface> MakeRasterDirect(const SkImageInfo&, void* pixels, s ize_t rowBytes,
41 const SkSurfaceProps* = nullptr); 41 const SkSurfaceProps* = nullptr);
42 42
43 /** 43 /**
44 * The same as NewRasterDirect, but also accepts a call-back routine, which is invoked 44 * 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. 45 * when the surface is deleted, and is passed the pixel memory and the spec ified context.
46 */ 46 */
47 static sk_sp<SkSurface> MakeRasterDirectReleaseProc(const SkImageInfo&, void * pixels, size_t rowBytes, 47 static sk_sp<SkSurface> MakeRasterDirectReleaseProc(const SkImageInfo&, void * pixels, size_t rowBytes,
48 void (*releaseProc)(void* pixel s, void* context), 48 void (*releaseProc)(void* pixel s, void* context),
49 void* context, const SkSurfaceP rops* = nullptr); 49 void* context, const SkSurfaceP rops* = nullptr);
50 50
51 /** 51 /**
52 * Return a new surface, with the memory for the pixels automatically alloc ated, but respecting 52 * 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 53 * zero-initialized, but respecting the specified rowBytes. If rowBytes==0, then a default
reed1 2016/06/15 15:30:35 Do we consistently make this promise for surfaces
f(malita) 2016/06/15 15:36:37 Even if we only do this for raster, it's still wor
bsalomon 2016/06/15 16:18:23 I believe we do this for GPU as well.
54 * rowBytes is specified, then any images snapped off of this surface (via newImageSnapshot()) 54 * 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. 55 * this surface (via makeImageSnapshot()) are guaranteed to have the same r owBytes.
56 * 56 *
57 * If the requested surface cannot be created, or the request is not a 57 * If the requested surface cannot be created, or the request is not a
58 * supported configuration, NULL will be returned. 58 * supported configuration, NULL will be returned.
59 */ 59 */
60 static sk_sp<SkSurface> MakeRaster(const SkImageInfo&, size_t rowBytes, cons t SkSurfaceProps*); 60 static sk_sp<SkSurface> MakeRaster(const SkImageInfo&, size_t rowBytes, cons t SkSurfaceProps*);
61 61
62 /** 62 /**
63 * Allocate a new surface, automatically computing the rowBytes. 63 * Allocate a new surface, automatically computing the rowBytes.
64 */ 64 */
65 static sk_sp<SkSurface> MakeRaster(const SkImageInfo&, const SkSurfaceProps* = nullptr); 65 static sk_sp<SkSurface> MakeRaster(const SkImageInfo&, const SkSurfaceProps* = nullptr);
reed1 2016/07/01 20:11:42 Maybe we should have this guy be inline, so that i
f(malita) 2016/07/05 15:39:53 Done.
66 66
67 /** 67 /**
68 * Helper version of NewRaster. It creates a SkImageInfo with the 68 * Helper version of NewRaster. It creates a SkImageInfo with the
69 * specified width and height, and populates the rest of info to match 69 * specified width and height, and populates the rest of info to match
70 * pixels in SkPMColor format. 70 * pixels in SkPMColor format.
71 */ 71 */
72 static sk_sp<SkSurface> MakeRasterN32Premul(int width, int height, 72 static sk_sp<SkSurface> MakeRasterN32Premul(int width, int height,
73 const SkSurfaceProps* props = nu llptr) { 73 const SkSurfaceProps* props = nu llptr) {
74 return MakeRaster(SkImageInfo::MakeN32Premul(width, height), props); 74 return MakeRaster(SkImageInfo::MakeN32Premul(width, height), props);
75 } 75 }
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 private: 366 private:
367 const SkSurfaceProps fProps; 367 const SkSurfaceProps fProps;
368 const int fWidth; 368 const int fWidth;
369 const int fHeight; 369 const int fHeight;
370 uint32_t fGenerationID; 370 uint32_t fGenerationID;
371 371
372 typedef SkRefCnt INHERITED; 372 typedef SkRefCnt INHERITED;
373 }; 373 };
374 374
375 #endif 375 #endif
OLDNEW
« no previous file with comments | « no previous file | tests/SurfaceTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698