1cb93a386Sopenharmony_ci// Copyright 2019 Google LLC. 2cb93a386Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. 3cb93a386Sopenharmony_ci#include "tools/fiddle/examples.h" 4cb93a386Sopenharmony_ci// HASH=9c6edd836c573a0fd232d2b8aa11a678 5cb93a386Sopenharmony_ciREG_FIDDLE(Path_readFromMemory, 256, 256, true, 0) { 6cb93a386Sopenharmony_civoid draw(SkCanvas* canvas) { 7cb93a386Sopenharmony_ci SkPath path, copy; 8cb93a386Sopenharmony_ci path.lineTo(6.f / 7, 2.f / 3); 9cb93a386Sopenharmony_ci size_t size = path.writeToMemory(nullptr); 10cb93a386Sopenharmony_ci SkTDArray<char> storage; 11cb93a386Sopenharmony_ci storage.setCount(size); 12cb93a386Sopenharmony_ci path.writeToMemory(storage.begin()); 13cb93a386Sopenharmony_ci size_t wrongSize = size - 4; 14cb93a386Sopenharmony_ci size_t bytesRead = copy.readFromMemory(storage.begin(), wrongSize); 15cb93a386Sopenharmony_ci SkDebugf("length = %zu; returned by readFromMemory = %zu\n", wrongSize, bytesRead); 16cb93a386Sopenharmony_ci size_t largerSize = size + 4; 17cb93a386Sopenharmony_ci bytesRead = copy.readFromMemory(storage.begin(), largerSize); 18cb93a386Sopenharmony_ci SkDebugf("length = %zu; returned by readFromMemory = %zu\n", largerSize, bytesRead); 19cb93a386Sopenharmony_ci} 20cb93a386Sopenharmony_ci} // END FIDDLE 21