代码拉取完成,页面将自动刷新
同步操作将从 OpenHarmony-TPC/chromium_third_party_skia 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "include/core/SkCanvas.h"
#include "SkFlattenableSerialization.h"
#include "include/core/SkImageFilter.h"
#include "include/core/SkString.h"
#include "src/core/SkOSFile.h"
#include <stdio.h>
static const int kBitmapSize = 24;
static bool read_test_case(const char* filename, SkString* testdata) {
FILE* file = sk_fopen(filename, kRead_SkFILE_Flag);
if (!file) {
SkDebugf("couldn't open file %s\n", filename);
return false;
}
size_t len = sk_fgetsize(file);
if (!len) {
SkDebugf("couldn't read file %s\n", filename);
return false;
}
testdata->resize(len);
(void) fread(testdata->data(), len, file);
return true;
}
static void run_test_case(const SkString& testdata, const SkBitmap& bitmap,
SkCanvas* canvas) {
// This call shouldn't crash or cause ASAN to flag any memory issues
// If nothing bad happens within this call, everything is fine
sk_sp<SkImageFilter> flattenable = SkValidatingDeserializeImageFilter(testdata.c_str(),
testdata.size());
// Adding some info, but the test passed if we got here without any trouble
if (flattenable != nullptr) {
SkDebugf("Valid stream detected.\n");
// Let's see if using the filters can cause any trouble...
SkPaint paint;
paint.setImageFilter(flattenable);
canvas->save();
canvas->clipRect(SkRect::MakeXYWH(
0, 0, SkIntToScalar(kBitmapSize), SkIntToScalar(kBitmapSize)));
// This call shouldn't crash or cause ASAN to flag any memory issues
// If nothing bad happens within this call, everything is fine
canvas->drawBitmap(bitmap, 0, 0, &paint);
SkDebugf("Filter DAG rendered successfully.\n");
canvas->restore();
} else {
SkDebugf("Invalid stream detected.\n");
}
}
static bool read_and_run_test_case(const char* filename, const SkBitmap& bitmap,
SkCanvas* canvas) {
SkString testdata;
SkDebugf("Test case: %s\n", filename);
// read_test_case will print a useful error message if it fails.
if (!read_test_case(filename, &testdata))
return false;
run_test_case(testdata, bitmap, canvas);
return true;
}
int main(int argc, char** argv) {
int ret = 0;
SkBitmap bitmap;
bitmap.allocN32Pixels(kBitmapSize, kBitmapSize);
SkCanvas canvas(bitmap);
canvas.clear(0x00000000);
for (int i = 1; i < argc; i++)
if (!read_and_run_test_case(argv[i], bitmap, &canvas))
ret = 2;
// Cluster-Fuzz likes "#EOF" as the last line of output to help distinguish
// successful runs from crashes.
SkDebugf("#EOF\n");
return ret;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。