| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 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 SkPictureData_DEFINED | 8 #ifndef SkPictureData_DEFINED |
| 9 #define SkPictureData_DEFINED | 9 #define SkPictureData_DEFINED |
| 10 | 10 |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 const sk_sp<SkData>& opData() const { return fOpData; } | 80 const sk_sp<SkData>& opData() const { return fOpData; } |
| 81 | 81 |
| 82 protected: | 82 protected: |
| 83 explicit SkPictureData(const SkPictInfo& info); | 83 explicit SkPictureData(const SkPictInfo& info); |
| 84 | 84 |
| 85 // Does not affect ownership of SkStream. | 85 // Does not affect ownership of SkStream. |
| 86 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc, SkTypefacePlayba
ck*); | 86 bool parseStream(SkStream*, SkPicture::InstallPixelRefProc, SkTypefacePlayba
ck*); |
| 87 bool parseBuffer(SkReadBuffer& buffer); | 87 bool parseBuffer(SkReadBuffer& buffer); |
| 88 | 88 |
| 89 public: | 89 public: |
| 90 const SkBitmap& getBitmap(SkReader32* reader) const { | 90 const SkBitmap& getBitmap(SkReadBuffer* reader) const { |
| 91 const int index = reader->readInt(); | 91 const int index = reader->readInt(); |
| 92 return fBitmaps[index]; | 92 return reader->validateIndex(index, fBitmaps.count()) ? fBitmaps[index]
: fEmptyBitmap; |
| 93 } | 93 } |
| 94 | 94 |
| 95 const SkImage* getImage(SkReader32* reader) const { | 95 const SkImage* getImage(SkReadBuffer* reader) const { |
| 96 const int index = reader->readInt(); | 96 const int index = reader->readInt(); |
| 97 return fImageRefs[index]; | 97 return reader->validateIndex(index, fImageCount) ? fImageRefs[index] : n
ullptr; |
| 98 } | 98 } |
| 99 | 99 |
| 100 const SkPath& getPath(SkReader32* reader) const { | 100 const SkPath& getPath(SkReadBuffer* reader) const { |
| 101 int index = reader->readInt() - 1; | 101 const int index = reader->readInt() - 1; |
| 102 return fPaths[index]; | 102 return reader->validateIndex(index, fPaths.count()) ? fPaths[index] : fE
mptyPath; |
| 103 } | 103 } |
| 104 | 104 |
| 105 const SkPicture* getPicture(SkReader32* reader) const { | 105 const SkPicture* getPicture(SkReadBuffer* reader) const { |
| 106 int index = reader->readInt(); | 106 const int index = reader->readInt() - 1; |
| 107 SkASSERT(index > 0 && index <= fPictureCount); | 107 return reader->validateIndex(index, fPictureCount) ? fPictureRefs[index]
: nullptr; |
| 108 return fPictureRefs[index - 1]; | |
| 109 } | 108 } |
| 110 | 109 |
| 111 const SkPaint* getPaint(SkReader32* reader) const { | 110 const SkPaint* getPaint(SkReadBuffer* reader) const { |
| 112 int index = reader->readInt(); | 111 const int index = reader->readInt() - 1; |
| 113 if (index == 0) { | 112 return reader->validateIndex(index, fPaints.count()) ? &fPaints[index] :
nullptr; |
| 114 return nullptr; | |
| 115 } | |
| 116 return &fPaints[index - 1]; | |
| 117 } | 113 } |
| 118 | 114 |
| 119 const SkTextBlob* getTextBlob(SkReader32* reader) const { | 115 const SkTextBlob* getTextBlob(SkReadBuffer* reader) const { |
| 120 int index = reader->readInt(); | 116 const int index = reader->readInt() - 1; |
| 121 SkASSERT(index > 0 && index <= fTextBlobCount); | 117 return reader->validateIndex(index, fTextBlobCount) ? fTextBlobRefs[inde
x] : nullptr; |
| 122 return fTextBlobRefs[index - 1]; | |
| 123 } | 118 } |
| 124 | 119 |
| 125 #if SK_SUPPORT_GPU | 120 #if SK_SUPPORT_GPU |
| 126 /** | 121 /** |
| 127 * sampleCount is the number of samples-per-pixel or zero if non-MSAA. | 122 * sampleCount is the number of samples-per-pixel or zero if non-MSAA. |
| 128 * It is defaulted to be zero. | 123 * It is defaulted to be zero. |
| 129 */ | 124 */ |
| 130 bool suitableForGpuRasterization(GrContext* context, const char **reason, | 125 bool suitableForGpuRasterization(GrContext* context, const char **reason, |
| 131 int sampleCount = 0) const; | 126 int sampleCount = 0) const; |
| 132 | 127 |
| (...skipping 20 matching lines...) Expand all Loading... |
| 153 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_
SLOT. This empty | 148 // Only used by getBitmap() if the passed in index is SkBitmapHeap::INVALID_
SLOT. This empty |
| 154 // bitmap allows playback to draw nothing and move on. | 149 // bitmap allows playback to draw nothing and move on. |
| 155 SkBitmap fBadBitmap; | 150 SkBitmap fBadBitmap; |
| 156 | 151 |
| 157 SkTArray<SkBitmap> fBitmaps; | 152 SkTArray<SkBitmap> fBitmaps; |
| 158 SkTArray<SkPaint> fPaints; | 153 SkTArray<SkPaint> fPaints; |
| 159 SkTArray<SkPath> fPaths; | 154 SkTArray<SkPath> fPaths; |
| 160 | 155 |
| 161 sk_sp<SkData> fOpData; // opcodes and parameters | 156 sk_sp<SkData> fOpData; // opcodes and parameters |
| 162 | 157 |
| 158 const SkPath fEmptyPath; |
| 159 const SkBitmap fEmptyBitmap; |
| 160 |
| 163 const SkPicture** fPictureRefs; | 161 const SkPicture** fPictureRefs; |
| 164 int fPictureCount; | 162 int fPictureCount; |
| 165 const SkTextBlob** fTextBlobRefs; | 163 const SkTextBlob** fTextBlobRefs; |
| 166 int fTextBlobCount; | 164 int fTextBlobCount; |
| 167 const SkImage** fImageRefs; | 165 const SkImage** fImageRefs; |
| 168 int fImageCount; | 166 int fImageCount; |
| 169 | 167 |
| 170 SkPictureContentInfo fContentInfo; | 168 SkPictureContentInfo fContentInfo; |
| 171 | 169 |
| 172 SkTypefacePlayback fTFPlayback; | 170 SkTypefacePlayback fTFPlayback; |
| 173 SkFactoryPlayback* fFactoryPlayback; | 171 SkFactoryPlayback* fFactoryPlayback; |
| 174 | 172 |
| 175 const SkPictInfo fInfo; | 173 const SkPictInfo fInfo; |
| 176 | 174 |
| 177 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); | 175 static void WriteFactories(SkWStream* stream, const SkFactorySet& rec); |
| 178 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); | 176 static void WriteTypefaces(SkWStream* stream, const SkRefCntSet& rec); |
| 179 | 177 |
| 180 void initForPlayback() const; | 178 void initForPlayback() const; |
| 181 }; | 179 }; |
| 182 | 180 |
| 183 #endif | 181 #endif |
| OLD | NEW |