blob: 05d38ff52220a99b3491dfe3667d5f06b2187dfb [file] [log] [blame]
Cary Clarka560c472017-11-27 10:44:06 -05001#Topic Image
2#Alias Image_Reference
3
4#Class SkImage
5
6SkImage is an abstraction for drawing a rectangle of pixels, though the
7particular type of image could be actually storing its data on the GPU, or
8as drawing commands (picture or PDF or otherwise), ready to be played back
9into another canvas.
10The content of SkImage is always immutable, though the actual storage may
11change, if for example that image can be re-created via encoded data or
12other means.
13SkImage always has a non-zero dimensions. If there is a request to create a new
14image, either directly or via SkSurface, and either of the requested dimensions
15are zero, then nullptr will be returned.
16
17#Topic Overview
18
19#Subtopic Subtopics
20#ToDo manually add subtopics ##
21#Table
22#Legend
23# topics # description ##
24#Legend ##
25#Table ##
26##
27
28#Subtopic Structs
29#Table
30#Legend
31# description # struct ##
32#Legend ##
33# DeferredTextureImageUsageParams # ##
34#Table ##
35#Subtopic ##
36
37#Subtopic Member_Functions
38#Table
39#Legend
40# description # function ##
41#Legend ##
42# MakeFromAHardwareBuffer # ##
43# MakeBackendTextureFromSkImage # ##
44# MakeCrossContextFromEncoded # ##
45# MakeFromAHardwareBuffer # ##
46# MakeFromAdoptedTexture # ##
47# MakeFromBitmap # ##
48# MakeFromDeferredTextureImageData # ##
49# MakeFromEncoded # ##
50# MakeFromGenerator # ##
51# MakeFromNV12TexturesCopy # ##
52# MakeFromPicture # ##
53# MakeFromRaster # ##
54# MakeFromTexture # ##
55# MakeFromYUVTexturesCopy # ##
56# MakeRasterCopy # ##
57# MakeRasterData # ##
58# alphaType # ##
59# asLegacyBitmap # ##
60# bounds # ##
61# colorSpace # ##
62# dimensions # ##
63# encodeToData # ##
64# getDeferredTextureImageData # ##
65# getTexture # ##
66# getTextureHandle # ##
67# height # ##
68# isAlphaOnly # ##
69# isLazyGenerated # ##
70# isOpaque # ##
71# isTextureBacked # ##
72# isValid # ##
73# makeColorSpace # ##
74# makeNonTextureImage # ##
75# makeShader # ##
76# makeSubset # ##
77# makeTextureImage # ##
78# makeWithFilter # ##
79# peekPixels # ##
80# readPixels # ##
81# refColorSpace # ##
82# refEncodedData # ##
83# scalePixels # ##
84# toString # ##
85# uniqueID # ##
86# width # ##
87#Table ##
88#Subtopic ##
89
90#Topic ##
91
92# ------------------------------------------------------------------------------
93
94#Struct DeferredTextureImageUsageParams
95
96#Code
97#ToDo fill this in manually ##
98##
99
100Drawing parameters for which a deferred texture image data should be optimized. */
101
102# ------------------------------------------------------------------------------
103
104#Method DeferredTextureImageUsageParams(const SkMatrix matrix, const SkFilterQuality quality,
105 int preScaleMipLevel)
106
107#Param matrix incomplete ##
108#Param quality incomplete ##
109#Param preScaleMipLevel incomplete ##
110
111#Return incomplete ##
112
113#Example
114// incomplete
115##
116
117#SeeAlso incomplete
118
119#Method ##
120
121#Member SkMatrix fMatrix
122##
123
124#Member SkFilterQuality fQuality
125##
126
127#Member int fPreScaleMipLevel
128##
129
130#Struct DeferredTextureImageUsageParams ##
131
132#Typedef SkImageInfo Info
133
134##
135
136#Typedef void* ReleaseContext
137
138##
139
140# ------------------------------------------------------------------------------
141
142#Method static sk_sp<SkImage> MakeRasterCopy(const SkPixmap& pixmap)
143
144#Param pixmap incomplete ##
145
146#Return incomplete ##
147
148#Example
149// incomplete
150##
151
152#SeeAlso incomplete
153
154#Method ##
155
156# ------------------------------------------------------------------------------
157
158#Method static sk_sp<SkImage> MakeRasterData(const Info& info, sk_sp<SkData> pixels, size_t rowBytes)
159
160#Param info incomplete ##
161#Param pixels incomplete ##
162#Param rowBytes incomplete ##
163
164#Return incomplete ##
165
166#Example
167// incomplete
168##
169
170#SeeAlso incomplete
171
172#Method ##
173
174# ------------------------------------------------------------------------------
175
176#Typedef void (*RasterReleaseProc)(const void* pixels, ReleaseContext)
177
178##
179
180#Method static sk_sp<SkImage> MakeFromRaster(const SkPixmap& pixmap,
181 RasterReleaseProc rasterReleaseProc,
182 ReleaseContext releaseContext)
183
184Return a new Image referencing the specified pixels. These must remain valid and unchanged
185until the specified release-proc is called, indicating that Skia no longer has a reference
186to the pixels.
187Returns nullptr if the requested pixmap info is unsupported.
188
189#Param pixmap incomplete ##
190#Param rasterReleaseProc incomplete ##
191#Param releaseContext incomplete ##
192
193#Return incomplete ##
194
195#Example
196// incomplete
197##
198
199#SeeAlso incomplete
200
201#Method ##
202
203# ------------------------------------------------------------------------------
204
205#Method static sk_sp<SkImage> MakeFromBitmap(const SkBitmap& bitmap)
206
207Construct a new image from the specified bitmap. If the bitmap is marked immutable, and
208its pixel memory is shareable, it may be shared instead of copied.
209
210#Param bitmap incomplete ##
211
212#Return incomplete ##
213
214#Example
215// incomplete
216##
217
218#SeeAlso incomplete
219
220#Method ##
221
222# ------------------------------------------------------------------------------
223
224#Method static sk_sp<SkImage> MakeFromGenerator(std::unique_ptr<SkImageGenerator> imageGenerator,
225 const SkIRect* subset = nullptr)
226
227Construct a new SkImage based on the given ImageGenerator. Returns nullptr on error.
228This function will always take ownership of the passed generator.
229If a subset is specified, it must be contained within the generator's bounds.
230
231#Param imageGenerator incomplete ##
232#Param subset incomplete ##
233
234#Return incomplete ##
235
236#Example
237// incomplete
238##
239
240#SeeAlso incomplete
241
242#Method ##
243
244# ------------------------------------------------------------------------------
245
246#Method static sk_sp<SkImage> MakeFromEncoded(sk_sp<SkData> encoded, const SkIRect* subset = nullptr)
247
248Construct a new SkImage based on the specified encoded data. Returns nullptr on failure,
249which can mean that the format of the encoded data was not recognized/supported.
250If a subset is specified, it must be contained within the encoded data's bounds.
251
252#Param encoded incomplete ##
253#Param subset incomplete ##
254
255#Return incomplete ##
256
257#Example
258// incomplete
259##
260
261#SeeAlso incomplete
262
263#Method ##
264
265# ------------------------------------------------------------------------------
266
267#Typedef void (*TextureReleaseProc)(ReleaseContext releaseContext)
268
269##
270
271#Method static sk_sp<SkImage> MakeFromTexture(GrContext* context,
272 const GrBackendTexture& backendTexture,
273 GrSurfaceOrigin origin,
274 SkAlphaType alphaType,
275 sk_sp<SkColorSpace> colorSpace)
276
277Create a new image from the specified descriptor. Note - the caller is responsible for
278managing the lifetime of the underlying platform texture.
279Will return nullptr if the specified back-end texture is unsupported.
280
281#Param context incomplete ##
282#Param backendTexture incomplete ##
283#Param origin incomplete ##
284#Param alphaType incomplete ##
285#Param colorSpace incomplete ##
286
287#Return incomplete ##
288
289#Example
290// incomplete
291##
292
293#SeeAlso incomplete
294
295#Method ##
296
297# ------------------------------------------------------------------------------
298
299#Method static sk_sp<SkImage> MakeFromTexture(GrContext* context,
300 const GrBackendTexture& backendTexture,
301 GrSurfaceOrigin origin,
302 SkAlphaType alphaType,
303 sk_sp<SkColorSpace> colorSpace,
304 TextureReleaseProc textureReleaseProc,
305 ReleaseContext releaseContext)
306
307Create a new image from the GrBackendTexture. The underlying platform texture must stay
308valid and unaltered until the specified release-proc is invoked, indicating that Skia
309no longer is holding a reference to it.
310Will return nullptr if the specified back-end texture is unsupported.
311
312#Param context incomplete ##
313#Param backendTexture incomplete ##
314#Param origin incomplete ##
315#Param alphaType incomplete ##
316#Param colorSpace incomplete ##
317#Param textureReleaseProc incomplete ##
318#Param releaseContext incomplete ##
319
320#Return incomplete ##
321
322#Example
323// incomplete
324##
325
326#SeeAlso incomplete
327
328#Method ##
329
330# ------------------------------------------------------------------------------
331
332#Method static sk_sp<SkImage> MakeCrossContextFromEncoded(GrContext* context, sk_sp<SkData> data,
333 bool buildMips,
334 SkColorSpace* dstColorSpace)
335
336Decodes and uploads the encoded data to a GPU backed image using the supplied GrContext.
337That image can be safely used by other GrContexts, across thread boundaries. The GrContext
338used here, and the ones used to draw this image later must be in the same OpenGL share group,
339or otherwise be able to share resources.
340When the image's ref count reaches zero, the original GrContext will destroy the texture,
341asynchronously.
342The texture will be decoded and uploaded to be suitable for use with surfaces that have the
343supplied destination color space. The color space of the image itself will be determined
344from the encoded data.
345
346#Param context incomplete ##
347#Param data incomplete ##
348#Param buildMips incomplete ##
349#Param dstColorSpace incomplete ##
350
351#Return incomplete ##
352
353#Example
354// incomplete
355##
356
357#SeeAlso incomplete
358
359#Method ##
360
361# ------------------------------------------------------------------------------
362
363#Method static sk_sp<SkImage> MakeFromAdoptedTexture(GrContext* context,
364 const GrBackendTexture& backendTexture,
365 GrSurfaceOrigin surfaceOrigin,
366 SkAlphaType alphaType = kPremul_SkAlphaType,
367 sk_sp<SkColorSpace> colorSpace = nullptr)
368
369Create a new image from the specified descriptor. Note - Skia will delete or recycle the
370texture when the image is released.
371Will return nullptr if the specified back-end texture is unsupported.
372
373#Param context incomplete ##
374#Param backendTexture incomplete ##
375#Param surfaceOrigin incomplete ##
376#Param alphaType incomplete ##
377#Param colorSpace incomplete ##
378
379#Return incomplete ##
380
381#Example
382// incomplete
383##
384
385#SeeAlso incomplete
386
387#Method ##
388
389# ------------------------------------------------------------------------------
390
391#Method static sk_sp<SkImage> MakeFromYUVTexturesCopy(GrContext* context, SkYUVColorSpace yuvColorSpace,
392 const GrBackendObject yuvTextureHandles[3],
393 const SkISize yuvSizes[3],
394 GrSurfaceOrigin surfaceOrigin,
395 sk_sp<SkColorSpace> colorSpace = nullptr)
396
397Create a new image by copying the pixels from the specified y, u, v textures. The data
398from the textures is immediately ingested into the image and the textures can be modified or
399deleted after the function returns. The image will have the dimensions of the y texture.
400
401#Param context incomplete ##
402#Param yuvColorSpace incomplete ##
403#Param yuvTextureHandles incomplete ##
404#Param yuvSizes incomplete ##
405#Param surfaceOrigin incomplete ##
406#Param colorSpace incomplete ##
407
408#Return incomplete ##
409
410#Example
411// incomplete
412##
413
414#SeeAlso incomplete
415
416#Method ##
417
418# ------------------------------------------------------------------------------
419
420#Method static sk_sp<SkImage> MakeFromNV12TexturesCopy(GrContext* context,
421 SkYUVColorSpace yuvColorSpace,
422 const GrBackendObject nv12TextureHandles[2],
423 const SkISize nv12Sizes[2],
424 GrSurfaceOrigin surfaceOrigin,
425 sk_sp<SkColorSpace> colorSpace = nullptr)
426
427Create a new image by copying the pixels from the specified y and UV_Mapping. The data
428from the textures is immediately ingested into the image and the textures can be modified or
429deleted after the function returns. The image will have the dimensions of the y texture.
430
431#Param context incomplete ##
432#Param yuvColorSpace incomplete ##
433#Param nv12TextureHandles incomplete ##
434#Param nv12Sizes incomplete ##
435#Param surfaceOrigin incomplete ##
436#Param colorSpace incomplete ##
437
438#Return incomplete ##
439
440#Example
441// incomplete
442##
443
444#SeeAlso incomplete
445
446#Method ##
447
448# ------------------------------------------------------------------------------
449
450#Enum BitDepth
451
452#Code
453 enum BitDepth {
454 kU8,
455 kF16,
456 };
457##
458
459#Const kU8 0
460##
461#Const kF16 1
462##
463
464#Example
465// incomplete
466##
467
468#SeeAlso incomplete
469
470#Enum ##
471
472# ------------------------------------------------------------------------------
473
474#Method static sk_sp<SkImage> MakeFromPicture(sk_sp<SkPicture> picture, const SkISize& dimensions,
475 const SkMatrix* matrix, const SkPaint* paint,
476 BitDepth bitDepth,
477 sk_sp<SkColorSpace> colorSpace)
478
479Create a new image from the specified picture.
480On creation of the SkImage, snap the SkPicture to a particular BitDepth and SkColorSpace.
481
482#Param picture incomplete ##
483#Param dimensions incomplete ##
484#Param matrix incomplete ##
485#Param paint incomplete ##
486#Param bitDepth incomplete ##
487#Param colorSpace incomplete ##
488
489#Return incomplete ##
490
491#Example
492// incomplete
493##
494
495#SeeAlso incomplete
496
497#Method ##
498
499# ------------------------------------------------------------------------------
500
501#Method static sk_sp<SkImage> MakeFromAHardwareBuffer(AHardwareBuffer* hardwareBuffer,
502 SkAlphaType alphaType = kPremul_SkAlphaType,
503 sk_sp<SkColorSpace> colorSpace = nullptr)
504
505 Create a new image from the an Android hardware buffer.
506 The new image takes a reference on the buffer.
507
508 Only available on Android, when __ANDROID_API__ is defined to be 26 or greater.
509
510#Param hardwareBuffer incomplete ##
511#Param alphaType incomplete ##
512#Param colorSpace incomplete ##
513
514#Return incomplete ##
515
516#Example
517// incomplete
518##
519
520#SeeAlso incomplete
521
522#Method ##
523
524# ------------------------------------------------------------------------------
525
526#Method static sk_sp<SkImage> MakeFromAHardwareBuffer(AHardwareBuffer* hardwareBuffer,
527 SkAlphaType alphaType = kPremul_SkAlphaType,
528 sk_sp<SkColorSpace> colorSpace = nullptr)
529
530Create a new image from the an Android hardware buffer.
531The new image takes a reference on the buffer.
532
533#Param hardwareBuffer incomplete ##
534#Param alphaType incomplete ##
535#Param colorSpace incomplete ##
536
537#Return incomplete ##
538
539#Example
540// incomplete
541##
542
543#SeeAlso incomplete
544
545#Method ##
546
547# ------------------------------------------------------------------------------
548
549#Method int width() const
550
551#Return incomplete ##
552
553#Example
554// incomplete
555##
556
557#SeeAlso incomplete
558
559#Method ##
560
561# ------------------------------------------------------------------------------
562
563#Method int height() const
564
565#Return incomplete ##
566
567#Example
568// incomplete
569##
570
571#SeeAlso incomplete
572
573#Method ##
574
575# ------------------------------------------------------------------------------
576
577#Method SkISize dimensions() const
578
579#Return incomplete ##
580
581#Example
582// incomplete
583##
584
585#SeeAlso incomplete
586
587#Method ##
588
589# ------------------------------------------------------------------------------
590
591#Method SkIRect bounds() const
592
593#Return incomplete ##
594
595#Example
596// incomplete
597##
598
599#SeeAlso incomplete
600
601#Method ##
602
603# ------------------------------------------------------------------------------
604
605#Method uint32_t uniqueID() const
606
607#Return incomplete ##
608
609#Example
610// incomplete
611##
612
613#SeeAlso incomplete
614
615#Method ##
616
617# ------------------------------------------------------------------------------
618
619#Method SkAlphaType alphaType() const
620
621#Return incomplete ##
622
623#Example
624// incomplete
625##
626
627#SeeAlso incomplete
628
629#Method ##
630
631# ------------------------------------------------------------------------------
632
633#Method SkColorSpace* colorSpace() const
634
635Returns Color_Space of Image. Color_Space may have been a parameter when
636Image was created, or may have been parsed from encoded data. Skia may not be
637able to draw image respecting returned Color_Space or draw into Surface with
638returned Color_Space.
639
640#Return Color_Space Image was created with, or nullptr ##
641
642#Example
643// incomplete
644##
645
646#SeeAlso incomplete
647
648#Method ##
649
650# ------------------------------------------------------------------------------
651
652#Method sk_sp<SkColorSpace> refColorSpace() const
653
654#Return incomplete ##
655
656#Example
657// incomplete
658##
659
660#SeeAlso incomplete
661
662#Method ##
663
664# ------------------------------------------------------------------------------
665
666#Method bool isAlphaOnly() const
667
668Returns true fi the image will be drawn as a mask, with no intrinsic color of its own.
669
670#Return incomplete ##
671
672#Example
673// incomplete
674##
675
676#SeeAlso incomplete
677
678#Method ##
679
680# ------------------------------------------------------------------------------
681
682#Method bool isOpaque() const
683
684#Return incomplete ##
685
686#Example
687// incomplete
688##
689
690#SeeAlso incomplete
691
692#Method ##
693
694# ------------------------------------------------------------------------------
695
696#Method sk_sp<SkShader> makeShader(SkShader::TileMode tileMode1, SkShader::TileMode tileMode2,
697 const SkMatrix* localMatrix = nullptr) const
698
699#Param tileMode1 incomplete ##
700#Param tileMode2 incomplete ##
701#Param localMatrix incomplete ##
702
703#Return incomplete ##
704
705#Example
706// incomplete
707##
708
709#SeeAlso incomplete
710
711#Method ##
712
713# ------------------------------------------------------------------------------
714
715#Method sk_sp<SkShader> makeShader(const SkMatrix* localMatrix = nullptr) const
716
717Helper version of makeShader() that specifies SkShader::kClamp_TileMode.
718
719#Param localMatrix incomplete ##
720
721#Return incomplete ##
722
723#Example
724// incomplete
725##
726
727#SeeAlso incomplete
728
729#Method ##
730
731# ------------------------------------------------------------------------------
732
733#Method bool peekPixels(SkPixmap* pixmap) const
734
735If the image has direct access to its pixels (i.e. they are in local RAM)
736return true, and if not null, return in the pixmap parameter the info about the
737images pixels.
738On failure, return false and ignore the pixmap parameter.
739
740#Param pixmap incomplete ##
741
742#Return incomplete ##
743
744#Example
745// incomplete
746##
747
748#SeeAlso incomplete
749
750#Method ##
751
752# ------------------------------------------------------------------------------
753
754#Method GrTexture* getTexture() const
755
756DEPRECATED -
757#Private
758currently used by Canvas2DLayerBridge in Chromium.
759##
760
761#Return incomplete ##
762
763#Example
764// incomplete
765##
766
767#SeeAlso incomplete
768
769#Method ##
770
771# ------------------------------------------------------------------------------
772
773#Method bool isTextureBacked() const
774
775Returns true if the image is texture backed.
776
777#Return incomplete ##
778
779#Example
780// incomplete
781##
782
783#SeeAlso incomplete
784
785#Method ##
786
787# ------------------------------------------------------------------------------
788
789#Method bool isValid(GrContext* context) const
790
791Returns true if Image can be drawn. If context
792is nullptr, tests if Image draws on Raster_Surface; Otherwise, tests if Image
793draws on GPU_Surface associated with context.
794
795Texture-backed images may become invalid if their underlying GrContext is abandoned. Some
796generator-backed images may be invalid for CPU and/or GPU.
797
798#Param context incomplete ##
799
800#Return incomplete ##
801
802#Example
803// incomplete
804##
805
806#SeeAlso incomplete
807
808#Method ##
809
810# ------------------------------------------------------------------------------
811
812#Method GrBackendObject getTextureHandle(bool flushPendingGrContextIO,
813 GrSurfaceOrigin* origin = nullptr) const
814
815Retrieves the back-end API handle of the texture. If flushPendingGrContextIO then the
816GrContext will issue to the back-end API any deferred I/O operations on the texture before
817returning.
818If 'origin' is supplied it will be filled in with the origin of the content drawn
819into the image.
820
821#Param flushPendingGrContextIO incomplete ##
822#Param origin incomplete ##
823
824#Return incomplete ##
825
826#Example
827// incomplete
828##
829
830#SeeAlso incomplete
831
832#Method ##
833
834# ------------------------------------------------------------------------------
835
836#Enum CachingHint
837
838#Code
839 enum CachingHint {
840 kAllow_CachingHint,
841 kDisallow_CachingHint,
842 };
843##
844
845Hints to image calls where the system might cache computed intermediates (e.g. the results
846of decoding or a read-back from the GPU. Passing kAllow_CachingHint signals that the system's default
847behavior is fine. Passing kDisallow_CachingHint signals that caching should be avoided.
848
849#Const kAllow_CachingHint 0
850##
851#Const kDisallow_CachingHint 1
852##
853
854#Example
855// incomplete
856##
857
858#SeeAlso incomplete
859
860#Enum ##
861
862# ------------------------------------------------------------------------------
863
864#Method bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
865 int srcX, int srcY, CachingHint cachingHint = kAllow_CachingHint) const
866
867Copy the pixels from the image into the specified buffer (dstPixels + dstRowBytes),
868converting them into the requested format (dstInfo). The image pixels are read
869starting at the specified (srcX, srcY) location.
870dstInfo and (srcX, srcY) offset specifies a source rectangle:
871#Code
872SkRect srcR;
873srcR.setXYWH(srcX, srcY, dstInfo.width(), dstInfo.height());
874##
875
876The source rectangle is intersected with the bounds of the image. If this intersection is not empty,
877then we have two sets of pixels (of equal size). Replace dstPixels with the
878corresponding Image pixels, performing any Color_Type/Alpha_Type transformations needed
879(in the case where Image and dstInfo have different Color_Types or Alpha_Types).
880This call can fail, returning false, for several reasons:
881if source rectangle does not intersect the image bounds;
882if the requested Color_Type/Alpha_Type cannot be converted from the image's types.
883
884#Param dstInfo incomplete ##
885#Param dstPixels incomplete ##
886#Param dstRowBytes incomplete ##
887#Param srcX incomplete ##
888#Param srcY incomplete ##
889#Param cachingHint incomplete ##
890
891#Return incomplete ##
892
893#Example
894// incomplete
895##
896
897#SeeAlso incomplete
898
899#Method ##
900
901# ------------------------------------------------------------------------------
902
903#Method bool readPixels(const SkPixmap& dst, int srcX, int srcY,
904 CachingHint cachingHint = kAllow_CachingHint) const
905
906#Param dst incomplete ##
907#Param srcX incomplete ##
908#Param srcY incomplete ##
909#Param cachingHint incomplete ##
910
911#Return incomplete ##
912
913#Example
914// incomplete
915##
916
917#SeeAlso incomplete
918
919#Method ##
920
921# ------------------------------------------------------------------------------
922
923#Method bool scalePixels(const SkPixmap& dst, SkFilterQuality filterQuality,
924 CachingHint cachingHint = kAllow_CachingHint) const
925
926Copies Image pixels into dst, converting to dst Color_Type and Alpha_Type.
927If the conversion cannot be performed, false is returned.
928If dst dimensions differ from Image dimensions, Image is scaled, applying
929filterQuality.
930
931#Param dst incomplete ##
932#Param filterQuality incomplete ##
933#Param cachingHint incomplete ##
934
935#Return incomplete ##
936
937#Example
938// incomplete
939##
940
941#SeeAlso incomplete
942
943#Method ##
944
945# ------------------------------------------------------------------------------
946
947#Method sk_sp<SkData> encodeToData(SkEncodedImageFormat encodedImageFormat, int quality) const
948
949Encode the image's pixels and return the result as SkData.
950If the image type cannot be encoded, or the requested encoder format is
951not supported, this will return nullptr.
952
953#Param encodedImageFormat incomplete ##
954#Param quality incomplete ##
955
956#Return incomplete ##
957
958#Example
959// incomplete
960##
961
962#SeeAlso incomplete
963
964#Method ##
965
966# ------------------------------------------------------------------------------
967
968#Method sk_sp<SkData> encodeToData(SkPixelSerializer* pixelSerializer = nullptr) const
969
970Encodes Image and returns result as SkData. Will reuse existing encoded data
971if present, as returned by refEncodedData. pixelSerializer validates existing
972encoded data, and encodes Image when existing encoded data is missing or
973invalid.
974
975Passing nullptr for pixelSerializer selects default serialization which
976accepts all data and encodes to PNG.
977
978Returns nullptr if existing encoded data is missing or invalid and
979encoding fails.
980
981#Param pixelSerializer incomplete ##
982
983#Return incomplete ##
984
985#Example
986// incomplete
987##
988
989#SeeAlso incomplete
990
991#Method ##
992
993# ------------------------------------------------------------------------------
994
995#Method sk_sp<SkData> refEncodedData() const
996
997If the image already has its contents in encoded form (e.g. PNG or JPEG), return that
998as SkData. If the image does not already has its contents in encoded form, return nullptr.
999
1000To force the image to return its contents as encoded data, call encodeToData.
1001
1002#Return incomplete ##
1003
1004#Example
1005// incomplete
1006##
1007
1008#SeeAlso incomplete
1009
1010#Method ##
1011
1012# ------------------------------------------------------------------------------
1013
1014#Method const char* toString(SkString* string) const
1015
1016#Param string incomplete ##
1017
1018#Return incomplete ##
1019
1020#Example
1021// incomplete
1022##
1023
1024#SeeAlso incomplete
1025
1026#Method ##
1027
1028# ------------------------------------------------------------------------------
1029
1030#Method sk_sp<SkImage> makeSubset(const SkIRect& subset) const
1031
1032Return a new image that is a subset of this image. The underlying implementation may
1033share the pixels, or it may make a copy.
1034If subset does not intersect the bounds of this image, or the copy/share cannot be made,
1035nullptr will be returned.
1036
1037#Param subset incomplete ##
1038
1039#Return incomplete ##
1040
1041#Example
1042// incomplete
1043##
1044
1045#SeeAlso incomplete
1046
1047#Method ##
1048
1049# ------------------------------------------------------------------------------
1050
1051#Method sk_sp<SkImage> makeTextureImage(GrContext* context, SkColorSpace* dstColorSpace) const
1052
1053Ensures that an image is backed by a texture (when GrContext is non-null), suitable for use
1054with surfaces that have the supplied destination color space. If no transformation is
1055required, the returned image may be the same as this image. If this image is from a
1056different GrContext, this will fail.
1057
1058#Param context incomplete ##
1059#Param dstColorSpace incomplete ##
1060
1061#Return incomplete ##
1062
1063#Example
1064// incomplete
1065##
1066
1067#SeeAlso incomplete
1068
1069#Method ##
1070
1071# ------------------------------------------------------------------------------
1072
1073#Method sk_sp<SkImage> makeNonTextureImage() const
1074
1075If the image is texture-backed this will make a raster copy of it (or nullptr if reading back
1076the pixels fails). Otherwise, it returns the original image.
1077
1078#Return incomplete ##
1079
1080#Example
1081// incomplete
1082##
1083
1084#SeeAlso incomplete
1085
1086#Method ##
1087
1088# ------------------------------------------------------------------------------
1089
1090#Method sk_sp<SkImage> makeWithFilter(const SkImageFilter* filter, const SkIRect& subset,
1091 const SkIRect& clipBounds, SkIRect* outSubset,
1092 SkIPoint* offset) const
1093
1094Apply a given image filter to this image, and return the filtered result.
1095The subset represents the active portion of this image. The return value is similarly an
1096SkImage, with an active subset (outSubset). This is usually used with texture-backed
1097images, where the texture may be approx-match and thus larger than the required size.
1098clipBounds constrains the device-space extent of the image, stored in outSubset.
1099offset is storage, set to the amount to translate the result when drawn.
1100If the result image cannot be created, or the result would be transparent black, null
1101is returned, in which case the offset and outSubset parameters should be ignored by the
1102caller.
1103
1104#Param filter incomplete ##
1105#Param subset incomplete ##
1106#Param clipBounds incomplete ##
1107#Param outSubset incomplete ##
1108#Param offset incomplete ##
1109
1110#Return incomplete ##
1111
1112#Example
1113// incomplete
1114##
1115
1116#SeeAlso incomplete
1117
1118#Method ##
1119
1120# ------------------------------------------------------------------------------
1121
1122#Method size_t getDeferredTextureImageData(const GrContextThreadSafeProxy& contextThreadSafeProxy,
1123 const DeferredTextureImageUsageParams deferredTextureImageUsageParams[],
1124 int paramCnt,
1125 void* buffer,
1126 SkColorSpace* dstColorSpace = nullptr,
1127 SkColorType dstColorType = kN32_SkColorType) const
1128
1129This method allows clients to capture the data necessary to turn a SkImage into a texture-
1130backed image. If the original image is codec-backed this will decode into a format optimized
1131for the context represented by the proxy. This method is thread safe with respect to the
1132GrContext whence the proxy came. Clients allocate and manage the storage of the deferred
1133texture data and control its lifetime. No cleanup is required, thus it is safe to simply free
1134the memory out from under the data.
1135
1136The same method is used both for getting the size necessary for uploading
1137and retrieving texture data. The deferredTextureImageUsageParams array represents the set of
1138draws over which to optimize the texture data prior to uploading.
1139
1140When called with a null buffer this returns the size that the client must allocate in order
1141to create deferred texture data for this image (or zero if this is an inappropriate
1142candidate). The buffer allocated by the client should be 8 byte aligned.
1143When buffer is not null this fills in the deferred texture data for this image in the
1144provided buffer (assuming this is an appropriate candidate image and the buffer is
1145appropriately aligned). Upon success the size written is returned, otherwise 0.
1146dstColorSpace is the color space of the surface where this texture will ultimately be used.
1147If the method determines that Mip_Maps are needed, this helps determine the correct strategy
1148for building them (gamma-correct or not).
1149
1150dstColorType is the color type of the surface where this texture will ultimately be used.
1151This determines the format with which the image will be uploaded to the GPU. If dstColorType
1152does not support color spaces (low bit depth types such as kARGB_4444_SkColorType), then dstColorSpace
1153must be null.
1154
1155#Param contextThreadSafeProxy incomplete ##
1156#Param deferredTextureImageUsageParams incomplete ##
1157#Param paramCnt incomplete ##
1158#Param buffer incomplete ##
1159#Param dstColorSpace incomplete ##
1160#Param dstColorType incomplete ##
1161
1162#Return incomplete ##
1163
1164#Example
1165// incomplete
1166##
1167
1168#SeeAlso incomplete
1169
1170#Method ##
1171
1172# ------------------------------------------------------------------------------
1173
1174#Method static sk_sp<SkImage> MakeFromDeferredTextureImageData(GrContext* context, const void* data,
1175 SkBudgeted budgeted)
1176
1177Returns a texture-backed image from data produced in SkImage::getDeferredTextureImageData.
1178The context must be the context that provided the proxy passed to
1179getDeferredTextureImageData.
1180
1181#Param context incomplete ##
1182#Param data incomplete ##
1183#Param budgeted incomplete ##
1184
1185#Return incomplete ##
1186
1187#Example
1188// incomplete
1189##
1190
1191#SeeAlso incomplete
1192
1193#Method ##
1194
1195#Typedef std::function<void(GrBackendTexture)> BackendTextureReleaseProc
1196
1197##
1198
1199# ------------------------------------------------------------------------------
1200
1201#Method static bool MakeBackendTextureFromSkImage(GrContext* context,
1202 sk_sp<SkImage> image,
1203 GrBackendTexture* backendTexture,
1204 BackendTextureReleaseProc* backendTextureReleaseProc)
1205
1206Creates a GrBackendTexture from the provided SkImage. Returns true on success. The
1207GrBackendTexture and BackendTextureReleaseProc are populated on success. It is the callers
1208responsibility to call the BackendTextureReleaseProc once they have deleted the texture.
1209Note that the BackendTextureReleaseProc allows Skia to clean up auxiliary data related
1210to the GrBackendTexture, and is not a substitute for the client deleting the GrBackendTexture
1211themselves.
1212
1213If image is both texture backed and singly referenced; that is, its only
1214reference was transferred using std::move(): image is returned in backendTexture
1215without conversion or making a copy.
1216
1217If the SkImage is not texture backed, this function will generate a texture with the image's
1218contents and return that.
1219
1220#Param context incomplete ##
1221#Param image incomplete ##
1222#Param backendTexture incomplete ##
1223#Param backendTextureReleaseProc incomplete ##
1224
1225#Return incomplete ##
1226
1227#Example
1228// incomplete
1229##
1230
1231#SeeAlso incomplete
1232
1233#Method ##
1234
1235# ------------------------------------------------------------------------------
1236
1237#Enum LegacyBitmapMode
1238
1239#Code
1240 enum LegacyBitmapMode {
1241 kRO_LegacyBitmapMode,
1242 kRW_LegacyBitmapMode,
1243 };
1244##
1245
1246Helper functions to convert to SkBitmap
1247
1248#Const kRO_LegacyBitmapMode 0
1249##
1250#Const kRW_LegacyBitmapMode 1
1251##
1252
1253#Example
1254// incomplete
1255##
1256
1257#SeeAlso incomplete
1258
1259#Enum ##
1260
1261# ------------------------------------------------------------------------------
1262
1263#Method bool asLegacyBitmap(SkBitmap* bitmap, LegacyBitmapMode legacyBitmapMode) const
1264
1265Attempt to create a bitmap with the same pixels as the image. The result will always be
1266a raster-backed bitmap (texture-backed bitmaps are DEPRECATED, and not supported here).
1267If the mode is kRO_LegacyBitmapMode (read-only), the resulting bitmap will be marked as immutable.
1268On success, returns true. On failure, returns false and the bitmap parameter will be reset
1269to empty.
1270
1271#Param bitmap incomplete ##
1272#Param legacyBitmapMode incomplete ##
1273
1274#Return incomplete ##
1275
1276#Example
1277// incomplete
1278##
1279
1280#SeeAlso incomplete
1281
1282#Method ##
1283
1284# ------------------------------------------------------------------------------
1285
1286#Method bool isLazyGenerated() const
1287
1288Returns true if Image is backed by an image-generator or other service that creates
1289and caches its pixels or texture on-demand.
1290
1291#Return incomplete ##
1292
1293#Example
1294// incomplete
1295##
1296
1297#SeeAlso incomplete
1298
1299#Method ##
1300
1301# ------------------------------------------------------------------------------
1302
1303#Method sk_sp<SkImage> makeColorSpace(sk_sp<SkColorSpace> target,
1304 SkTransferFunctionBehavior premulBehavior) const
1305
1306If target is supported, returns an SkImage in target color space.
1307Otherwise, returns nullptr.
1308This will leave the image as is if it already in target color space.
1309Otherwise, it will convert the pixels from Image color space to target
1310color space. If this->colorSpace() is nullptr, Image color space will be
1311treated as sRGB.
1312
1313If premulBehavior is SkTransferFunctionBehavior::kRespect: converts Image
1314pixels to a linear space before converting to match destination Color_Type
1315and Color_Space.
1316If premulBehavior is SkTransferFunctionBehavior::kIgnore: Image
1317pixels are treated as if they are linear, regardless of how they are encoded.
1318
1319#Param target incomplete ##
1320#Param premulBehavior incomplete ##
1321
1322#Return incomplete ##
1323
1324#Example
1325// incomplete
1326##
1327
1328#SeeAlso incomplete
1329
1330#Method ##
1331
1332#Class SkImage ##
1333
1334#Topic Image ##