static bool nativeSerializeViewState(JNIEnv* env, jobject, jint jbaseLayer, jobject jstream, jbyteArray jstorage) { BaseLayerAndroid* baseLayer = (BaseLayerAndroid*) jbaseLayer; if (!baseLayer) return false; SkWStream *stream = CreateJavaOutputStreamAdaptor(env, jstream, jstorage); #if USE(ACCELERATED_COMPOSITING) // SAMSUNG CHANGE >> White flickering issue. // WAS:stream->write32(baseLayer->getBackgroundColor().rgb()); stream->write32(baseLayer->getBackgroundColor()); // SAMSUNG CHANGE << #else stream->write32(0); #endif SkPicture picture; PictureSet* content = baseLayer->content(); baseLayer->drawCanvas(picture.beginRecording(content->width(), content->height(), SkPicture::kUsePathBoundsForClip_RecordingFlag)); picture.endRecording(); if (!stream) return false; picture.serialize(stream); int childCount = baseLayer->countChildren(); XLOG("BaseLayer has %d child(ren)", childCount); stream->write32(childCount); for (int i = 0; i < childCount; i++) { LayerAndroid* layer = static_cast<LayerAndroid*>(baseLayer->getChild(i)); serializeLayer(layer, stream); } delete stream; return true; }
static bool nativeSerializeViewState(JNIEnv* env, jobject, jint jbaseLayer, jobject jstream, jbyteArray jstorage) { BaseLayerAndroid* baseLayer = (BaseLayerAndroid*) jbaseLayer; if (!baseLayer) return false; SkWStream *stream = CreateJavaOutputStreamAdaptor(env, jstream, jstorage); #if USE(ACCELERATED_COMPOSITING) stream->write32(baseLayer->getBackgroundColor().rgb()); #else stream->write32(0); #endif if (!stream) return false; if (baseLayer->content()) baseLayer->content()->serialize(stream); else return false; int childCount = baseLayer->countChildren(); ALOGV("BaseLayer has %d child(ren)", childCount); stream->write32(childCount); for (int i = 0; i < childCount; i++) { LayerAndroid* layer = static_cast<LayerAndroid*>(baseLayer->getChild(i)); serializeLayer(layer, stream); } delete stream; return true; }
static void writeTestName(const char* nameSuffix, SkWStream& outFile) { outFile.writeText(testName); outFile.writeDecAsText(testNumber); if (nameSuffix) { outFile.writeText(nameSuffix); } }
void SkRTConfRegistry::printNonDefault(const char *fname) const { SkWStream *o; if (NULL != fname) { o = new SkFILEWStream(fname); } else { o = new SkDebugWStream(); } ConfMap::Iter iter(fConfs); SkTDArray<SkRTConfBase *> *confArray; while (iter.next(&confArray)) { if (!confArray->getAt(0)->isDefault()) { confArray->getAt(0)->print(o); o->newline(); } } delete o; }
~SkPipeWriter() override { SkASSERT(SkIsAlign4(fStream->bytesWritten())); this->writeToStream(fStream); }
static void write_png_callback(png_structp png_ptr, png_bytep data, png_size_t length) { SkWStream* out = (SkWStream*) png_get_io_ptr(png_ptr); out->write(data, length); }
static size_t consumer_put(void* info, const void* buffer, size_t count) { SkWStream* stream = reinterpret_cast<SkWStream*>(info); return stream->write(buffer, count) ? count : 0; }
void SkDiffContext::outputRecords(SkWStream& stream, bool useJSONP) { DiffRecord* currentRecord = fRecords; if (useJSONP) { stream.writeText("var SkPDiffRecords = {\n"); } else { stream.writeText("{\n"); } stream.writeText(" \"records\": [\n"); while (NULL != currentRecord) { stream.writeText(" {\n"); stream.writeText(" \"baselinePath\": \""); stream.writeText(currentRecord->fBaselinePath.c_str()); stream.writeText("\",\n"); stream.writeText(" \"testPath\": \""); stream.writeText(currentRecord->fTestPath.c_str()); stream.writeText("\",\n"); stream.writeText(" \"diffs\": [\n"); for (int diffIndex = 0; diffIndex < currentRecord->fDiffs.count(); diffIndex++) { DiffData& data = currentRecord->fDiffs[diffIndex]; stream.writeText(" {\n"); stream.writeText(" \"differName\": \""); stream.writeText(data.fDiffName); stream.writeText("\",\n"); stream.writeText(" \"result\": "); stream.writeScalarAsText(data.fResult); stream.writeText(",\n"); stream.writeText(" \"pointsOfInterest\": [\n"); for (int poiIndex = 0; poiIndex < data.fPointsOfInterest.count(); poiIndex++) { SkIPoint poi = data.fPointsOfInterest[poiIndex]; stream.writeText(" ["); stream.writeDecAsText(poi.x()); stream.writeText(","); stream.writeDecAsText(poi.y()); stream.writeText("]"); // JSON does not allow trailing commas if (poiIndex + 1 < data.fPointsOfInterest.count()) { stream.writeText(","); } stream.writeText("\n"); } stream.writeText(" ]\n"); stream.writeText(" }"); // JSON does not allow trailing commas if (diffIndex + 1 < currentRecord->fDiffs.count()) { stream.writeText(","); } stream.writeText(" \n"); } stream.writeText(" ]\n"); stream.writeText(" }"); // JSON does not allow trailing commas if (NULL != currentRecord->fNext) { stream.writeText(","); } stream.writeText("\n"); currentRecord = currentRecord->fNext; } stream.writeText(" ]\n"); if (useJSONP) { stream.writeText("};\n"); } else { stream.writeText("}\n"); } }
static void tab(SkWStream& stream, int level) { for (int i = 0; i < level; i++) stream.writeText("\t"); }
void outputToStream(const State4& state, const char* pathStr, const char* pathPrefix, const char* nameSuffix, const char* testFunction, SkWStream& outFile) { outFile.writeText("<div id=\""); writeTestName(nameSuffix, outFile); outFile.writeText("\">\n"); if (pathPrefix) { outFile.writeText(pathPrefix); } outFile.writeText(pathStr); outFile.writeText("</div>\n\n"); outFile.writeText(marker); outFile.writeText(" "); writeTestName(nameSuffix, outFile); outFile.writeText(",\n\n\n"); outFile.writeText("static void "); writeTestName(nameSuffix, outFile); outFile.writeText("() {\n SkPath path;\n"); if (pathPrefix) { outFile.writeText(pathPrefix); } outFile.writeText(pathStr); outFile.writeText(" "); outFile.writeText(testFunction); outFile.writeText("\n}\n\n"); outFile.writeText("static void (*firstTest)() = "); writeTestName(nameSuffix, outFile); outFile.writeText(";\n\n"); outFile.writeText("static struct {\n"); outFile.writeText(" void (*fun)();\n"); outFile.writeText(" const char* str;\n"); outFile.writeText("} tests[] = {\n"); outFile.writeText(" TEST("); writeTestName(nameSuffix, outFile); outFile.writeText("),\n"); outFile.flush(); }
static void sk_write_fn(png_structp png_ptr, png_bytep data, png_size_t len) { SkWStream* stream = (SkWStream*)png_get_io_ptr(png_ptr); if (!stream->write(data, len)) { png_error(png_ptr, "sk_write_fn cannot write to stream"); } }