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

Side by Side Diff: src/core/SkPicture.cpp

Issue 1918433002: Optionally enable SkValidatingReadBuffer in SkPictureImageFilter (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: More clean up Created 4 years, 8 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 | « include/core/SkPicture.h ('k') | src/core/SkPicturePlayback.h » ('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 2007 The Android Open Source Project 2 * Copyright 2007 The Android Open Source Project
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 #include "SkAtomics.h" 8 #include "SkAtomics.h"
9 #include "SkImageGenerator.h" 9 #include "SkImageGenerator.h"
10 #include "SkMessageBus.h" 10 #include "SkMessageBus.h"
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 buffer->readRect(&info.fCullRect); 122 buffer->readRect(&info.fCullRect);
123 info.fFlags = buffer->readUInt(); 123 info.fFlags = buffer->readUInt();
124 124
125 if (IsValidPictInfo(info)) { 125 if (IsValidPictInfo(info)) {
126 if (pInfo) { *pInfo = info; } 126 if (pInfo) { *pInfo = info; }
127 return true; 127 return true;
128 } 128 }
129 return false; 129 return false;
130 } 130 }
131 131
132 sk_sp<SkPicture> SkPicture::Forwardport(const SkPictInfo& info, const SkPictureD ata* data) { 132 sk_sp<SkPicture> SkPicture::Forwardport(const SkPictInfo& info,
133 const SkPictureData* data,
134 const SkReadBuffer* buffer) {
133 if (!data) { 135 if (!data) {
134 return nullptr; 136 return nullptr;
135 } 137 }
136 SkPicturePlayback playback(data); 138 SkPicturePlayback playback(data);
137 SkPictureRecorder r; 139 SkPictureRecorder r;
138 playback.draw(r.beginRecording(info.fCullRect), nullptr/*no callback*/); 140 playback.draw(r.beginRecording(info.fCullRect), nullptr/*no callback*/, buff er);
139 return r.finishRecordingAsPicture(); 141 return r.finishRecordingAsPicture();
140 } 142 }
141 143
142 static bool default_install(const void* src, size_t length, SkBitmap* dst) { 144 static bool default_install(const void* src, size_t length, SkBitmap* dst) {
143 sk_sp<SkData> encoded(SkData::MakeWithCopy(src, length)); 145 sk_sp<SkData> encoded(SkData::MakeWithCopy(src, length));
144 return encoded && SkDEPRECATED_InstallDiscardablePixelRef( 146 return encoded && SkDEPRECATED_InstallDiscardablePixelRef(
145 SkImageGenerator::NewFromEncoded(encoded.get()), dst); 147 SkImageGenerator::NewFromEncoded(encoded.get()), dst);
146 } 148 }
147 149
148 sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream) { 150 sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream) {
149 return MakeFromStream(stream, &default_install, nullptr); 151 return MakeFromStream(stream, &default_install, nullptr);
150 } 152 }
151 153
152 sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream, InstallPixelRefProc proc) { 154 sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream, InstallPixelRefProc proc) {
153 return MakeFromStream(stream, proc, nullptr); 155 return MakeFromStream(stream, proc, nullptr);
154 } 156 }
155 157
156 sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream, InstallPixelRefProc proc, 158 sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream, InstallPixelRefProc proc,
157 SkTypefacePlayback* typefaces) { 159 SkTypefacePlayback* typefaces) {
158 SkPictInfo info; 160 SkPictInfo info;
159 if (!InternalOnly_StreamIsSKP(stream, &info) || !stream->readBool()) { 161 if (!InternalOnly_StreamIsSKP(stream, &info) || !stream->readBool()) {
160 return nullptr; 162 return nullptr;
161 } 163 }
162 SkAutoTDelete<SkPictureData> data( 164 SkAutoTDelete<SkPictureData> data(
163 SkPictureData::CreateFromStream(stream, info, proc, typefaces)); 165 SkPictureData::CreateFromStream(stream, info, proc, typefaces));
164 return Forwardport(info, data); 166 return Forwardport(info, data, nullptr);
165 } 167 }
166 168
167 sk_sp<SkPicture> SkPicture::MakeFromBuffer(SkReadBuffer& buffer) { 169 sk_sp<SkPicture> SkPicture::MakeFromBuffer(SkReadBuffer& buffer) {
168 SkPictInfo info; 170 SkPictInfo info;
169 if (!InternalOnly_BufferIsSKP(&buffer, &info) || !buffer.readBool()) { 171 if (!InternalOnly_BufferIsSKP(&buffer, &info) || !buffer.readBool()) {
170 return nullptr; 172 return nullptr;
171 } 173 }
172 SkAutoTDelete<SkPictureData> data(SkPictureData::CreateFromBuffer(buffer, in fo)); 174 SkAutoTDelete<SkPictureData> data(SkPictureData::CreateFromBuffer(buffer, in fo));
173 return Forwardport(info, data); 175 return Forwardport(info, data, &buffer);
174 } 176 }
175 177
176 SkPictureData* SkPicture::backport() const { 178 SkPictureData* SkPicture::backport() const {
177 SkPictInfo info = this->createHeader(); 179 SkPictInfo info = this->createHeader();
178 SkPictureRecord rec(SkISize::Make(info.fCullRect.width(), info.fCullRect.hei ght()), 0/*flags*/); 180 SkPictureRecord rec(SkISize::Make(info.fCullRect.width(), info.fCullRect.hei ght()), 0/*flags*/);
179 rec.beginRecording(); 181 rec.beginRecording();
180 this->playback(&rec); 182 this->playback(&rec);
181 rec.endRecording(); 183 rec.endRecording();
182 return new SkPictureData(rec, info, false /*deep copy ops?*/); 184 return new SkPictureData(rec, info, false /*deep copy ops?*/);
183 } 185 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 } 228 }
227 229
228 // Global setting to disable security precautions for serialization. 230 // Global setting to disable security precautions for serialization.
229 void SkPicture::SetPictureIOSecurityPrecautionsEnabled_Dangerous(bool set) { 231 void SkPicture::SetPictureIOSecurityPrecautionsEnabled_Dangerous(bool set) {
230 g_AllPictureIOSecurityPrecautionsEnabled = set; 232 g_AllPictureIOSecurityPrecautionsEnabled = set;
231 } 233 }
232 234
233 bool SkPicture::PictureIOSecurityPrecautionsEnabled() { 235 bool SkPicture::PictureIOSecurityPrecautionsEnabled() {
234 return g_AllPictureIOSecurityPrecautionsEnabled; 236 return g_AllPictureIOSecurityPrecautionsEnabled;
235 } 237 }
OLDNEW
« no previous file with comments | « include/core/SkPicture.h ('k') | src/core/SkPicturePlayback.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698