OLD | NEW |
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" | |
10 #include "SkMessageBus.h" | 9 #include "SkMessageBus.h" |
11 #include "SkPicture.h" | 10 #include "SkPicture.h" |
12 #include "SkPictureData.h" | 11 #include "SkPictureData.h" |
13 #include "SkPicturePlayback.h" | 12 #include "SkPicturePlayback.h" |
14 #include "SkPictureRecord.h" | 13 #include "SkPictureRecord.h" |
15 #include "SkPictureRecorder.h" | 14 #include "SkPictureRecorder.h" |
16 | 15 |
17 #if defined(SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS) || \ | 16 #if defined(SK_DISALLOW_CROSSPROCESS_PICTUREIMAGEFILTERS) || \ |
18 defined(SK_ENABLE_PICTURE_IO_SECURITY_PRECAUTIONS) | 17 defined(SK_ENABLE_PICTURE_IO_SECURITY_PRECAUTIONS) |
19 static bool g_AllPictureIOSecurityPrecautionsEnabled = true; | 18 static bool g_AllPictureIOSecurityPrecautionsEnabled = true; |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 SkPicture* SkPicture::Forwardport(const SkPictInfo& info, const SkPictureData* d
ata) { | 131 SkPicture* SkPicture::Forwardport(const SkPictInfo& info, const SkPictureData* d
ata) { |
133 if (!data) { | 132 if (!data) { |
134 return nullptr; | 133 return nullptr; |
135 } | 134 } |
136 SkPicturePlayback playback(data); | 135 SkPicturePlayback playback(data); |
137 SkPictureRecorder r; | 136 SkPictureRecorder r; |
138 playback.draw(r.beginRecording(info.fCullRect), nullptr/*no callback*/); | 137 playback.draw(r.beginRecording(info.fCullRect), nullptr/*no callback*/); |
139 return r.endRecording(); | 138 return r.endRecording(); |
140 } | 139 } |
141 | 140 |
142 static bool default_install(const void* src, size_t length, SkBitmap* dst) { | |
143 SkAutoTUnref<SkData> encoded(SkData::NewWithCopy(src, length)); | |
144 return encoded && SkDEPRECATED_InstallDiscardablePixelRef( | |
145 SkImageGenerator::NewFromEncoded(encoded), dst); | |
146 } | |
147 | |
148 SkPicture* SkPicture::CreateFromStream(SkStream* stream) { | |
149 return CreateFromStream(stream, &default_install, nullptr); | |
150 } | |
151 | |
152 SkPicture* SkPicture::CreateFromStream(SkStream* stream, InstallPixelRefProc pro
c) { | 141 SkPicture* SkPicture::CreateFromStream(SkStream* stream, InstallPixelRefProc pro
c) { |
153 return CreateFromStream(stream, proc, nullptr); | 142 return CreateFromStream(stream, proc, nullptr); |
154 } | 143 } |
155 | 144 |
156 SkPicture* SkPicture::CreateFromStream(SkStream* stream, | 145 SkPicture* SkPicture::CreateFromStream(SkStream* stream, |
157 InstallPixelRefProc proc, | 146 InstallPixelRefProc proc, |
158 SkTypefacePlayback* typefaces) { | 147 SkTypefacePlayback* typefaces) { |
159 SkPictInfo info; | 148 SkPictInfo info; |
160 if (!InternalOnly_StreamIsSKP(stream, &info) || !stream->readBool()) { | 149 if (!InternalOnly_StreamIsSKP(stream, &info) || !stream->readBool()) { |
161 return nullptr; | 150 return nullptr; |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } | 216 } |
228 | 217 |
229 // Global setting to disable security precautions for serialization. | 218 // Global setting to disable security precautions for serialization. |
230 void SkPicture::SetPictureIOSecurityPrecautionsEnabled_Dangerous(bool set) { | 219 void SkPicture::SetPictureIOSecurityPrecautionsEnabled_Dangerous(bool set) { |
231 g_AllPictureIOSecurityPrecautionsEnabled = set; | 220 g_AllPictureIOSecurityPrecautionsEnabled = set; |
232 } | 221 } |
233 | 222 |
234 bool SkPicture::PictureIOSecurityPrecautionsEnabled() { | 223 bool SkPicture::PictureIOSecurityPrecautionsEnabled() { |
235 return g_AllPictureIOSecurityPrecautionsEnabled; | 224 return g_AllPictureIOSecurityPrecautionsEnabled; |
236 } | 225 } |
OLD | NEW |