1 /* 2 * Copyright 2018 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 SkPicturePriv_DEFINED 9 #define SkPicturePriv_DEFINED 10 11 #include "include/core/SkPicture.h" 12 13 class SkReadBuffer; 14 class SkWriteBuffer; 15 16 class SkPicturePriv { 17 public: 18 /** 19 * Recreate a picture that was serialized into a buffer. If the creation requires bitmap 20 * decoding, the decoder must be set on the SkReadBuffer parameter by calling 21 * SkReadBuffer::setBitmapDecoder() before calling SkPicture::MakeFromBuffer(). 22 * @param buffer Serialized picture data. 23 * @return A new SkPicture representing the serialized data, or NULL if the buffer is 24 * invalid. 25 */ 26 static sk_sp<SkPicture> MakeFromBuffer(SkReadBuffer& buffer); 27 28 /** 29 * Serialize to a buffer. 30 */ 31 static void Flatten(const sk_sp<const SkPicture> , SkWriteBuffer& buffer); 32 33 // Returns NULL if this is not an SkBigPicture. AsSkBigPicture(const sk_sp<const SkPicture> picture)34 static const SkBigPicture* AsSkBigPicture(const sk_sp<const SkPicture> picture) { 35 return picture->asSkBigPicture(); 36 } 37 MakeSharedID(uint32_t pictureID)38 static uint64_t MakeSharedID(uint32_t pictureID) { 39 uint64_t sharedID = SkSetFourByteTag('p', 'i', 'c', 't'); 40 return (sharedID << 32) | pictureID; 41 } 42 AddedToCache(const SkPicture * pic)43 static void AddedToCache(const SkPicture* pic) { 44 pic->fAddedToCache.store(true); 45 } 46 47 // V35: Store SkRect (rather then width & height) in header 48 // V36: Remove (obsolete) alphatype from SkColorTable 49 // V37: Added shadow only option to SkDropShadowImageFilter (last version to record CLEAR) 50 // V38: Added PictureResolution option to SkPictureImageFilter 51 // V39: Added FilterLevel option to SkPictureImageFilter 52 // V40: Remove UniqueID serialization from SkImageFilter. 53 // V41: Added serialization of SkBitmapSource's filterQuality parameter 54 // V42: Added a bool to SkPictureShader serialization to indicate did-we-serialize-a-picture? 55 // V43: Added DRAW_IMAGE and DRAW_IMAGE_RECT opt codes to serialized data 56 // V44: Move annotations from paint to drawAnnotation 57 // V45: Add invNormRotation to SkLightingShader. 58 // V46: Add drawTextRSXform 59 // V47: Add occluder rect to SkBlurMaskFilter 60 // V48: Read and write extended SkTextBlobs. 61 // V49: Gradients serialized as SkColor4f + SkColorSpace 62 // V50: SkXfermode -> SkBlendMode 63 // V51: more SkXfermode -> SkBlendMode 64 // V52: Remove SkTextBlob::fRunCount 65 // V53: SaveLayerRec clip mask 66 // V54: ComposeShader can use a Mode or a Lerp 67 // V55: Drop blendmode[] from MergeImageFilter 68 // V56: Add TileMode in SkBlurImageFilter. 69 // V57: Sweep tiling info. 70 // V58: No more 2pt conical flipping. 71 // V59: No more LocalSpace option on PictureImageFilter 72 // V60: Remove flags in picture header 73 // V61: Change SkDrawPictureRec to take two colors rather than two alphas 74 // V62: Don't negate size of custom encoded images (don't write origin x,y either) 75 // V63: Store image bounds (including origin) instead of just width/height to support subsets 76 // V64: Remove occluder feature from blur maskFilter 77 // V65: Float4 paint color 78 // V66: Add saveBehind 79 // V67: Blobs serialize fonts instead of paints 80 // V68: Paint doesn't serialize font-related stuff 81 // V69: Clean up duplicated and redundant SkImageFilter related enums 82 // V70: Image filters definitions hidden, registered names updated to include "Impl" 83 // V71: Unify erode and dilate image filters 84 // V72: SkColorFilter_Matrix domain (rgba vs. hsla) 85 // V73: Use SkColor4f in per-edge AA quad API 86 // V74: MorphologyImageFilter internal radius is SkScaler 87 // V75: SkVertices switched from unsafe use of SkReader32 to SkReadBuffer (like everything else) 88 // V76: Add filtering enum to ImageShader 89 // V77: Explicit filtering options on imageshaders 90 // V78: Serialize skmipmap data for images that have it 91 // V79: Cubic Resampler option on imageshader 92 // V80: Smapling options on imageshader 93 // V81: sampling parameters on drawImage/drawImageRect/etc. 94 // V82: Add filter param to picture-shader 95 // V83: SkMatrixImageFilter now takes SkSamplingOptions instead of SkFilterQuality 96 // V84: SkImageFilters::Image now takes SkSamplingOptions instead of SkFilterQuality 97 // V85: Remove legacy support for inheriting sampling from the paint. 98 // V86: Remove support for custom data inside SkVertices 99 // V87: SkPaint now holds a user-defined blend function (SkBlender), no longer has DrawLooper 100 // V88: Add blender to ComposeShader and BlendImageFilter 101 // V89: Deprecated SkClipOps are no longer supported 102 // V90: Private API for backdrop scale factor in SaveLayerRec 103 104 enum Version { 105 kPictureShaderFilterParam_Version = 82, 106 kMatrixImageFilterSampling_Version = 83, 107 kImageFilterImageSampling_Version = 84, 108 kNoFilterQualityShaders_Version = 85, 109 kVerticesRemoveCustomData_Version = 86, 110 kSkBlenderInSkPaint = 87, 111 kBlenderInEffects = 88, 112 kNoExpandingClipOps = 89, 113 kBackdropScaleFactor = 90, 114 115 // Only SKPs within the min/current picture version range (inclusive) can be read. 116 kMin_Version = kPictureShaderFilterParam_Version, 117 kCurrent_Version = kBackdropScaleFactor 118 }; 119 }; 120 121 #endif 122