Reland "Use specialized quad lists in rectangle ops"
This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8
It is updated in patchset 2 to clean up pointers passed into memcpy, and to
optimize the bounds calculation in GrPerspQuad. This should fix a performance
regression caused by the move away from caching 1/w. The Sk4f::invert() does not
always preserve 1/1 == 1, which led to bounds slightly outside of clips and
thus forced Skia to keep the scissor test enabled. The fix also restores the
optimization of skipping the 1/w division when the quad is known to be 2D.
Original change's description:
> Use specialized quad lists in rectangle ops
>
> Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp
>
> The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2
> SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total
> of 124 bytes per quad that was stored in the op.
>
> The first pass at the rectangle consolidation switched to storing device and
> local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag
> (1 int) for a total of 148 bytes per quad. After landing, several memory
> regressions appeared in Chrome and our perf monitor.
>
> Several intertwined approaches are taken here. First, GrPerspQuad no longer
> caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized
> list type is defined that allows storing the x, y, and extra metadata together
> for quads, but keeps the w components separate. When the quad type isn't
> perspective, w is not stored at all since it is implicitly 1 and can be
> reconstituted at tessellation time. This brings the total per quad to either
> 84 or 116 bytes, depending on if the op list needs perspective information.
>
> Bug: chromium:915025
> Bug: chromium:917242
> Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6
> Reviewed-on: https://skia-review.googlesource.com/c/180644
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
Bug: chromium:915025, chromium:917242
Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55
Reviewed-on: https://skia-review.googlesource.com/c/182203
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2019 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tests/Test.h"
|
Reland "Use specialized quad lists in rectangle ops"
This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8
It is updated in patchset 2 to clean up pointers passed into memcpy, and to
optimize the bounds calculation in GrPerspQuad. This should fix a performance
regression caused by the move away from caching 1/w. The Sk4f::invert() does not
always preserve 1/1 == 1, which led to bounds slightly outside of clips and
thus forced Skia to keep the scissor test enabled. The fix also restores the
optimization of skipping the 1/w division when the quad is known to be 2D.
Original change's description:
> Use specialized quad lists in rectangle ops
>
> Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp
>
> The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2
> SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total
> of 124 bytes per quad that was stored in the op.
>
> The first pass at the rectangle consolidation switched to storing device and
> local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag
> (1 int) for a total of 148 bytes per quad. After landing, several memory
> regressions appeared in Chrome and our perf monitor.
>
> Several intertwined approaches are taken here. First, GrPerspQuad no longer
> caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized
> list type is defined that allows storing the x, y, and extra metadata together
> for quads, but keeps the w components separate. When the quad type isn't
> perspective, w is not stored at all since it is implicitly 1 and can be
> reconstituted at tessellation time. This brings the total per quad to either
> 84 or 116 bytes, depending on if the op list needs perspective information.
>
> Bug: chromium:915025
> Bug: chromium:917242
> Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6
> Reviewed-on: https://skia-review.googlesource.com/c/180644
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
Bug: chromium:915025, chromium:917242
Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55
Reviewed-on: https://skia-review.googlesource.com/c/182203
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
|
|
|
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/GrQuad.h"
|
Reland "Use specialized quad lists in rectangle ops"
This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8
It is updated in patchset 2 to clean up pointers passed into memcpy, and to
optimize the bounds calculation in GrPerspQuad. This should fix a performance
regression caused by the move away from caching 1/w. The Sk4f::invert() does not
always preserve 1/1 == 1, which led to bounds slightly outside of clips and
thus forced Skia to keep the scissor test enabled. The fix also restores the
optimization of skipping the 1/w division when the quad is known to be 2D.
Original change's description:
> Use specialized quad lists in rectangle ops
>
> Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp
>
> The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2
> SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total
> of 124 bytes per quad that was stored in the op.
>
> The first pass at the rectangle consolidation switched to storing device and
> local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag
> (1 int) for a total of 148 bytes per quad. After landing, several memory
> regressions appeared in Chrome and our perf monitor.
>
> Several intertwined approaches are taken here. First, GrPerspQuad no longer
> caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized
> list type is defined that allows storing the x, y, and extra metadata together
> for quads, but keeps the w components separate. When the quad type isn't
> perspective, w is not stored at all since it is implicitly 1 and can be
> reconstituted at tessellation time. This brings the total per quad to either
> 84 or 116 bytes, depending on if the op list needs perspective information.
>
> Bug: chromium:915025
> Bug: chromium:917242
> Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6
> Reviewed-on: https://skia-review.googlesource.com/c/180644
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
Bug: chromium:915025, chromium:917242
Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55
Reviewed-on: https://skia-review.googlesource.com/c/182203
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
|
|
|
|
|
|
|
#define ASSERT(cond) REPORTER_ASSERT(r, cond)
|
|
|
|
#define ASSERTF(cond, ...) REPORTER_ASSERT(r, cond, __VA_ARGS__)
|
|
|
|
#define TEST(name) DEF_TEST(GrQuadList##name, r)
|
|
|
|
|
|
|
|
struct TestData {
|
|
|
|
int fItem1;
|
|
|
|
float fItem2;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Simple factories to make placeholder quads used in the tests. The 2D quads
|
|
|
|
// will have the kRect quad type.
|
|
|
|
static GrQuad make_2d_quad() {
|
|
|
|
return GrQuad(SkRect::MakeLTRB(1.f, 2.f, 3.f, 4.f));
|
|
|
|
}
|
|
|
|
static bool is_2d_quad(const GrPerspQuad& quad) {
|
|
|
|
return quad.x(0) == 1.f && quad.x(1) == 1.f && quad.x(2) == 3.f && quad.x(3) == 3.f &&
|
|
|
|
quad.y(0) == 2.f && quad.y(1) == 4.f && quad.y(2) == 2.f && quad.y(3) == 4.f &&
|
|
|
|
quad.w(0) == 1.f && quad.w(1) == 1.f && quad.w(2) == 1.f && quad.w(3) == 1.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GrPerspQuad make_2d_persp_quad() {
|
2019-02-13 18:39:39 +00:00
|
|
|
return GrPerspQuad(SkRect::MakeLTRB(5.f, 6.f, 7.f, 8.f));
|
Reland "Use specialized quad lists in rectangle ops"
This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8
It is updated in patchset 2 to clean up pointers passed into memcpy, and to
optimize the bounds calculation in GrPerspQuad. This should fix a performance
regression caused by the move away from caching 1/w. The Sk4f::invert() does not
always preserve 1/1 == 1, which led to bounds slightly outside of clips and
thus forced Skia to keep the scissor test enabled. The fix also restores the
optimization of skipping the 1/w division when the quad is known to be 2D.
Original change's description:
> Use specialized quad lists in rectangle ops
>
> Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp
>
> The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2
> SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total
> of 124 bytes per quad that was stored in the op.
>
> The first pass at the rectangle consolidation switched to storing device and
> local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag
> (1 int) for a total of 148 bytes per quad. After landing, several memory
> regressions appeared in Chrome and our perf monitor.
>
> Several intertwined approaches are taken here. First, GrPerspQuad no longer
> caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized
> list type is defined that allows storing the x, y, and extra metadata together
> for quads, but keeps the w components separate. When the quad type isn't
> perspective, w is not stored at all since it is implicitly 1 and can be
> reconstituted at tessellation time. This brings the total per quad to either
> 84 or 116 bytes, depending on if the op list needs perspective information.
>
> Bug: chromium:915025
> Bug: chromium:917242
> Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6
> Reviewed-on: https://skia-review.googlesource.com/c/180644
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
Bug: chromium:915025, chromium:917242
Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55
Reviewed-on: https://skia-review.googlesource.com/c/182203
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
|
|
|
}
|
|
|
|
static bool is_2d_persp_quad(const GrPerspQuad& quad) {
|
|
|
|
return quad.x(0) == 5.f && quad.x(1) == 5.f && quad.x(2) == 7.f && quad.x(3) == 7.f &&
|
|
|
|
quad.y(0) == 6.f && quad.y(1) == 8.f && quad.y(2) == 6.f && quad.y(3) == 8.f &&
|
|
|
|
quad.w(0) == 1.f && quad.w(1) == 1.f && quad.w(2) == 1.f && quad.w(3) == 1.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
static GrPerspQuad make_3d_persp_quad() {
|
|
|
|
// This perspective matrix leaves x and y unmodified, and sets w to the persp2 value
|
|
|
|
SkMatrix p = SkMatrix::I();
|
|
|
|
p[SkMatrix::kMPersp2] = 13.f;
|
|
|
|
SkASSERT(p.hasPerspective()); // Sanity check
|
2019-02-13 18:39:39 +00:00
|
|
|
return GrPerspQuad::MakeFromRect(SkRect::MakeLTRB(9.f, 10.f, 11.f, 12.f), p);
|
Reland "Use specialized quad lists in rectangle ops"
This is a reland of 5820b0c3f3ceba23b9d80415e77a9db124b409b8
It is updated in patchset 2 to clean up pointers passed into memcpy, and to
optimize the bounds calculation in GrPerspQuad. This should fix a performance
regression caused by the move away from caching 1/w. The Sk4f::invert() does not
always preserve 1/1 == 1, which led to bounds slightly outside of clips and
thus forced Skia to keep the scissor test enabled. The fix also restores the
optimization of skipping the 1/w division when the quad is known to be 2D.
Original change's description:
> Use specialized quad lists in rectangle ops
>
> Hopefully reduces memory footprint of GrFillRectOp and GrTextureOp
>
> The original rect code (GrAAFillRectOp) stored 2 SkMatrices (18 floats), 2
> SkRects (8 floats) an SkPMColor4f (4 floats) and a flag (1 int) for a total
> of 124 bytes per quad that was stored in the op.
>
> The first pass at the rectangle consolidation switched to storing device and
> local quads as GrPerspQuads (32 floats), an SkPMColor4f (4 floats) and a flag
> (1 int) for a total of 148 bytes per quad. After landing, several memory
> regressions appeared in Chrome and our perf monitor.
>
> Several intertwined approaches are taken here. First, GrPerspQuad no longer
> caches 1/w, which makes a quad 12 floats instead of 16. Second, a specialized
> list type is defined that allows storing the x, y, and extra metadata together
> for quads, but keeps the w components separate. When the quad type isn't
> perspective, w is not stored at all since it is implicitly 1 and can be
> reconstituted at tessellation time. This brings the total per quad to either
> 84 or 116 bytes, depending on if the op list needs perspective information.
>
> Bug: chromium:915025
> Bug: chromium:917242
> Change-Id: If37ee122847b0c32604bb45dc2a1326b544f9cf6
> Reviewed-on: https://skia-review.googlesource.com/c/180644
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Reviewed-by: Robert Phillips <robertphillips@google.com>
Bug: chromium:915025, chromium:917242
Change-Id: I98a1bf83fd7d393604823d567c57d7e06fad5e55
Reviewed-on: https://skia-review.googlesource.com/c/182203
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Chris Dalton <csmartdalton@google.com>
2019-01-08 20:46:15 +00:00
|
|
|
}
|
|
|
|
static bool is_3d_persp_quad(const GrPerspQuad& quad) {
|
|
|
|
return quad.x(0) == 9.f && quad.x(1) == 9.f && quad.x(2) == 11.f && quad.x(3) == 11.f &&
|
|
|
|
quad.y(0) == 10.f && quad.y(1) == 12.f && quad.y(2) == 10.f && quad.y(3) == 12.f &&
|
|
|
|
quad.w(0) == 13.f && quad.w(1) == 13.f && quad.w(2) == 13.f && quad.w(3) == 13.f;
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Add2D) {
|
|
|
|
GrQuadList list2D;
|
|
|
|
// Add a plain quad, a 2D persp quad, and then a 3D persp quad, then read back and make sure
|
|
|
|
// the coordinates make sense (including that the type was lifted to perspective).
|
|
|
|
list2D.push_back(make_2d_quad(), GrQuadType::kRect);
|
|
|
|
list2D.push_back(make_2d_persp_quad(), GrQuadType::kRect);
|
|
|
|
|
|
|
|
// Check 2D state of the list
|
|
|
|
ASSERTF(list2D.count() == 2, "Unexpected count: %d", list2D.count());
|
|
|
|
ASSERTF(list2D.quadType() == GrQuadType::kRect, "Unexpected quad type: %d",
|
|
|
|
(uint32_t) list2D.quadType());
|
|
|
|
ASSERTF(is_2d_quad(list2D[0]), "Incorrect quad at i=0");
|
|
|
|
ASSERTF(is_2d_persp_quad(list2D[1]), "Incorrect quad at i=1");
|
|
|
|
|
|
|
|
// Force the 2D quads to be updated to store ws by adding a perspective quad
|
|
|
|
list2D.push_back(make_3d_persp_quad(), GrQuadType::kPerspective);
|
|
|
|
ASSERTF(list2D.quadType() == GrQuadType::kPerspective,
|
|
|
|
"Expected 2D list to be upgraded to perspective");
|
|
|
|
|
|
|
|
// Re-check full state of list after type upgrade
|
|
|
|
ASSERTF(list2D.count() == 3, "Unexpected count: %d", list2D.count());
|
|
|
|
ASSERTF(is_2d_quad(list2D[0]), "Incorrect quad at i=0 after upgrade");
|
|
|
|
ASSERTF(is_2d_persp_quad(list2D[1]), "Incorrect quad at i=1 after upgrade");
|
|
|
|
ASSERTF(is_3d_persp_quad(list2D[2]), "Incorrect quad at i=2");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Add3D) {
|
|
|
|
// Now make a list that starts with a 3D persp quad, then has conventional quads added to it
|
|
|
|
// and make sure its state is correct
|
|
|
|
GrQuadList list3D;
|
|
|
|
list3D.push_back(make_3d_persp_quad(), GrQuadType::kPerspective);
|
|
|
|
list3D.push_back(make_2d_persp_quad(), GrQuadType::kRect);
|
|
|
|
list3D.push_back(make_2d_quad(), GrQuadType::kRect);
|
|
|
|
|
|
|
|
ASSERTF(list3D.count() == 3, "Unexpected count: %d", list3D.count());
|
|
|
|
ASSERTF(is_3d_persp_quad(list3D[0]), "Incorrect quad at i=0");
|
|
|
|
ASSERTF(is_2d_persp_quad(list3D[1]), "Incorrect quad at i=1");
|
|
|
|
ASSERTF(is_2d_quad(list3D[2]), "Incorrect quad at i=2");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(AddWithMetadata2D) {
|
|
|
|
// As above, but also make sure that the metadata is saved and read properly
|
|
|
|
GrTQuadList<TestData> list2D;
|
|
|
|
// Add a plain quad, a 2D persp quad, and then a 3D persp quad, then read back and make sure
|
|
|
|
// the coordinates make sense (including that the type was lifted to perspective).
|
|
|
|
list2D.push_back(make_2d_quad(), GrQuadType::kRect, {1, 1.f});
|
|
|
|
list2D.push_back(make_2d_persp_quad(), GrQuadType::kRect, {2, 2.f});
|
|
|
|
|
|
|
|
// Check 2D state of the list
|
|
|
|
ASSERTF(list2D.count() == 2, "Unexpected count: %d", list2D.count());
|
|
|
|
ASSERTF(list2D.quadType() == GrQuadType::kRect, "Unexpected quad type: %d",
|
|
|
|
(uint32_t) list2D.quadType());
|
|
|
|
ASSERTF(is_2d_quad(list2D[0]), "Incorrect quad at i=0");
|
|
|
|
ASSERTF(list2D.metadata(0).fItem1 == 1 && list2D.metadata(0).fItem2 == 1.f,
|
|
|
|
"Incorrect metadata at i=0");
|
|
|
|
ASSERTF(is_2d_persp_quad(list2D[1]), "Incorrect quad at i=1");
|
|
|
|
ASSERTF(list2D.metadata(1).fItem1 == 2 && list2D.metadata(1).fItem2 == 2.f,
|
|
|
|
"Incorrect metadata at i=1");
|
|
|
|
|
|
|
|
// Force the 2D quads to be updated to store ws by adding a perspective quad
|
|
|
|
list2D.push_back(make_3d_persp_quad(), GrQuadType::kPerspective, {3, 3.f});
|
|
|
|
ASSERTF(list2D.quadType() == GrQuadType::kPerspective,
|
|
|
|
"Expected 2D list to be upgraded to perspective");
|
|
|
|
|
|
|
|
// Re-check full state of list after type upgrade
|
|
|
|
ASSERTF(list2D.count() == 3, "Unexpected count: %d", list2D.count());
|
|
|
|
ASSERTF(is_2d_quad(list2D[0]), "Incorrect quad at i=0 after upgrade");
|
|
|
|
ASSERTF(list2D.metadata(0).fItem1 == 1 && list2D.metadata(0).fItem2 == 1.f,
|
|
|
|
"Incorrect metadata at i=0");
|
|
|
|
ASSERTF(is_2d_persp_quad(list2D[1]), "Incorrect quad at i=1 after upgrade");
|
|
|
|
ASSERTF(list2D.metadata(1).fItem1 == 2 && list2D.metadata(1).fItem2 == 2.f,
|
|
|
|
"Incorrect metadata at i=1");
|
|
|
|
ASSERTF(is_3d_persp_quad(list2D[2]), "Incorrect quad at i=2");
|
|
|
|
ASSERTF(list2D.metadata(2).fItem1 == 3 && list2D.metadata(2).fItem2 == 3.f,
|
|
|
|
"Incorrect metadata at i=2");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(AddWithMetadata3D) {
|
|
|
|
// Now make a list that starts with a 3D persp quad, then has conventional quads added to it
|
|
|
|
// and make sure its state is correct
|
|
|
|
GrTQuadList<TestData> list3D;
|
|
|
|
list3D.push_back(make_3d_persp_quad(), GrQuadType::kPerspective, {3, 3.f});
|
|
|
|
list3D.push_back(make_2d_persp_quad(), GrQuadType::kRect, {2, 2.f});
|
|
|
|
list3D.push_back(make_2d_quad(), GrQuadType::kRect, {1, 1.f});
|
|
|
|
|
|
|
|
ASSERTF(list3D.count() == 3, "Unexpected count: %d", list3D.count());
|
|
|
|
ASSERTF(is_3d_persp_quad(list3D[0]), "Incorrect quad at i=0");
|
|
|
|
ASSERTF(list3D.metadata(0).fItem1 == 3 && list3D.metadata(0).fItem2 == 3.f,
|
|
|
|
"Incorrect metadata at i=0");
|
|
|
|
ASSERTF(is_2d_persp_quad(list3D[1]), "Incorrect quad at i=1");
|
|
|
|
ASSERTF(list3D.metadata(1).fItem1 == 2 && list3D.metadata(1).fItem2 == 2.f,
|
|
|
|
"Incorrect metadata at i=1");
|
|
|
|
ASSERTF(is_2d_quad(list3D[2]), "Incorrect quad at i=2");
|
|
|
|
ASSERTF(list3D.metadata(2).fItem1 == 1 && list3D.metadata(2).fItem2 == 1.f,
|
|
|
|
"Incorrect metadata at i=2");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Concat2DWith2D) {
|
|
|
|
GrQuadList a2D;
|
|
|
|
a2D.push_back(make_2d_quad(), GrQuadType::kRect);
|
|
|
|
GrQuadList b2D;
|
|
|
|
b2D.push_back(make_2d_persp_quad(), GrQuadType::kRect);
|
|
|
|
|
|
|
|
a2D.concat(b2D);
|
|
|
|
|
|
|
|
ASSERTF(a2D.count() == 2, "Unexpected count: %d", a2D.count());
|
|
|
|
ASSERTF(is_2d_quad(a2D[0]), "Incorrect quad at i=0");
|
|
|
|
ASSERTF(is_2d_persp_quad(a2D[1]), "Incorrect quad at i=1");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Concat2DWith3D) {
|
|
|
|
GrQuadList a2D;
|
|
|
|
a2D.push_back(make_2d_quad(), GrQuadType::kRect);
|
|
|
|
GrQuadList b3D;
|
|
|
|
b3D.push_back(make_3d_persp_quad(), GrQuadType::kPerspective);
|
|
|
|
|
|
|
|
a2D.concat(b3D);
|
|
|
|
|
|
|
|
ASSERTF(a2D.count() == 2, "Unexpected count: %d", a2D.count());
|
|
|
|
ASSERTF(is_2d_quad(a2D[0]), "Incorrect quad at i=0");
|
|
|
|
ASSERTF(is_3d_persp_quad(a2D[1]), "Incorrect quad at i=1");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Concat3DWith2D) {
|
|
|
|
GrQuadList a3D;
|
|
|
|
a3D.push_back(make_3d_persp_quad(), GrQuadType::kPerspective);
|
|
|
|
GrQuadList b2D;
|
|
|
|
b2D.push_back(make_2d_quad(), GrQuadType::kRect);
|
|
|
|
|
|
|
|
a3D.concat(b2D);
|
|
|
|
|
|
|
|
ASSERTF(a3D.count() == 2, "Unexpected count: %d", a3D.count());
|
|
|
|
ASSERTF(is_3d_persp_quad(a3D[0]), "Incorrect quad at i=0");
|
|
|
|
ASSERTF(is_2d_quad(a3D[1]), "Incorrect quad at i=1");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Concat3DWith3D) {
|
|
|
|
GrQuadList a3D;
|
|
|
|
a3D.push_back(make_3d_persp_quad(), GrQuadType::kPerspective);
|
|
|
|
GrQuadList b3D;
|
|
|
|
b3D.push_back(make_3d_persp_quad(), GrQuadType::kPerspective);
|
|
|
|
|
|
|
|
a3D.concat(b3D);
|
|
|
|
|
|
|
|
ASSERTF(a3D.count() == 2, "Unexpected count: %d", a3D.count());
|
|
|
|
ASSERTF(is_3d_persp_quad(a3D[0]), "Incorrect quad at i=0");
|
|
|
|
ASSERTF(is_3d_persp_quad(a3D[1]), "Incorrect quad at i=1");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Concat2DWith2DMetadata) {
|
|
|
|
GrTQuadList<TestData> a2D;
|
|
|
|
a2D.push_back(make_2d_quad(), GrQuadType::kRect, {1, 1.f});
|
|
|
|
GrTQuadList<TestData> b2D;
|
|
|
|
b2D.push_back(make_2d_persp_quad(), GrQuadType::kRect, {2, 2.f});
|
|
|
|
|
|
|
|
a2D.concat(b2D);
|
|
|
|
|
|
|
|
ASSERTF(a2D.count() == 2, "Unexpected count: %d", a2D.count());
|
|
|
|
ASSERTF(is_2d_quad(a2D[0]), "Incorrect quad at i=0");
|
|
|
|
ASSERTF(a2D.metadata(0).fItem1 == 1 && a2D.metadata(0).fItem2 == 1.f,
|
|
|
|
"Incorrect metadata at i=0");
|
|
|
|
ASSERTF(is_2d_persp_quad(a2D[1]), "Incorrect quad at i=1");
|
|
|
|
ASSERTF(a2D.metadata(1).fItem1 == 2 && a2D.metadata(1).fItem2 == 2.f,
|
|
|
|
"Incorrect metadata at i=1");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Concat2DWith3DMetadata) {
|
|
|
|
GrTQuadList<TestData> a2D;
|
|
|
|
a2D.push_back(make_2d_quad(), GrQuadType::kRect, {1, 1.f});
|
|
|
|
GrTQuadList<TestData> b3D;
|
|
|
|
b3D.push_back(make_3d_persp_quad(), GrQuadType::kPerspective, {2, 2.f});
|
|
|
|
|
|
|
|
a2D.concat(b3D);
|
|
|
|
|
|
|
|
ASSERTF(a2D.count() == 2, "Unexpected count: %d", a2D.count());
|
|
|
|
ASSERTF(is_2d_quad(a2D[0]), "Incorrect quad at i=0");
|
|
|
|
ASSERTF(a2D.metadata(0).fItem1 == 1 && a2D.metadata(0).fItem2 == 1.f,
|
|
|
|
"Incorrect metadata at i=0");
|
|
|
|
ASSERTF(is_3d_persp_quad(a2D[1]), "Incorrect quad at i=1");
|
|
|
|
ASSERTF(a2D.metadata(1).fItem1 == 2 && a2D.metadata(1).fItem2 == 2.f,
|
|
|
|
"Incorrect metadata at i=1");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Concat3DWith2DMetadata) {
|
|
|
|
GrTQuadList<TestData> a3D;
|
|
|
|
a3D.push_back(make_3d_persp_quad(), GrQuadType::kPerspective, {1, 1.f});
|
|
|
|
GrTQuadList<TestData> b2D;
|
|
|
|
b2D.push_back(make_2d_quad(), GrQuadType::kRect, {2, 2.f});
|
|
|
|
|
|
|
|
a3D.concat(b2D);
|
|
|
|
|
|
|
|
ASSERTF(a3D.count() == 2, "Unexpected count: %d", a3D.count());
|
|
|
|
ASSERTF(is_3d_persp_quad(a3D[0]), "Incorrect quad at i=0");
|
|
|
|
ASSERTF(a3D.metadata(0).fItem1 == 1 && a3D.metadata(0).fItem2 == 1.f,
|
|
|
|
"Incorrect metadata at i=0");
|
|
|
|
ASSERTF(is_2d_quad(a3D[1]), "Incorrect quad at i=1");
|
|
|
|
ASSERTF(a3D.metadata(1).fItem1 == 2 && a3D.metadata(1).fItem2 == 2.f,
|
|
|
|
"Incorrect metadata at i=1");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(Concat3DWith3DMetadata) {
|
|
|
|
GrTQuadList<TestData> a3D;
|
|
|
|
a3D.push_back(make_3d_persp_quad(), GrQuadType::kPerspective, {1, 1.f});
|
|
|
|
GrTQuadList<TestData> b3D;
|
|
|
|
b3D.push_back(make_3d_persp_quad(), GrQuadType::kPerspective, {2, 2.f});
|
|
|
|
|
|
|
|
a3D.concat(b3D);
|
|
|
|
|
|
|
|
ASSERTF(a3D.count() == 2, "Unexpected count: %d", a3D.count());
|
|
|
|
ASSERTF(is_3d_persp_quad(a3D[0]), "Incorrect quad at i=0");
|
|
|
|
ASSERTF(a3D.metadata(0).fItem1 == 1 && a3D.metadata(0).fItem2 == 1.f,
|
|
|
|
"Incorrect metadata at i=0");
|
|
|
|
ASSERTF(is_3d_persp_quad(a3D[1]), "Incorrect quad at i=1");
|
|
|
|
ASSERTF(a3D.metadata(1).fItem1 == 2 && a3D.metadata(1).fItem2 == 2.f,
|
|
|
|
"Incorrect metadata at i=1");
|
|
|
|
}
|
|
|
|
|
|
|
|
TEST(WriteMetadata) {
|
|
|
|
GrTQuadList<TestData> list;
|
|
|
|
list.push_back(make_2d_quad(), GrQuadType::kRect, {1, 1.f});
|
|
|
|
ASSERTF(list.metadata(0).fItem1 == 1 && list.metadata(0).fItem2 == 1.f,
|
|
|
|
"Incorrect metadata at i=0"); // Sanity check
|
|
|
|
|
|
|
|
// Rewrite metadata within the list and read back
|
|
|
|
list.metadata(0).fItem1 = 2;
|
|
|
|
list.metadata(0).fItem2 = 2.f;
|
|
|
|
ASSERTF(list.metadata(0).fItem1 == 2 && list.metadata(0).fItem2 == 2.f,
|
|
|
|
"Incorrect metadata at i=0 after edit");
|
|
|
|
}
|