2013-03-28 13:49:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2013 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2014-01-10 22:08:27 +00:00
|
|
|
|
2016-02-05 15:17:34 +00:00
|
|
|
#include <functional>
|
2013-03-28 13:49:22 +00:00
|
|
|
#include "SkCanvas.h"
|
2016-08-30 14:07:59 +00:00
|
|
|
#include "SkColorSpace_Base.h"
|
2014-02-06 14:11:56 +00:00
|
|
|
#include "SkData.h"
|
2015-06-09 19:16:53 +00:00
|
|
|
#include "SkDevice.h"
|
2015-06-10 15:49:28 +00:00
|
|
|
#include "SkImage_Base.h"
|
2016-11-28 23:28:07 +00:00
|
|
|
#include "SkOverdrawCanvas.h"
|
2015-08-05 20:57:49 +00:00
|
|
|
#include "SkPath.h"
|
2013-03-28 13:49:22 +00:00
|
|
|
#include "SkRRect.h"
|
|
|
|
#include "SkSurface.h"
|
2014-02-06 14:11:56 +00:00
|
|
|
#include "SkUtils.h"
|
2013-03-28 13:49:22 +00:00
|
|
|
#include "Test.h"
|
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
#include "GrContext.h"
|
2016-10-27 18:47:55 +00:00
|
|
|
#include "GrRenderTargetContext.h"
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
#include "GrGpu.h"
|
2016-05-04 19:01:58 +00:00
|
|
|
#include "GrResourceProvider.h"
|
2016-08-30 14:07:59 +00:00
|
|
|
#include <vector>
|
2013-03-28 13:49:22 +00:00
|
|
|
#endif
|
|
|
|
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
#include <initializer_list>
|
2015-06-23 21:38:48 +00:00
|
|
|
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
static void release_direct_surface_storage(void* pixels, void* context) {
|
2014-06-27 13:48:14 +00:00
|
|
|
SkASSERT(pixels == context);
|
|
|
|
sk_free(pixels);
|
|
|
|
}
|
2016-03-24 01:59:25 +00:00
|
|
|
static sk_sp<SkSurface> create_surface(SkAlphaType at = kPremul_SkAlphaType,
|
|
|
|
SkImageInfo* requestedInfo = nullptr) {
|
2015-06-23 21:38:48 +00:00
|
|
|
const SkImageInfo info = SkImageInfo::MakeN32(10, 10, at);
|
2014-02-13 17:14:46 +00:00
|
|
|
if (requestedInfo) {
|
|
|
|
*requestedInfo = info;
|
|
|
|
}
|
2016-03-24 01:59:25 +00:00
|
|
|
return SkSurface::MakeRaster(info);
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
2016-03-24 01:59:25 +00:00
|
|
|
static sk_sp<SkSurface> create_direct_surface(SkAlphaType at = kPremul_SkAlphaType,
|
|
|
|
SkImageInfo* requestedInfo = nullptr) {
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
const SkImageInfo info = SkImageInfo::MakeN32(10, 10, at);
|
|
|
|
if (requestedInfo) {
|
|
|
|
*requestedInfo = info;
|
|
|
|
}
|
|
|
|
const size_t rowBytes = info.minRowBytes();
|
|
|
|
void* storage = sk_malloc_throw(info.getSafeSize(rowBytes));
|
2016-03-24 01:59:25 +00:00
|
|
|
return SkSurface::MakeRasterDirectReleaseProc(info, storage, rowBytes,
|
|
|
|
release_direct_surface_storage,
|
|
|
|
storage);
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
|
|
|
#if SK_SUPPORT_GPU
|
2016-03-24 01:59:25 +00:00
|
|
|
static sk_sp<SkSurface> create_gpu_surface(GrContext* context, SkAlphaType at = kPremul_SkAlphaType,
|
|
|
|
SkImageInfo* requestedInfo = nullptr) {
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
const SkImageInfo info = SkImageInfo::MakeN32(10, 10, at);
|
|
|
|
if (requestedInfo) {
|
|
|
|
*requestedInfo = info;
|
|
|
|
}
|
2016-07-26 18:38:17 +00:00
|
|
|
return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info);
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
2016-03-24 01:59:25 +00:00
|
|
|
static sk_sp<SkSurface> create_gpu_scratch_surface(GrContext* context,
|
|
|
|
SkAlphaType at = kPremul_SkAlphaType,
|
|
|
|
SkImageInfo* requestedInfo = nullptr) {
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
const SkImageInfo info = SkImageInfo::MakeN32(10, 10, at);
|
|
|
|
if (requestedInfo) {
|
|
|
|
*requestedInfo = info;
|
2013-03-28 13:49:22 +00:00
|
|
|
}
|
2016-07-26 18:38:17 +00:00
|
|
|
return SkSurface::MakeRenderTarget(context, SkBudgeted::kYes, info);
|
2013-03-28 13:49:22 +00:00
|
|
|
}
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
#endif
|
2013-03-28 13:49:22 +00:00
|
|
|
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
DEF_TEST(SurfaceEmpty, reporter) {
|
2014-12-31 20:31:43 +00:00
|
|
|
const SkImageInfo info = SkImageInfo::Make(0, 0, kN32_SkColorType, kPremul_SkAlphaType);
|
2016-03-24 01:59:25 +00:00
|
|
|
REPORTER_ASSERT(reporter, nullptr == SkSurface::MakeRaster(info));
|
|
|
|
REPORTER_ASSERT(reporter, nullptr == SkSurface::MakeRasterDirect(info, nullptr, 0));
|
2014-12-31 20:31:43 +00:00
|
|
|
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
2015-04-08 15:38:40 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2016-06-28 15:07:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceEmpty_Gpu, reporter, ctxInfo) {
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
const SkImageInfo info = SkImageInfo::Make(0, 0, kN32_SkColorType, kPremul_SkAlphaType);
|
|
|
|
REPORTER_ASSERT(reporter, nullptr ==
|
2016-07-26 18:38:17 +00:00
|
|
|
SkSurface::MakeRenderTarget(ctxInfo.grContext(), SkBudgeted::kNo, info));
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
|
|
|
#endif
|
2015-06-16 15:07:16 +00:00
|
|
|
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
static void test_canvas_peek(skiatest::Reporter* reporter,
|
2016-03-24 01:59:25 +00:00
|
|
|
sk_sp<SkSurface>& surface,
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
const SkImageInfo& requestInfo,
|
|
|
|
bool expectPeekSuccess) {
|
2014-02-13 17:14:46 +00:00
|
|
|
const SkColor color = SK_ColorRED;
|
|
|
|
const SkPMColor pmcolor = SkPreMultiplyColor(color);
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
surface->getCanvas()->clear(color);
|
|
|
|
|
2016-03-09 22:26:26 +00:00
|
|
|
SkPixmap pmap;
|
|
|
|
bool success = surface->getCanvas()->peekPixels(&pmap);
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
REPORTER_ASSERT(reporter, expectPeekSuccess == success);
|
|
|
|
|
2016-03-09 22:26:26 +00:00
|
|
|
SkPixmap pmap2;
|
|
|
|
const void* addr2 = surface->peekPixels(&pmap2) ? pmap2.addr() : nullptr;
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
|
|
|
|
if (success) {
|
2016-03-09 22:26:26 +00:00
|
|
|
REPORTER_ASSERT(reporter, requestInfo == pmap.info());
|
|
|
|
REPORTER_ASSERT(reporter, requestInfo.minRowBytes() <= pmap.rowBytes());
|
|
|
|
REPORTER_ASSERT(reporter, pmcolor == *pmap.addr32());
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
|
2016-03-09 22:26:26 +00:00
|
|
|
REPORTER_ASSERT(reporter, pmap.addr() == pmap2.addr());
|
|
|
|
REPORTER_ASSERT(reporter, pmap.info() == pmap2.info());
|
|
|
|
REPORTER_ASSERT(reporter, pmap.rowBytes() == pmap2.rowBytes());
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
} else {
|
|
|
|
REPORTER_ASSERT(reporter, nullptr == addr2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DEF_TEST(SurfaceCanvasPeek, reporter) {
|
|
|
|
for (auto& surface_func : { &create_surface, &create_direct_surface }) {
|
|
|
|
SkImageInfo requestInfo;
|
2016-03-24 01:59:25 +00:00
|
|
|
auto surface(surface_func(kPremul_SkAlphaType, &requestInfo));
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
test_canvas_peek(reporter, surface, requestInfo, true);
|
|
|
|
}
|
|
|
|
}
|
2014-07-17 17:50:59 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2016-06-28 15:07:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCanvasPeek_Gpu, reporter, ctxInfo) {
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
|
|
|
|
SkImageInfo requestInfo;
|
2016-05-11 13:33:06 +00:00
|
|
|
auto surface(surface_func(ctxInfo.grContext(), kPremul_SkAlphaType, &requestInfo));
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
test_canvas_peek(reporter, surface, requestInfo, false);
|
2014-02-13 17:14:46 +00:00
|
|
|
}
|
|
|
|
}
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
#endif
|
2014-02-13 17:14:46 +00:00
|
|
|
|
2016-03-24 01:59:25 +00:00
|
|
|
static void test_snapshot_alphatype(skiatest::Reporter* reporter, const sk_sp<SkSurface>& surface,
|
2016-08-17 21:01:05 +00:00
|
|
|
SkAlphaType expectedAlphaType) {
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
REPORTER_ASSERT(reporter, surface);
|
|
|
|
if (surface) {
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image(surface->makeImageSnapshot());
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
REPORTER_ASSERT(reporter, image);
|
|
|
|
if (image) {
|
2016-08-17 21:01:05 +00:00
|
|
|
REPORTER_ASSERT(reporter, image->alphaType() == expectedAlphaType);
|
2015-06-09 19:16:53 +00:00
|
|
|
}
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DEF_TEST(SurfaceSnapshotAlphaType, reporter) {
|
|
|
|
for (auto& surface_func : { &create_surface, &create_direct_surface }) {
|
2016-08-17 21:01:05 +00:00
|
|
|
for (auto& at: { kOpaque_SkAlphaType, kPremul_SkAlphaType, kUnpremul_SkAlphaType }) {
|
|
|
|
auto surface(surface_func(at, nullptr));
|
|
|
|
test_snapshot_alphatype(reporter, surface, at);
|
2015-06-09 19:16:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-06-23 21:38:48 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2016-06-28 15:07:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceSnapshotAlphaType_Gpu, reporter, ctxInfo) {
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
|
2016-08-17 21:01:05 +00:00
|
|
|
// GPU doesn't support creating unpremul surfaces, so only test opaque + premul
|
|
|
|
for (auto& at : { kOpaque_SkAlphaType, kPremul_SkAlphaType }) {
|
|
|
|
auto surface(surface_func(ctxInfo.grContext(), at, nullptr));
|
|
|
|
test_snapshot_alphatype(reporter, surface, at);
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
2015-06-23 21:38:48 +00:00
|
|
|
}
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
2015-06-23 21:38:48 +00:00
|
|
|
#endif
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
|
|
|
|
static GrBackendObject get_surface_backend_texture_handle(
|
|
|
|
SkSurface* s, SkSurface::BackendHandleAccess a) {
|
|
|
|
return s->getTextureHandle(a);
|
|
|
|
}
|
|
|
|
static GrBackendObject get_surface_backend_render_target_handle(
|
|
|
|
SkSurface* s, SkSurface::BackendHandleAccess a) {
|
|
|
|
GrBackendObject result;
|
|
|
|
if (!s->getRenderTargetHandle(&result, a)) {
|
|
|
|
return 0;
|
2015-06-23 21:38:48 +00:00
|
|
|
}
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
return result;
|
2015-06-23 21:38:48 +00:00
|
|
|
}
|
|
|
|
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
static void test_backend_handle_access_copy_on_write(
|
|
|
|
skiatest::Reporter* reporter, SkSurface* surface, SkSurface::BackendHandleAccess mode,
|
|
|
|
GrBackendObject (*func)(SkSurface*, SkSurface::BackendHandleAccess)) {
|
2015-08-06 14:04:51 +00:00
|
|
|
GrBackendObject obj1 = func(surface, mode);
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> snap1(surface->makeImageSnapshot());
|
2015-08-06 14:04:51 +00:00
|
|
|
|
|
|
|
GrBackendObject obj2 = func(surface, mode);
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> snap2(surface->makeImageSnapshot());
|
2015-08-06 14:04:51 +00:00
|
|
|
|
|
|
|
// If the access mode triggers CoW, then the backend objects should reflect it.
|
|
|
|
REPORTER_ASSERT(reporter, (obj1 == obj2) == (snap1 == snap2));
|
|
|
|
}
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
DEF_TEST(SurfaceBackendHandleAccessCopyOnWrite, reporter) {
|
|
|
|
const SkSurface::BackendHandleAccess accessModes[] = {
|
|
|
|
SkSurface::kFlushRead_BackendHandleAccess,
|
|
|
|
SkSurface::kFlushWrite_BackendHandleAccess,
|
|
|
|
SkSurface::kDiscardWrite_BackendHandleAccess,
|
|
|
|
};
|
|
|
|
for (auto& handle_access_func :
|
|
|
|
{ &get_surface_backend_texture_handle, &get_surface_backend_render_target_handle }) {
|
|
|
|
for (auto& accessMode : accessModes) {
|
2016-03-24 01:59:25 +00:00
|
|
|
auto surface(create_surface());
|
|
|
|
test_backend_handle_access_copy_on_write(reporter, surface.get(), accessMode,
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
handle_access_func);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#if SK_SUPPORT_GPU
|
2016-04-12 16:59:58 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBackendHandleAccessCopyOnWrite_Gpu, reporter, ctxInfo) {
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
const SkSurface::BackendHandleAccess accessModes[] = {
|
|
|
|
SkSurface::kFlushRead_BackendHandleAccess,
|
|
|
|
SkSurface::kFlushWrite_BackendHandleAccess,
|
|
|
|
SkSurface::kDiscardWrite_BackendHandleAccess,
|
|
|
|
};
|
|
|
|
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
|
|
|
|
for (auto& handle_access_func :
|
|
|
|
{ &get_surface_backend_texture_handle, &get_surface_backend_render_target_handle }) {
|
|
|
|
for (auto& accessMode : accessModes) {
|
2016-05-11 13:33:06 +00:00
|
|
|
auto surface(surface_func(ctxInfo.grContext(), kPremul_SkAlphaType, nullptr));
|
2016-03-24 01:59:25 +00:00
|
|
|
test_backend_handle_access_copy_on_write(reporter, surface.get(), accessMode,
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
handle_access_func);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2015-08-06 14:04:51 +00:00
|
|
|
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2016-07-21 14:17:54 +00:00
|
|
|
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
static void test_backend_handle_unique_id(
|
|
|
|
skiatest::Reporter* reporter, SkSurface* surface,
|
|
|
|
GrBackendObject (*func)(SkSurface*, SkSurface::BackendHandleAccess)) {
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image0(surface->makeImageSnapshot());
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
GrBackendObject obj = func(surface, SkSurface::kFlushRead_BackendHandleAccess);
|
|
|
|
REPORTER_ASSERT(reporter, obj != 0);
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image1(surface->makeImageSnapshot());
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
// just read access should not affect the snapshot
|
|
|
|
REPORTER_ASSERT(reporter, image0->uniqueID() == image1->uniqueID());
|
|
|
|
|
|
|
|
obj = func(surface, SkSurface::kFlushWrite_BackendHandleAccess);
|
|
|
|
REPORTER_ASSERT(reporter, obj != 0);
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image2(surface->makeImageSnapshot());
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
// expect a new image, since we claimed we would write
|
|
|
|
REPORTER_ASSERT(reporter, image0->uniqueID() != image2->uniqueID());
|
|
|
|
|
|
|
|
obj = func(surface, SkSurface::kDiscardWrite_BackendHandleAccess);
|
|
|
|
REPORTER_ASSERT(reporter, obj != 0);
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image3(surface->makeImageSnapshot());
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
// expect a new(er) image, since we claimed we would write
|
|
|
|
REPORTER_ASSERT(reporter, image0->uniqueID() != image3->uniqueID());
|
|
|
|
REPORTER_ASSERT(reporter, image2->uniqueID() != image3->uniqueID());
|
|
|
|
}
|
|
|
|
// No CPU test.
|
2016-04-12 16:59:58 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBackendHandleAccessIDs_Gpu, reporter, ctxInfo) {
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
|
2016-07-21 14:17:54 +00:00
|
|
|
for (auto& test_func : { &test_backend_handle_unique_id }) {
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
for (auto& handle_access_func :
|
|
|
|
{ &get_surface_backend_texture_handle, &get_surface_backend_render_target_handle}) {
|
2016-05-11 13:33:06 +00:00
|
|
|
auto surface(surface_func(ctxInfo.grContext(), kPremul_SkAlphaType, nullptr));
|
2016-03-24 01:59:25 +00:00
|
|
|
test_func(reporter, surface.get(), handle_access_func);
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Verify that the right canvas commands trigger a copy on write.
|
|
|
|
static void test_copy_on_write(skiatest::Reporter* reporter, SkSurface* surface) {
|
2013-03-28 13:49:22 +00:00
|
|
|
SkCanvas* canvas = surface->getCanvas();
|
|
|
|
|
|
|
|
const SkRect testRect =
|
|
|
|
SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0),
|
|
|
|
SkIntToScalar(4), SkIntToScalar(5));
|
|
|
|
SkPath testPath;
|
|
|
|
testPath.addRect(SkRect::MakeXYWH(SkIntToScalar(0), SkIntToScalar(0),
|
|
|
|
SkIntToScalar(2), SkIntToScalar(1)));
|
|
|
|
|
|
|
|
const SkIRect testIRect = SkIRect::MakeXYWH(0, 0, 2, 1);
|
|
|
|
|
|
|
|
SkRegion testRegion;
|
|
|
|
testRegion.setRect(testIRect);
|
|
|
|
|
|
|
|
|
|
|
|
const SkColor testColor = 0x01020304;
|
|
|
|
const SkPaint testPaint;
|
|
|
|
const SkPoint testPoints[3] = {
|
|
|
|
{SkIntToScalar(0), SkIntToScalar(0)},
|
|
|
|
{SkIntToScalar(2), SkIntToScalar(1)},
|
|
|
|
{SkIntToScalar(0), SkIntToScalar(2)}
|
|
|
|
};
|
|
|
|
const size_t testPointCount = 3;
|
|
|
|
|
|
|
|
SkBitmap testBitmap;
|
2014-02-13 14:41:43 +00:00
|
|
|
testBitmap.allocN32Pixels(10, 10);
|
2013-10-09 12:51:09 +00:00
|
|
|
testBitmap.eraseColor(0);
|
2013-03-28 13:49:22 +00:00
|
|
|
|
|
|
|
SkRRect testRRect;
|
|
|
|
testRRect.setRectXY(testRect, SK_Scalar1, SK_Scalar1);
|
|
|
|
|
|
|
|
SkString testText("Hello World");
|
|
|
|
const SkPoint testPoints2[] = {
|
|
|
|
{ SkIntToScalar(0), SkIntToScalar(1) },
|
|
|
|
{ SkIntToScalar(1), SkIntToScalar(1) },
|
|
|
|
{ SkIntToScalar(2), SkIntToScalar(1) },
|
|
|
|
{ SkIntToScalar(3), SkIntToScalar(1) },
|
|
|
|
{ SkIntToScalar(4), SkIntToScalar(1) },
|
|
|
|
{ SkIntToScalar(5), SkIntToScalar(1) },
|
|
|
|
{ SkIntToScalar(6), SkIntToScalar(1) },
|
|
|
|
{ SkIntToScalar(7), SkIntToScalar(1) },
|
|
|
|
{ SkIntToScalar(8), SkIntToScalar(1) },
|
|
|
|
{ SkIntToScalar(9), SkIntToScalar(1) },
|
|
|
|
{ SkIntToScalar(10), SkIntToScalar(1) },
|
|
|
|
};
|
|
|
|
|
|
|
|
#define EXPECT_COPY_ON_WRITE(command) \
|
|
|
|
{ \
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> imageBefore = surface->makeImageSnapshot(); \
|
|
|
|
sk_sp<SkImage> aur_before(imageBefore); \
|
2013-03-28 13:49:22 +00:00
|
|
|
canvas-> command ; \
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> imageAfter = surface->makeImageSnapshot(); \
|
|
|
|
sk_sp<SkImage> aur_after(imageAfter); \
|
2013-03-28 13:49:22 +00:00
|
|
|
REPORTER_ASSERT(reporter, imageBefore != imageAfter); \
|
|
|
|
}
|
|
|
|
|
|
|
|
EXPECT_COPY_ON_WRITE(clear(testColor))
|
|
|
|
EXPECT_COPY_ON_WRITE(drawPaint(testPaint))
|
|
|
|
EXPECT_COPY_ON_WRITE(drawPoints(SkCanvas::kPoints_PointMode, testPointCount, testPoints, \
|
|
|
|
testPaint))
|
|
|
|
EXPECT_COPY_ON_WRITE(drawOval(testRect, testPaint))
|
|
|
|
EXPECT_COPY_ON_WRITE(drawRect(testRect, testPaint))
|
|
|
|
EXPECT_COPY_ON_WRITE(drawRRect(testRRect, testPaint))
|
|
|
|
EXPECT_COPY_ON_WRITE(drawPath(testPath, testPaint))
|
|
|
|
EXPECT_COPY_ON_WRITE(drawBitmap(testBitmap, 0, 0))
|
2015-08-06 17:02:53 +00:00
|
|
|
EXPECT_COPY_ON_WRITE(drawBitmapRect(testBitmap, testRect, nullptr))
|
2015-08-27 14:41:13 +00:00
|
|
|
EXPECT_COPY_ON_WRITE(drawBitmapNine(testBitmap, testIRect, testRect, nullptr))
|
2013-03-28 13:49:22 +00:00
|
|
|
EXPECT_COPY_ON_WRITE(drawText(testText.c_str(), testText.size(), 0, 1, testPaint))
|
|
|
|
EXPECT_COPY_ON_WRITE(drawPosText(testText.c_str(), testText.size(), testPoints2, \
|
|
|
|
testPaint))
|
2015-08-27 14:41:13 +00:00
|
|
|
EXPECT_COPY_ON_WRITE(drawTextOnPath(testText.c_str(), testText.size(), testPath, nullptr, \
|
2013-03-28 13:49:22 +00:00
|
|
|
testPaint))
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
|
|
|
DEF_TEST(SurfaceCopyOnWrite, reporter) {
|
2016-03-24 01:59:25 +00:00
|
|
|
test_copy_on_write(reporter, create_surface().get());
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
|
|
|
#if SK_SUPPORT_GPU
|
2016-06-28 15:07:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCopyOnWrite_Gpu, reporter, ctxInfo) {
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
|
2016-05-11 13:33:06 +00:00
|
|
|
auto surface(surface_func(ctxInfo.grContext(), kPremul_SkAlphaType, nullptr));
|
2016-03-24 01:59:25 +00:00
|
|
|
test_copy_on_write(reporter, surface.get());
|
2015-08-06 14:04:51 +00:00
|
|
|
}
|
2013-03-28 13:49:22 +00:00
|
|
|
}
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
#endif
|
2013-03-28 13:49:22 +00:00
|
|
|
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
static void test_writable_after_snapshot_release(skiatest::Reporter* reporter,
|
|
|
|
SkSurface* surface) {
|
2013-04-03 15:03:26 +00:00
|
|
|
// This test succeeds by not triggering an assertion.
|
|
|
|
// The test verifies that the surface remains writable (usable) after
|
|
|
|
// acquiring and releasing a snapshot without triggering a copy on write.
|
|
|
|
SkCanvas* canvas = surface->getCanvas();
|
|
|
|
canvas->clear(1);
|
2016-03-17 17:51:11 +00:00
|
|
|
surface->makeImageSnapshot(); // Create and destroy SkImage
|
2013-07-25 23:29:40 +00:00
|
|
|
canvas->clear(2); // Must not assert internally
|
2013-03-28 13:49:22 +00:00
|
|
|
}
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
DEF_TEST(SurfaceWriteableAfterSnapshotRelease, reporter) {
|
2016-03-24 01:59:25 +00:00
|
|
|
test_writable_after_snapshot_release(reporter, create_surface().get());
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
|
|
|
#if SK_SUPPORT_GPU
|
2016-06-28 15:07:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceWriteableAfterSnapshotRelease_Gpu, reporter, ctxInfo) {
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
|
2016-05-11 13:33:06 +00:00
|
|
|
auto surface(surface_func(ctxInfo.grContext(), kPremul_SkAlphaType, nullptr));
|
2016-03-24 01:59:25 +00:00
|
|
|
test_writable_after_snapshot_release(reporter, surface.get());
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2013-05-01 22:38:16 +00:00
|
|
|
|
2013-05-01 22:49:59 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
static void test_crbug263329(skiatest::Reporter* reporter,
|
|
|
|
SkSurface* surface1,
|
|
|
|
SkSurface* surface2) {
|
2013-07-25 23:29:40 +00:00
|
|
|
// This is a regression test for crbug.com/263329
|
|
|
|
// Bug was caused by onCopyOnWrite releasing the old surface texture
|
|
|
|
// back to the scratch texture pool even though the texture is used
|
|
|
|
// by and active SkImage_Gpu.
|
|
|
|
SkCanvas* canvas1 = surface1->getCanvas();
|
|
|
|
SkCanvas* canvas2 = surface2->getCanvas();
|
|
|
|
canvas1->clear(1);
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image1(surface1->makeImageSnapshot());
|
2013-07-25 23:29:40 +00:00
|
|
|
// Trigger copy on write, new backing is a scratch texture
|
|
|
|
canvas1->clear(2);
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image2(surface1->makeImageSnapshot());
|
2013-07-25 23:29:40 +00:00
|
|
|
// Trigger copy on write, old backing should not be returned to scratch
|
|
|
|
// pool because it is held by image2
|
|
|
|
canvas1->clear(3);
|
|
|
|
|
|
|
|
canvas2->clear(4);
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image3(surface2->makeImageSnapshot());
|
2013-07-25 23:29:40 +00:00
|
|
|
// Trigger copy on write on surface2. The new backing store should not
|
|
|
|
// be recycling a texture that is held by an existing image.
|
|
|
|
canvas2->clear(5);
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image4(surface2->makeImageSnapshot());
|
2016-02-29 19:41:52 +00:00
|
|
|
REPORTER_ASSERT(reporter, as_IB(image4)->peekTexture() != as_IB(image3)->peekTexture());
|
2013-07-25 23:29:40 +00:00
|
|
|
// The following assertion checks crbug.com/263329
|
2016-02-29 19:41:52 +00:00
|
|
|
REPORTER_ASSERT(reporter, as_IB(image4)->peekTexture() != as_IB(image2)->peekTexture());
|
|
|
|
REPORTER_ASSERT(reporter, as_IB(image4)->peekTexture() != as_IB(image1)->peekTexture());
|
|
|
|
REPORTER_ASSERT(reporter, as_IB(image3)->peekTexture() != as_IB(image2)->peekTexture());
|
|
|
|
REPORTER_ASSERT(reporter, as_IB(image3)->peekTexture() != as_IB(image1)->peekTexture());
|
|
|
|
REPORTER_ASSERT(reporter, as_IB(image2)->peekTexture() != as_IB(image1)->peekTexture());
|
2013-07-25 23:29:40 +00:00
|
|
|
}
|
2016-06-28 15:07:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCRBug263329_Gpu, reporter, ctxInfo) {
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
|
2016-05-11 13:33:06 +00:00
|
|
|
auto surface1(surface_func(ctxInfo.grContext(), kPremul_SkAlphaType, nullptr));
|
|
|
|
auto surface2(surface_func(ctxInfo.grContext(), kPremul_SkAlphaType, nullptr));
|
2016-03-24 01:59:25 +00:00
|
|
|
test_crbug263329(reporter, surface1.get(), surface2.get());
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2013-07-25 23:29:40 +00:00
|
|
|
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
DEF_TEST(SurfaceGetTexture, reporter) {
|
2016-03-24 01:59:25 +00:00
|
|
|
auto surface(create_surface());
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image(surface->makeImageSnapshot());
|
2016-02-29 19:41:52 +00:00
|
|
|
REPORTER_ASSERT(reporter, as_IB(image)->peekTexture() == nullptr);
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode);
|
2016-02-29 19:41:52 +00:00
|
|
|
REPORTER_ASSERT(reporter, as_IB(image)->peekTexture() == nullptr);
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
|
|
|
#if SK_SUPPORT_GPU
|
2016-06-28 15:07:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacepeekTexture_Gpu, reporter, ctxInfo) {
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
|
2016-05-11 13:33:06 +00:00
|
|
|
auto surface(surface_func(ctxInfo.grContext(), kPremul_SkAlphaType, nullptr));
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image(surface->makeImageSnapshot());
|
2016-02-29 19:41:52 +00:00
|
|
|
GrTexture* texture = as_IB(image)->peekTexture();
|
2014-09-05 20:34:00 +00:00
|
|
|
REPORTER_ASSERT(reporter, texture);
|
2013-05-01 22:38:16 +00:00
|
|
|
REPORTER_ASSERT(reporter, 0 != texture->getTextureHandle());
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
surface->notifyContentWillChange(SkSurface::kDiscard_ContentChangeMode);
|
2016-02-29 19:41:52 +00:00
|
|
|
REPORTER_ASSERT(reporter, as_IB(image)->peekTexture() == texture);
|
2013-05-01 22:38:16 +00:00
|
|
|
}
|
|
|
|
}
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
#endif
|
2015-01-23 16:08:04 +00:00
|
|
|
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2015-02-13 22:20:05 +00:00
|
|
|
#include "GrGpuResourcePriv.h"
|
2015-01-23 16:08:04 +00:00
|
|
|
#include "SkGpuDevice.h"
|
|
|
|
#include "SkImage_Gpu.h"
|
|
|
|
#include "SkSurface_Gpu.h"
|
|
|
|
|
2016-03-24 01:59:25 +00:00
|
|
|
static SkBudgeted is_budgeted(const sk_sp<SkSurface>& surf) {
|
|
|
|
SkSurface_Gpu* gsurf = (SkSurface_Gpu*)surf.get();
|
2016-10-27 18:47:55 +00:00
|
|
|
return gsurf->getDevice()->accessRenderTargetContext()
|
|
|
|
->accessRenderTarget()->resourcePriv().isBudgeted();
|
2015-01-23 16:08:04 +00:00
|
|
|
}
|
|
|
|
|
2016-02-25 16:33:02 +00:00
|
|
|
static SkBudgeted is_budgeted(SkImage* image) {
|
2016-02-29 19:41:52 +00:00
|
|
|
return ((SkImage_Gpu*)image)->peekTexture()->resourcePriv().isBudgeted();
|
2015-01-23 16:08:04 +00:00
|
|
|
}
|
|
|
|
|
2016-03-17 17:51:11 +00:00
|
|
|
static SkBudgeted is_budgeted(const sk_sp<SkImage> image) {
|
|
|
|
return is_budgeted(image.get());
|
|
|
|
}
|
|
|
|
|
2016-06-28 15:07:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceBudget, reporter, ctxInfo) {
|
2015-01-23 16:08:04 +00:00
|
|
|
SkImageInfo info = SkImageInfo::MakeN32Premul(8,8);
|
2016-02-25 16:33:02 +00:00
|
|
|
for (auto sbudgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) {
|
|
|
|
for (auto ibudgeted : { SkBudgeted::kNo, SkBudgeted::kYes }) {
|
2016-05-11 13:33:06 +00:00
|
|
|
auto surface(SkSurface::MakeRenderTarget(ctxInfo.grContext(), sbudgeted, info));
|
2015-01-23 16:08:04 +00:00
|
|
|
SkASSERT(surface);
|
|
|
|
REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface));
|
|
|
|
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image(surface->makeImageSnapshot(ibudgeted));
|
2015-01-23 16:08:04 +00:00
|
|
|
|
|
|
|
// Initially the image shares a texture with the surface, and the surface decides
|
|
|
|
// whether it is budgeted or not.
|
|
|
|
REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface));
|
|
|
|
REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(image));
|
|
|
|
|
|
|
|
// Now trigger copy-on-write
|
|
|
|
surface->getCanvas()->clear(SK_ColorBLUE);
|
|
|
|
|
|
|
|
// They don't share a texture anymore. They should each have made their own budget
|
|
|
|
// decision.
|
|
|
|
REPORTER_ASSERT(reporter, sbudgeted == is_budgeted(surface));
|
|
|
|
REPORTER_ASSERT(reporter, ibudgeted == is_budgeted(image));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-05-01 22:49:59 +00:00
|
|
|
#endif
|
2013-05-01 22:38:16 +00:00
|
|
|
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
static void test_no_canvas1(skiatest::Reporter* reporter,
|
|
|
|
SkSurface* surface,
|
|
|
|
SkSurface::ContentChangeMode mode) {
|
|
|
|
// Test passes by not asserting
|
|
|
|
surface->notifyContentWillChange(mode);
|
|
|
|
SkDEBUGCODE(surface->validate();)
|
|
|
|
}
|
|
|
|
static void test_no_canvas2(skiatest::Reporter* reporter,
|
|
|
|
SkSurface* surface,
|
|
|
|
SkSurface::ContentChangeMode mode) {
|
2013-04-16 19:41:09 +00:00
|
|
|
// Verifies the robustness of SkSurface for handling use cases where calls
|
|
|
|
// are made before a canvas is created.
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image1 = surface->makeImageSnapshot();
|
|
|
|
sk_sp<SkImage> aur_image1(image1);
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
SkDEBUGCODE(image1->validate();)
|
|
|
|
SkDEBUGCODE(surface->validate();)
|
|
|
|
surface->notifyContentWillChange(mode);
|
|
|
|
SkDEBUGCODE(image1->validate();)
|
|
|
|
SkDEBUGCODE(surface->validate();)
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image2 = surface->makeImageSnapshot();
|
|
|
|
sk_sp<SkImage> aur_image2(image2);
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
SkDEBUGCODE(image2->validate();)
|
|
|
|
SkDEBUGCODE(surface->validate();)
|
|
|
|
REPORTER_ASSERT(reporter, image1 != image2);
|
|
|
|
}
|
|
|
|
DEF_TEST(SurfaceNoCanvas, reporter) {
|
|
|
|
SkSurface::ContentChangeMode modes[] =
|
|
|
|
{ SkSurface::kDiscard_ContentChangeMode, SkSurface::kRetain_ContentChangeMode};
|
|
|
|
for (auto& test_func : { &test_no_canvas1, &test_no_canvas2 }) {
|
|
|
|
for (auto& mode : modes) {
|
2016-03-24 01:59:25 +00:00
|
|
|
test_func(reporter, create_surface().get(), mode);
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
}
|
2013-04-16 19:41:09 +00:00
|
|
|
}
|
|
|
|
}
|
2013-05-01 22:49:59 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2016-06-28 15:07:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceNoCanvas_Gpu, reporter, ctxInfo) {
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
SkSurface::ContentChangeMode modes[] =
|
|
|
|
{ SkSurface::kDiscard_ContentChangeMode, SkSurface::kRetain_ContentChangeMode};
|
|
|
|
for (auto& surface_func : { &create_gpu_surface, &create_gpu_scratch_surface }) {
|
|
|
|
for (auto& test_func : { &test_no_canvas1, &test_no_canvas2 }) {
|
|
|
|
for (auto& mode : modes) {
|
2016-05-11 13:33:06 +00:00
|
|
|
auto surface(surface_func(ctxInfo.grContext(), kPremul_SkAlphaType, nullptr));
|
2016-03-24 01:59:25 +00:00
|
|
|
test_func(reporter, surface.get(), mode);
|
2014-07-17 17:50:59 +00:00
|
|
|
}
|
2013-11-12 13:51:03 +00:00
|
|
|
}
|
2013-04-03 15:03:26 +00:00
|
|
|
}
|
2013-03-28 13:49:22 +00:00
|
|
|
}
|
Generate list of GPU contexts outside SurfaceTest tests
Add support for feeding the tests with contexts directly to the unit
test framework.
This fixes the problem where tests are more complex than needed just in
order to run the test code with multiple backends.
Also makes it possible to change the logic how contexts are
created. Instead of direct numbering, the different testable contexts
may be generated from filtered cross-product of context options. For
example: currently NVPR is a type of context. However, it could be also
an on/off feature of any context. In order to test this kind of context,
the enumeration can not be just of context type. It's simpler
to move the enumeration out of the tests.
A test targeting both normal and GPU backends would look like:
static void test_obj_behavior(skiatest::Reporter* reporter,
SkObj* obj, [other params] ) {
... test with obj and param ..
}
DEF_TEST(ObjBehavior, reporter) {
for (auto& object : generate_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#if SK_SUPPORT_GPU
DEF_GPUTEST_FOR_ALL_CONTEXTS(ObjBehavior_Gpu, reporter, context) {
for (auto& object : generate_gpu_object) {
for (auto& other_param : generate_other_variant) {
test_obj_behavior(reporter, object, other_param);
}
}
}
#endif
Uses the feature in SurfaceTests as an example.
Moves SkSurface -related tests from ImageTest to SurfaceTest.
BUG=skia:2992
Review URL: https://codereview.chromium.org/1446453003
2015-11-20 21:32:24 +00:00
|
|
|
#endif
|
2016-01-30 18:01:06 +00:00
|
|
|
|
|
|
|
static void check_rowbytes_remain_consistent(SkSurface* surface, skiatest::Reporter* reporter) {
|
2016-03-09 22:26:26 +00:00
|
|
|
SkPixmap surfacePM;
|
|
|
|
REPORTER_ASSERT(reporter, surface->peekPixels(&surfacePM));
|
2016-01-30 18:01:06 +00:00
|
|
|
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image(surface->makeImageSnapshot());
|
2016-03-09 22:26:26 +00:00
|
|
|
SkPixmap pm;
|
|
|
|
REPORTER_ASSERT(reporter, image->peekPixels(&pm));
|
2016-01-30 18:01:06 +00:00
|
|
|
|
2016-03-09 22:26:26 +00:00
|
|
|
REPORTER_ASSERT(reporter, surfacePM.rowBytes() == pm.rowBytes());
|
2016-01-30 18:01:06 +00:00
|
|
|
|
|
|
|
// trigger a copy-on-write
|
|
|
|
surface->getCanvas()->drawPaint(SkPaint());
|
2016-03-17 17:51:11 +00:00
|
|
|
sk_sp<SkImage> image2(surface->makeImageSnapshot());
|
2016-01-30 18:01:06 +00:00
|
|
|
REPORTER_ASSERT(reporter, image->uniqueID() != image2->uniqueID());
|
|
|
|
|
2016-03-09 22:26:26 +00:00
|
|
|
SkPixmap pm2;
|
|
|
|
REPORTER_ASSERT(reporter, image2->peekPixels(&pm2));
|
|
|
|
REPORTER_ASSERT(reporter, pm2.rowBytes() == pm.rowBytes());
|
2016-01-30 18:01:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DEF_TEST(surface_rowbytes, reporter) {
|
|
|
|
const SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
|
|
|
|
|
2016-03-24 01:59:25 +00:00
|
|
|
auto surf0(SkSurface::MakeRaster(info));
|
|
|
|
check_rowbytes_remain_consistent(surf0.get(), reporter);
|
2016-01-30 18:01:06 +00:00
|
|
|
|
|
|
|
// specify a larger rowbytes
|
2016-03-24 01:59:25 +00:00
|
|
|
auto surf1(SkSurface::MakeRaster(info, 500, nullptr));
|
|
|
|
check_rowbytes_remain_consistent(surf1.get(), reporter);
|
2016-01-30 18:01:06 +00:00
|
|
|
|
|
|
|
// Try some illegal rowByte values
|
2016-03-24 01:59:25 +00:00
|
|
|
auto s = SkSurface::MakeRaster(info, 396, nullptr); // needs to be at least 400
|
2016-01-30 18:01:06 +00:00
|
|
|
REPORTER_ASSERT(reporter, nullptr == s);
|
2016-03-24 01:59:25 +00:00
|
|
|
s = SkSurface::MakeRaster(info, 1 << 30, nullptr); // allocation to large
|
2016-01-30 18:01:06 +00:00
|
|
|
REPORTER_ASSERT(reporter, nullptr == s);
|
|
|
|
}
|
2016-02-05 15:17:34 +00:00
|
|
|
|
2016-07-06 13:22:06 +00:00
|
|
|
DEF_TEST(surface_raster_zeroinitialized, reporter) {
|
|
|
|
sk_sp<SkSurface> s(SkSurface::MakeRasterN32Premul(100, 100));
|
|
|
|
SkPixmap pixmap;
|
|
|
|
REPORTER_ASSERT(reporter, s->peekPixels(&pixmap));
|
|
|
|
|
|
|
|
for (int i = 0; i < pixmap.info().width(); ++i) {
|
|
|
|
for (int j = 0; j < pixmap.info().height(); ++j) {
|
|
|
|
REPORTER_ASSERT(reporter, *pixmap.addr32(i, j) == 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-02-05 15:17:34 +00:00
|
|
|
#if SK_SUPPORT_GPU
|
2016-05-04 19:01:58 +00:00
|
|
|
static sk_sp<SkSurface> create_gpu_surface_backend_texture(
|
|
|
|
GrContext* context, int sampleCnt, uint32_t color, GrBackendObject* outTexture) {
|
|
|
|
const int kWidth = 10;
|
|
|
|
const int kHeight = 10;
|
2016-11-02 21:07:33 +00:00
|
|
|
std::unique_ptr<uint32_t[]> pixels(new uint32_t[kWidth * kHeight]);
|
2016-05-04 19:01:58 +00:00
|
|
|
sk_memset32(pixels.get(), color, kWidth * kHeight);
|
|
|
|
GrBackendTextureDesc desc;
|
|
|
|
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
|
|
|
desc.fWidth = kWidth;
|
|
|
|
desc.fHeight = kHeight;
|
|
|
|
desc.fFlags = kRenderTarget_GrBackendTextureFlag;
|
|
|
|
desc.fTextureHandle = context->getGpu()->createTestingOnlyBackendTexture(
|
2016-06-24 16:22:31 +00:00
|
|
|
pixels.get(), kWidth, kHeight, kRGBA_8888_GrPixelConfig, true);
|
2016-05-04 19:01:58 +00:00
|
|
|
desc.fSampleCnt = sampleCnt;
|
|
|
|
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTexture(context, desc, nullptr);
|
|
|
|
if (!surface) {
|
|
|
|
context->getGpu()->deleteTestingOnlyBackendTexture(desc.fTextureHandle);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
*outTexture = desc.fTextureHandle;
|
|
|
|
return surface;
|
|
|
|
}
|
|
|
|
|
|
|
|
static sk_sp<SkSurface> create_gpu_surface_backend_texture_as_render_target(
|
|
|
|
GrContext* context, int sampleCnt, uint32_t color, GrBackendObject* outTexture) {
|
|
|
|
const int kWidth = 10;
|
|
|
|
const int kHeight = 10;
|
2016-11-02 21:07:33 +00:00
|
|
|
std::unique_ptr<uint32_t[]> pixels(new uint32_t[kWidth * kHeight]);
|
2016-05-04 19:01:58 +00:00
|
|
|
sk_memset32(pixels.get(), color, kWidth * kHeight);
|
|
|
|
GrBackendTextureDesc desc;
|
|
|
|
desc.fConfig = kRGBA_8888_GrPixelConfig;
|
|
|
|
desc.fWidth = kWidth;
|
|
|
|
desc.fHeight = kHeight;
|
|
|
|
desc.fFlags = kRenderTarget_GrBackendTextureFlag;
|
|
|
|
desc.fTextureHandle = context->getGpu()->createTestingOnlyBackendTexture(
|
2016-06-24 16:22:31 +00:00
|
|
|
pixels.get(), kWidth, kHeight, kRGBA_8888_GrPixelConfig, true);
|
2016-05-04 19:01:58 +00:00
|
|
|
desc.fSampleCnt = sampleCnt;
|
|
|
|
sk_sp<SkSurface> surface = SkSurface::MakeFromBackendTextureAsRenderTarget(context, desc,
|
|
|
|
nullptr);
|
|
|
|
if (!surface) {
|
|
|
|
context->getGpu()->deleteTestingOnlyBackendTexture(desc.fTextureHandle);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
*outTexture = desc.fTextureHandle;
|
|
|
|
return surface;
|
|
|
|
}
|
2016-02-05 15:17:34 +00:00
|
|
|
|
2016-05-04 19:01:58 +00:00
|
|
|
static void test_surface_clear(skiatest::Reporter* reporter, sk_sp<SkSurface> surface,
|
|
|
|
std::function<GrSurface*(SkSurface*)> grSurfaceGetter,
|
|
|
|
uint32_t expectedValue) {
|
2016-02-05 15:17:34 +00:00
|
|
|
if (!surface) {
|
|
|
|
ERRORF(reporter, "Could not create GPU SkSurface.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
int w = surface->width();
|
|
|
|
int h = surface->height();
|
2016-11-02 21:07:33 +00:00
|
|
|
std::unique_ptr<uint32_t[]> pixels(new uint32_t[w * h]);
|
2016-05-04 19:01:58 +00:00
|
|
|
sk_memset32(pixels.get(), ~expectedValue, w * h);
|
2016-02-05 15:17:34 +00:00
|
|
|
|
2016-11-04 15:49:42 +00:00
|
|
|
sk_sp<GrSurface> grSurface(SkSafeRef(grSurfaceGetter(surface.get())));
|
2016-02-05 15:17:34 +00:00
|
|
|
if (!grSurface) {
|
|
|
|
ERRORF(reporter, "Could access render target of GPU SkSurface.");
|
|
|
|
return;
|
|
|
|
}
|
2016-02-05 21:47:06 +00:00
|
|
|
surface.reset();
|
2016-02-05 15:17:34 +00:00
|
|
|
grSurface->readPixels(0, 0, w, h, kRGBA_8888_GrPixelConfig, pixels.get());
|
|
|
|
for (int y = 0; y < h; ++y) {
|
|
|
|
for (int x = 0; x < w; ++x) {
|
|
|
|
uint32_t pixel = pixels.get()[y * w + x];
|
|
|
|
if (pixel != expectedValue) {
|
|
|
|
SkString msg;
|
|
|
|
if (expectedValue) {
|
|
|
|
msg = "SkSurface should have left render target unmodified";
|
|
|
|
} else {
|
|
|
|
msg = "SkSurface should have cleared the render target";
|
|
|
|
}
|
|
|
|
ERRORF(reporter,
|
|
|
|
"%s but read 0x%08x (instead of 0x%08x) at %x,%d", msg.c_str(), pixel,
|
|
|
|
expectedValue, x, y);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-06 21:02:39 +00:00
|
|
|
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceClear_Gpu, reporter, ctxInfo) {
|
2016-05-11 13:33:06 +00:00
|
|
|
GrContext* context = ctxInfo.grContext();
|
2016-05-04 19:01:58 +00:00
|
|
|
|
2016-02-05 15:17:34 +00:00
|
|
|
std::function<GrSurface*(SkSurface*)> grSurfaceGetters[] = {
|
2016-06-28 15:07:26 +00:00
|
|
|
[] (SkSurface* s){
|
2016-10-27 18:47:55 +00:00
|
|
|
GrRenderTargetContext* rtc =
|
|
|
|
s->getCanvas()->internal_private_accessTopLayerRenderTargetContext();
|
|
|
|
return rtc->accessRenderTarget(); },
|
2016-03-17 17:51:11 +00:00
|
|
|
[] (SkSurface* s){ sk_sp<SkImage> i(s->makeImageSnapshot());
|
2016-05-04 19:01:58 +00:00
|
|
|
return as_IB(i)->peekTexture(); }
|
2016-02-05 15:17:34 +00:00
|
|
|
};
|
2016-05-04 19:01:58 +00:00
|
|
|
|
2016-02-05 15:17:34 +00:00
|
|
|
for (auto grSurfaceGetter : grSurfaceGetters) {
|
2016-05-04 19:01:58 +00:00
|
|
|
// Test that non-wrapped RTs are created clear.
|
2016-02-05 15:17:34 +00:00
|
|
|
for (auto& surface_func : {&create_gpu_surface, &create_gpu_scratch_surface}) {
|
2016-03-24 01:59:25 +00:00
|
|
|
auto surface = surface_func(context, kPremul_SkAlphaType, nullptr);
|
2016-02-05 15:17:34 +00:00
|
|
|
test_surface_clear(reporter, surface, grSurfaceGetter, 0x0);
|
|
|
|
}
|
|
|
|
// Wrapped RTs are *not* supposed to clear (to allow client to partially update a surface).
|
2016-05-04 19:01:58 +00:00
|
|
|
const uint32_t kOrigColor = 0xABABABAB;
|
|
|
|
for (auto& surfaceFunc : {&create_gpu_surface_backend_texture,
|
|
|
|
&create_gpu_surface_backend_texture_as_render_target}) {
|
|
|
|
GrBackendObject textureObject;
|
|
|
|
auto surface = surfaceFunc(context, 0, kOrigColor, &textureObject);
|
|
|
|
test_surface_clear(reporter, surface, grSurfaceGetter, kOrigColor);
|
|
|
|
surface.reset();
|
|
|
|
context->getGpu()->deleteTestingOnlyBackendTexture(textureObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void test_surface_draw_partially(
|
|
|
|
skiatest::Reporter* reporter, sk_sp<SkSurface> surface, uint32_t origColor) {
|
|
|
|
const int kW = surface->width();
|
|
|
|
const int kH = surface->height();
|
|
|
|
SkPaint paint;
|
|
|
|
const SkColor kRectColor = ~origColor | 0xFF000000;
|
|
|
|
paint.setColor(kRectColor);
|
|
|
|
surface->getCanvas()->drawRect(SkRect::MakeWH(SkIntToScalar(kW), SkIntToScalar(kH)/2),
|
|
|
|
paint);
|
2016-11-02 21:07:33 +00:00
|
|
|
std::unique_ptr<uint32_t[]> pixels(new uint32_t[kW * kH]);
|
2016-05-04 19:01:58 +00:00
|
|
|
sk_memset32(pixels.get(), ~origColor, kW * kH);
|
|
|
|
// Read back RGBA to avoid format conversions that may not be supported on all platforms.
|
|
|
|
SkImageInfo readInfo = SkImageInfo::Make(kW, kH, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
|
|
|
SkAssertResult(surface->readPixels(readInfo, pixels.get(), kW * sizeof(uint32_t), 0, 0));
|
|
|
|
bool stop = false;
|
|
|
|
SkPMColor origColorPM = SkPackARGB_as_RGBA((origColor >> 24 & 0xFF),
|
|
|
|
(origColor >> 0 & 0xFF),
|
|
|
|
(origColor >> 8 & 0xFF),
|
|
|
|
(origColor >> 16 & 0xFF));
|
|
|
|
SkPMColor rectColorPM = SkPackARGB_as_RGBA((kRectColor >> 24 & 0xFF),
|
|
|
|
(kRectColor >> 16 & 0xFF),
|
|
|
|
(kRectColor >> 8 & 0xFF),
|
|
|
|
(kRectColor >> 0 & 0xFF));
|
|
|
|
for (int y = 0; y < kH/2 && !stop; ++y) {
|
|
|
|
for (int x = 0; x < kW && !stop; ++x) {
|
|
|
|
REPORTER_ASSERT(reporter, rectColorPM == pixels[x + y * kW]);
|
|
|
|
if (rectColorPM != pixels[x + y * kW]) {
|
|
|
|
stop = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
stop = false;
|
|
|
|
for (int y = kH/2; y < kH && !stop; ++y) {
|
|
|
|
for (int x = 0; x < kW && !stop; ++x) {
|
|
|
|
REPORTER_ASSERT(reporter, origColorPM == pixels[x + y * kW]);
|
|
|
|
if (origColorPM != pixels[x + y * kW]) {
|
|
|
|
stop = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-02-05 15:17:34 +00:00
|
|
|
|
2016-06-28 15:07:26 +00:00
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfacePartialDraw_Gpu, reporter, ctxInfo) {
|
2016-05-11 13:33:06 +00:00
|
|
|
GrGpu* gpu = ctxInfo.grContext()->getGpu();
|
2016-05-04 19:01:58 +00:00
|
|
|
if (!gpu) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
static const uint32_t kOrigColor = 0xFFAABBCC;
|
2016-05-04 00:14:07 +00:00
|
|
|
|
2016-05-04 19:01:58 +00:00
|
|
|
for (auto& surfaceFunc : {&create_gpu_surface_backend_texture,
|
|
|
|
&create_gpu_surface_backend_texture_as_render_target}) {
|
|
|
|
// Validate that we can draw to the canvas and that the original texture color is
|
|
|
|
// preserved in pixels that aren't rendered to via the surface.
|
|
|
|
// This works only for non-multisampled case.
|
|
|
|
GrBackendObject textureObject;
|
2016-05-11 13:33:06 +00:00
|
|
|
auto surface = surfaceFunc(ctxInfo.grContext(), 0, kOrigColor, &textureObject);
|
2016-05-04 19:01:58 +00:00
|
|
|
if (surface) {
|
|
|
|
test_surface_draw_partially(reporter, surface, kOrigColor);
|
|
|
|
surface.reset();
|
|
|
|
gpu->deleteTestingOnlyBackendTexture(textureObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-05-04 00:14:07 +00:00
|
|
|
|
2016-05-04 19:01:58 +00:00
|
|
|
|
|
|
|
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(SurfaceAttachStencil_Gpu, reporter, ctxInfo) {
|
2016-05-11 13:33:06 +00:00
|
|
|
GrGpu* gpu = ctxInfo.grContext()->getGpu();
|
2016-05-04 19:01:58 +00:00
|
|
|
if (!gpu) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
static const uint32_t kOrigColor = 0xFFAABBCC;
|
|
|
|
|
|
|
|
for (auto& surfaceFunc : {&create_gpu_surface_backend_texture,
|
|
|
|
&create_gpu_surface_backend_texture_as_render_target}) {
|
|
|
|
for (int sampleCnt : {0, 4, 8}) {
|
|
|
|
GrBackendObject textureObject;
|
2016-05-11 13:33:06 +00:00
|
|
|
auto surface = surfaceFunc(ctxInfo.grContext(), sampleCnt, kOrigColor, &textureObject);
|
2016-05-04 19:01:58 +00:00
|
|
|
|
|
|
|
if (!surface && sampleCnt > 0) {
|
|
|
|
// Certain platforms don't support MSAA, skip these.
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Validate that we can attach a stencil buffer to an SkSurface created by either of
|
|
|
|
// our surface functions.
|
2016-10-27 18:47:55 +00:00
|
|
|
GrRenderTarget* rt = surface->getCanvas()
|
|
|
|
->internal_private_accessTopLayerRenderTargetContext()->accessRenderTarget();
|
2016-05-04 19:01:58 +00:00
|
|
|
REPORTER_ASSERT(reporter,
|
2016-05-11 13:33:06 +00:00
|
|
|
ctxInfo.grContext()->resourceProvider()->attachStencilAttachment(rt));
|
2016-05-04 19:01:58 +00:00
|
|
|
gpu->deleteTestingOnlyBackendTexture(textureObject);
|
|
|
|
}
|
2016-02-05 15:17:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2016-08-30 14:07:59 +00:00
|
|
|
|
|
|
|
static void test_surface_creation_and_snapshot_with_color_space(
|
|
|
|
skiatest::Reporter* reporter,
|
|
|
|
const char* prefix,
|
|
|
|
bool f16Support,
|
|
|
|
std::function<sk_sp<SkSurface>(const SkImageInfo&)> surfaceMaker) {
|
|
|
|
|
2016-10-24 13:24:02 +00:00
|
|
|
auto srgbColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGB_Named);
|
|
|
|
auto adobeColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kAdobeRGB_Named);
|
2016-10-18 17:02:51 +00:00
|
|
|
const SkMatrix44* srgbMatrix = as_CSB(srgbColorSpace)->toXYZD50();
|
|
|
|
SkASSERT(srgbMatrix);
|
2016-10-28 16:51:08 +00:00
|
|
|
SkColorSpaceTransferFn oddGamma;
|
|
|
|
oddGamma.fA = 1.0f;
|
|
|
|
oddGamma.fB = oddGamma.fC = oddGamma.fD = oddGamma.fE = oddGamma.fF = 0.0f;
|
|
|
|
oddGamma.fG = 4.0f;
|
2016-10-24 13:24:02 +00:00
|
|
|
auto oddColorSpace = SkColorSpace::MakeRGB(oddGamma, *srgbMatrix);
|
|
|
|
auto linearColorSpace = SkColorSpace::MakeNamed(SkColorSpace::kSRGBLinear_Named);
|
2016-08-30 14:07:59 +00:00
|
|
|
|
|
|
|
const struct {
|
|
|
|
SkColorType fColorType;
|
|
|
|
sk_sp<SkColorSpace> fColorSpace;
|
|
|
|
bool fShouldWork;
|
|
|
|
const char* fDescription;
|
|
|
|
} testConfigs[] = {
|
|
|
|
{ kN32_SkColorType, nullptr, true, "N32-nullptr" },
|
|
|
|
{ kN32_SkColorType, linearColorSpace, false, "N32-linear" },
|
|
|
|
{ kN32_SkColorType, srgbColorSpace, true, "N32-srgb" },
|
|
|
|
{ kN32_SkColorType, adobeColorSpace, true, "N32-adobe" },
|
|
|
|
{ kN32_SkColorType, oddColorSpace, false, "N32-odd" },
|
2016-11-01 20:30:21 +00:00
|
|
|
{ kRGBA_F16_SkColorType, nullptr, true, "F16-nullptr" },
|
2016-08-30 14:07:59 +00:00
|
|
|
{ kRGBA_F16_SkColorType, linearColorSpace, true, "F16-linear" },
|
|
|
|
{ kRGBA_F16_SkColorType, srgbColorSpace, false, "F16-srgb" },
|
|
|
|
{ kRGBA_F16_SkColorType, adobeColorSpace, false, "F16-adobe" },
|
|
|
|
{ kRGBA_F16_SkColorType, oddColorSpace, false, "F16-odd" },
|
|
|
|
{ kRGB_565_SkColorType, srgbColorSpace, false, "565-srgb" },
|
|
|
|
{ kAlpha_8_SkColorType, srgbColorSpace, false, "A8-srgb" },
|
|
|
|
};
|
|
|
|
|
|
|
|
for (auto& testConfig : testConfigs) {
|
|
|
|
SkString fullTestName = SkStringPrintf("%s-%s", prefix, testConfig.fDescription);
|
|
|
|
SkImageInfo info = SkImageInfo::Make(10, 10, testConfig.fColorType, kPremul_SkAlphaType,
|
|
|
|
testConfig.fColorSpace);
|
|
|
|
|
|
|
|
// For some GPU contexts (eg ANGLE), we don't have f16 support, so we should fail to create
|
|
|
|
// any surface of that type:
|
|
|
|
bool shouldWork = testConfig.fShouldWork &&
|
|
|
|
(f16Support || kRGBA_F16_SkColorType != testConfig.fColorType);
|
|
|
|
|
|
|
|
auto surface(surfaceMaker(info));
|
|
|
|
REPORTER_ASSERT_MESSAGE(reporter, SkToBool(surface) == shouldWork, fullTestName.c_str());
|
|
|
|
|
|
|
|
if (shouldWork && surface) {
|
|
|
|
sk_sp<SkImage> image(surface->makeImageSnapshot());
|
|
|
|
REPORTER_ASSERT_MESSAGE(reporter, image, testConfig.fDescription);
|
|
|
|
SkColorSpace* imageColorSpace = as_IB(image)->onImageInfo().colorSpace();
|
|
|
|
REPORTER_ASSERT_MESSAGE(reporter, imageColorSpace == testConfig.fColorSpace.get(),
|
|
|
|
fullTestName.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_TEST(SurfaceCreationWithColorSpace, reporter) {
|
|
|
|
auto surfaceMaker = [](const SkImageInfo& info) {
|
|
|
|
return SkSurface::MakeRaster(info);
|
|
|
|
};
|
|
|
|
|
|
|
|
test_surface_creation_and_snapshot_with_color_space(reporter, "raster", true, surfaceMaker);
|
|
|
|
}
|
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(SurfaceCreationWithColorSpace_Gpu, reporter, ctxInfo) {
|
|
|
|
GrContext* context = ctxInfo.grContext();
|
|
|
|
bool f16Support = context->caps()->isConfigRenderable(kRGBA_half_GrPixelConfig, false);
|
|
|
|
auto surfaceMaker = [context](const SkImageInfo& info) {
|
|
|
|
return SkSurface::MakeRenderTarget(context, SkBudgeted::kNo, info);
|
|
|
|
};
|
|
|
|
|
|
|
|
test_surface_creation_and_snapshot_with_color_space(reporter, "gpu", f16Support, surfaceMaker);
|
|
|
|
|
|
|
|
std::vector<GrBackendObject> textureHandles;
|
|
|
|
auto wrappedSurfaceMaker = [context,&textureHandles](const SkImageInfo& info) {
|
|
|
|
GrBackendTextureDesc desc;
|
|
|
|
desc.fConfig = SkImageInfo2GrPixelConfig(info, *context->caps());
|
|
|
|
desc.fWidth = 10;
|
|
|
|
desc.fHeight = 10;
|
|
|
|
desc.fFlags = kRenderTarget_GrBackendTextureFlag;
|
|
|
|
desc.fTextureHandle = context->getGpu()->createTestingOnlyBackendTexture(
|
|
|
|
nullptr, desc.fWidth, desc.fHeight, desc.fConfig, true);
|
|
|
|
|
|
|
|
if (!desc.fTextureHandle) {
|
|
|
|
return sk_sp<SkSurface>(nullptr);
|
|
|
|
}
|
|
|
|
textureHandles.push_back(desc.fTextureHandle);
|
|
|
|
|
|
|
|
return SkSurface::MakeFromBackendTexture(context, desc, sk_ref_sp(info.colorSpace()),
|
|
|
|
nullptr);
|
|
|
|
};
|
|
|
|
|
|
|
|
test_surface_creation_and_snapshot_with_color_space(reporter, "wrapped", f16Support,
|
|
|
|
wrappedSurfaceMaker);
|
|
|
|
|
|
|
|
for (auto textureHandle : textureHandles) {
|
|
|
|
context->getGpu()->deleteTestingOnlyBackendTexture(textureHandle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2016-11-22 16:31:41 +00:00
|
|
|
|
|
|
|
static void test_overdraw_surface(skiatest::Reporter* r, SkSurface* surface) {
|
2016-11-28 23:28:07 +00:00
|
|
|
SkOverdrawCanvas canvas(surface->getCanvas());
|
|
|
|
canvas.drawPaint(SkPaint());
|
2016-11-22 16:31:41 +00:00
|
|
|
sk_sp<SkImage> image = surface->makeImageSnapshot();
|
|
|
|
|
|
|
|
SkBitmap bitmap;
|
|
|
|
image->asLegacyBitmap(&bitmap, SkImage::kRO_LegacyBitmapMode);
|
|
|
|
bitmap.lockPixels();
|
|
|
|
for (int y = 0; y < 10; y++) {
|
|
|
|
for (int x = 0; x < 10; x++) {
|
|
|
|
REPORTER_ASSERT(r, 1 == SkGetPackedA32(*bitmap.getAddr32(x, y)));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DEF_TEST(OverdrawSurface_Raster, r) {
|
|
|
|
sk_sp<SkSurface> surface = create_surface();
|
|
|
|
test_overdraw_surface(r, surface.get());
|
|
|
|
}
|
|
|
|
|
|
|
|
#if SK_SUPPORT_GPU
|
|
|
|
DEF_GPUTEST_FOR_RENDERING_CONTEXTS(OverdrawSurface_Gpu, r, ctxInfo) {
|
|
|
|
GrContext* context = ctxInfo.grContext();
|
|
|
|
sk_sp<SkSurface> surface = create_gpu_surface(context);
|
|
|
|
test_overdraw_surface(r, surface.get());
|
|
|
|
}
|
|
|
|
#endif
|