| 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" | 9 #include "SkImageGenerator.h" | 
| 10 #include "SkMessageBus.h" | 10 #include "SkMessageBus.h" | 
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 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 SkPicture* SkPicture::Forwardport(const SkPictInfo& info, const SkPictureData* d
     ata) { | 132 sk_sp<SkPicture> SkPicture::Forwardport(const SkPictInfo& info, const SkPictureD
     ata* data) { | 
| 133     if (!data) { | 133     if (!data) { | 
| 134         return nullptr; | 134         return nullptr; | 
| 135     } | 135     } | 
| 136     SkPicturePlayback playback(data); | 136     SkPicturePlayback playback(data); | 
| 137     SkPictureRecorder r; | 137     SkPictureRecorder r; | 
| 138     playback.draw(r.beginRecording(info.fCullRect), nullptr/*no callback*/); | 138     playback.draw(r.beginRecording(info.fCullRect), nullptr/*no callback*/); | 
| 139     return r.endRecording(); | 139     return r.finishRecordingAsPicture(); | 
| 140 } | 140 } | 
| 141 | 141 | 
| 142 static bool default_install(const void* src, size_t length, SkBitmap* dst) { | 142 static bool default_install(const void* src, size_t length, SkBitmap* dst) { | 
| 143     sk_sp<SkData> encoded(SkData::MakeWithCopy(src, length)); | 143     sk_sp<SkData> encoded(SkData::MakeWithCopy(src, length)); | 
| 144     return encoded && SkDEPRECATED_InstallDiscardablePixelRef( | 144     return encoded && SkDEPRECATED_InstallDiscardablePixelRef( | 
| 145             SkImageGenerator::NewFromEncoded(encoded.get()), dst); | 145             SkImageGenerator::NewFromEncoded(encoded.get()), dst); | 
| 146 } | 146 } | 
| 147 | 147 | 
| 148 SkPicture* SkPicture::CreateFromStream(SkStream* stream) { | 148 sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream) { | 
| 149     return CreateFromStream(stream, &default_install, nullptr); | 149     return MakeFromStream(stream, &default_install, nullptr); | 
| 150 } | 150 } | 
| 151 | 151 | 
| 152 SkPicture* SkPicture::CreateFromStream(SkStream* stream, InstallPixelRefProc pro
     c) { | 152 sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream, InstallPixelRefProc
      proc) { | 
| 153     return CreateFromStream(stream, proc, nullptr); | 153     return MakeFromStream(stream, proc, nullptr); | 
| 154 } | 154 } | 
| 155 | 155 | 
| 156 SkPicture* SkPicture::CreateFromStream(SkStream* stream, | 156 sk_sp<SkPicture> SkPicture::MakeFromStream(SkStream* stream, InstallPixelRefProc
      proc, | 
| 157                                        InstallPixelRefProc proc, | 157                                            SkTypefacePlayback* typefaces) { | 
| 158                                        SkTypefacePlayback* typefaces) { |  | 
| 159     SkPictInfo info; | 158     SkPictInfo info; | 
| 160     if (!InternalOnly_StreamIsSKP(stream, &info) || !stream->readBool()) { | 159     if (!InternalOnly_StreamIsSKP(stream, &info) || !stream->readBool()) { | 
| 161         return nullptr; | 160         return nullptr; | 
| 162     } | 161     } | 
| 163     SkAutoTDelete<SkPictureData> data( | 162     SkAutoTDelete<SkPictureData> data( | 
| 164             SkPictureData::CreateFromStream(stream, info, proc, typefaces)); | 163             SkPictureData::CreateFromStream(stream, info, proc, typefaces)); | 
| 165     return Forwardport(info, data); | 164     return Forwardport(info, data); | 
| 166 } | 165 } | 
| 167 | 166 | 
| 168 SkPicture* SkPicture::CreateFromBuffer(SkReadBuffer& buffer) { | 167 sk_sp<SkPicture> SkPicture::MakeFromBuffer(SkReadBuffer& buffer) { | 
| 169     SkPictInfo info; | 168     SkPictInfo info; | 
| 170     if (!InternalOnly_BufferIsSKP(&buffer, &info) || !buffer.readBool()) { | 169     if (!InternalOnly_BufferIsSKP(&buffer, &info) || !buffer.readBool()) { | 
| 171         return nullptr; | 170         return nullptr; | 
| 172     } | 171     } | 
| 173     SkAutoTDelete<SkPictureData> data(SkPictureData::CreateFromBuffer(buffer, in
     fo)); | 172     SkAutoTDelete<SkPictureData> data(SkPictureData::CreateFromBuffer(buffer, in
     fo)); | 
| 174     return Forwardport(info, data); | 173     return Forwardport(info, data); | 
| 175 } | 174 } | 
| 176 | 175 | 
| 177 SkPictureData* SkPicture::backport() const { | 176 SkPictureData* SkPicture::backport() const { | 
| 178     SkPictInfo info = this->createHeader(); | 177     SkPictInfo info = this->createHeader(); | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 227 } | 226 } | 
| 228 | 227 | 
| 229 // Global setting to disable security precautions for serialization. | 228 // Global setting to disable security precautions for serialization. | 
| 230 void SkPicture::SetPictureIOSecurityPrecautionsEnabled_Dangerous(bool set) { | 229 void SkPicture::SetPictureIOSecurityPrecautionsEnabled_Dangerous(bool set) { | 
| 231     g_AllPictureIOSecurityPrecautionsEnabled = set; | 230     g_AllPictureIOSecurityPrecautionsEnabled = set; | 
| 232 } | 231 } | 
| 233 | 232 | 
| 234 bool SkPicture::PictureIOSecurityPrecautionsEnabled() { | 233 bool SkPicture::PictureIOSecurityPrecautionsEnabled() { | 
| 235     return g_AllPictureIOSecurityPrecautionsEnabled; | 234     return g_AllPictureIOSecurityPrecautionsEnabled; | 
| 236 } | 235 } | 
| OLD | NEW | 
|---|