Flutter Engine
The Flutter Engine
Functions
SkWriteBuffer.cpp File Reference
#include "src/core/SkWriteBuffer.h"
#include "include/core/SkAlphaType.h"
#include "include/core/SkData.h"
#include "include/core/SkFlattenable.h"
#include "include/core/SkImage.h"
#include "include/core/SkPoint.h"
#include "include/core/SkPoint3.h"
#include "include/core/SkRect.h"
#include "include/core/SkTypeface.h"
#include "include/private/base/SkAssert.h"
#include "include/private/base/SkTFitsIn.h"
#include "include/private/base/SkTo.h"
#include "src/core/SkMatrixPriv.h"
#include "src/core/SkMipmap.h"
#include "src/core/SkPaintPriv.h"
#include "src/core/SkPtrRecorder.h"
#include "src/image/SkImage_Base.h"
#include "include/core/SkBitmap.h"
#include "include/core/SkStream.h"
#include "include/encode/SkPngEncoder.h"
#include <cstring>
#include <utility>

Go to the source code of this file.

Functions

static sk_sp< SkDataserialize_image (const SkImage *image, SkSerialProcs procs)
 
static sk_sp< SkDataserialize_mipmap (const SkMipmap *mipmap, SkSerialProcs procs)
 

Function Documentation

◆ serialize_image()

static sk_sp< SkData > serialize_image ( const SkImage image,
SkSerialProcs  procs 
)
static

Definition at line 162 of file SkWriteBuffer.cpp.

162 {
164 if (procs.fImageProc) {
165 data = procs.fImageProc(const_cast<SkImage*>(image), procs.fImageCtx);
166 }
167 if (data) {
168 return data;
169 }
170 // Check to see if the image's source was an encoded block of data.
171 // If so, just use that.
173 if (data) {
174 return data;
175 }
176#if !defined(SK_DISABLE_LEGACY_PNG_WRITEBUFFER)
177 SkBitmap bm;
178 auto ib = as_IB(image);
179 if (!ib->getROPixels(ib->directContext(), &bm)) {
180 return nullptr;
181 }
184 return stream.detachAsData();
185 }
186#endif
187 return nullptr;
188}
static SkImage_Base * as_IB(SkImage *image)
Definition: SkImage_Base.h:201
const SkPixmap & pixmap() const
Definition: SkBitmap.h:133
sk_sp< SkData > refEncodedData() const
Definition: SkImage.cpp:214
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
sk_sp< const SkImage > image
Definition: SkRecords.h:269
void * fImageCtx
Definition: SkSerialProcs.h:91
SkSerialImageProc fImageProc
Definition: SkSerialProcs.h:90
std::shared_ptr< const fml::Mapping > data
Definition: texture_gles.cc:63

◆ serialize_mipmap()

static sk_sp< SkData > serialize_mipmap ( const SkMipmap mipmap,
SkSerialProcs  procs 
)
static

Definition at line 190 of file SkWriteBuffer.cpp.

190 {
191 /* Format
192 count_levels:32
193 for each level, starting with the biggest (index 0 in our iterator)
194 encoded_size:32
195 encoded_data (padded)
196 */
197 const int count = mipmap->countLevels();
198
199 // This buffer does not need procs because it is just writing SkDatas
201 buffer.write32(count);
202 for (int i = 0; i < count; ++i) {
204 if (mipmap->getLevel(i, &level)) {
205 sk_sp<SkImage> levelImage = SkImages::RasterFromPixmap(level.fPixmap, nullptr, nullptr);
206 sk_sp<SkData> levelData = serialize_image(levelImage.get(), procs);
207 buffer.writeDataAsByteArray(levelData.get());
208 } else {
209 return nullptr;
210 }
211 }
212 return buffer.snapshotAsData();
213}
int count
Definition: FontMgrTest.cpp:50
static sk_sp< SkData > serialize_image(const SkImage *image, SkSerialProcs procs)
int countLevels() const
Definition: SkMipmap.cpp:276
bool getLevel(int index, Level *) const
Definition: SkMipmap.cpp:280
T * get() const
Definition: SkRefCnt.h:303
SK_API sk_sp< SkImage > RasterFromPixmap(const SkPixmap &pixmap, RasterReleaseProc rasterReleaseProc, ReleaseContext releaseContext)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
Definition: switches.h:126