2016-01-14 17:24:09 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2015 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"
|
|
|
|
#include "tests/TestUtils.h"
|
2017-01-27 15:11:42 +00:00
|
|
|
|
2020-07-01 20:09:43 +00:00
|
|
|
#include "include/gpu/GrDirectContext.h"
|
2020-10-14 15:23:11 +00:00
|
|
|
#include "src/gpu/GrDirectContextPriv.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/GrProxyProvider.h"
|
2020-12-09 21:37:04 +00:00
|
|
|
#include "src/gpu/GrSurfaceDrawContext.h"
|
2020-07-23 14:33:24 +00:00
|
|
|
#include "src/gpu/GrTexture.h"
|
2019-06-06 16:44:05 +00:00
|
|
|
#include "src/gpu/SkGr.h"
|
2019-11-08 21:18:15 +00:00
|
|
|
#ifdef SK_GL
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "src/gpu/gl/GrGLGpu.h"
|
|
|
|
#include "src/gpu/gl/GrGLUtil.h"
|
2019-11-08 21:18:15 +00:00
|
|
|
#endif
|
2019-06-05 20:52:02 +00:00
|
|
|
#include "tools/gpu/ProxyUtils.h"
|
2016-01-14 17:24:09 +00:00
|
|
|
|
2016-11-07 14:53:44 +00:00
|
|
|
// skbug.com/5932
|
2020-08-11 16:02:22 +00:00
|
|
|
static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrDirectContext* dContext,
|
2020-02-11 16:54:55 +00:00
|
|
|
GrSurfaceProxyView rectView, GrColorType colorType,
|
2019-11-23 00:09:27 +00:00
|
|
|
SkAlphaType alphaType, uint32_t expectedPixelValues[]) {
|
2020-12-16 16:44:47 +00:00
|
|
|
auto fillContext = GrSurfaceFillContext::Make(
|
|
|
|
dContext, {colorType, kPremul_SkAlphaType, nullptr, rectView.dimensions()});
|
2020-07-22 15:18:06 +00:00
|
|
|
for (auto filter : {GrSamplerState::Filter::kNearest, GrSamplerState::Filter::kLinear}) {
|
|
|
|
for (auto mm : {GrSamplerState::MipmapMode::kNone, GrSamplerState::MipmapMode::kLinear}) {
|
2020-12-16 16:44:47 +00:00
|
|
|
fillContext->clear(SkPMColor4f::FromBytes_RGBA(0xDDCCBBAA));
|
2020-07-22 15:18:06 +00:00
|
|
|
auto fp = GrTextureEffect::Make(rectView, alphaType, SkMatrix::I(), filter, mm);
|
2020-12-16 16:44:47 +00:00
|
|
|
fillContext->fillWithFP(std::move(fp));
|
|
|
|
TestReadPixels(reporter, dContext, fillContext.get(), expectedPixelValues,
|
2020-07-22 15:18:06 +00:00
|
|
|
"RectangleTexture-basic-draw");
|
|
|
|
}
|
2016-11-07 14:53:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-11 16:02:22 +00:00
|
|
|
static void test_clear(skiatest::Reporter* reporter, GrDirectContext* dContext,
|
|
|
|
GrSurfaceContext* rectContext) {
|
2020-12-16 16:44:47 +00:00
|
|
|
if (GrSurfaceFillContext* sfc = rectContext->asFillContext()) {
|
2016-01-14 17:24:09 +00:00
|
|
|
// Clear the whole thing.
|
|
|
|
GrColor color0 = GrColorPackRGBA(0xA, 0xB, 0xC, 0xD);
|
2020-12-16 16:44:47 +00:00
|
|
|
sfc->clear(SkPMColor4f::FromBytes_RGBA(color0));
|
2016-01-14 17:24:09 +00:00
|
|
|
|
2020-12-16 16:44:47 +00:00
|
|
|
int w = sfc->width();
|
|
|
|
int h = sfc->height();
|
2016-01-14 17:24:09 +00:00
|
|
|
int pixelCnt = w * h;
|
|
|
|
SkAutoTMalloc<uint32_t> expectedPixels(pixelCnt);
|
|
|
|
|
|
|
|
// The clear color is a GrColor, our readback is to kRGBA_8888, which may be different.
|
2016-01-15 14:21:18 +00:00
|
|
|
uint32_t expectedColor0 = 0;
|
2018-06-14 18:41:22 +00:00
|
|
|
uint8_t* expectedBytes0 = reinterpret_cast<uint8_t*>(&expectedColor0);
|
2016-01-14 17:24:09 +00:00
|
|
|
expectedBytes0[0] = GrColorUnpackR(color0);
|
|
|
|
expectedBytes0[1] = GrColorUnpackG(color0);
|
|
|
|
expectedBytes0[2] = GrColorUnpackB(color0);
|
|
|
|
expectedBytes0[3] = GrColorUnpackA(color0);
|
2020-12-16 16:44:47 +00:00
|
|
|
for (int i = 0; i < sfc->width() * sfc->height(); ++i) {
|
2016-01-14 17:24:09 +00:00
|
|
|
expectedPixels.get()[i] = expectedColor0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Clear the the top to a different color.
|
|
|
|
GrColor color1 = GrColorPackRGBA(0x1, 0x2, 0x3, 0x4);
|
|
|
|
SkIRect rect = SkIRect::MakeWH(w, h/2);
|
2020-12-16 16:44:47 +00:00
|
|
|
sfc->clear(rect, SkPMColor4f::FromBytes_RGBA(color1));
|
2016-01-14 17:24:09 +00:00
|
|
|
|
2016-01-15 14:21:18 +00:00
|
|
|
uint32_t expectedColor1 = 0;
|
2018-06-14 18:41:22 +00:00
|
|
|
uint8_t* expectedBytes1 = reinterpret_cast<uint8_t*>(&expectedColor1);
|
2016-01-14 17:24:09 +00:00
|
|
|
expectedBytes1[0] = GrColorUnpackR(color1);
|
|
|
|
expectedBytes1[1] = GrColorUnpackG(color1);
|
|
|
|
expectedBytes1[2] = GrColorUnpackB(color1);
|
|
|
|
expectedBytes1[3] = GrColorUnpackA(color1);
|
|
|
|
|
|
|
|
for (int y = 0; y < h/2; ++y) {
|
|
|
|
for (int x = 0; x < w; ++x) {
|
|
|
|
expectedPixels.get()[y * h + x] = expectedColor1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-16 16:44:47 +00:00
|
|
|
TestReadPixels(reporter, dContext, sfc, expectedPixels.get(), "RectangleTexture-clear");
|
2016-01-14 17:24:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Reland "Reland "Remove support for copyAsDraw in gpu copySurface.""
This reverts commit 4c6f9b767034c6812d868108516c2580dce3cb56.
Reason for revert: Landing with neuxs 7 and androind one fixes
Original change's description:
> Revert "Reland "Remove support for copyAsDraw in gpu copySurface.""
>
> This reverts commit 84ea04949cabc87a88d06c5c6f6aeb944a745911.
>
> Reason for revert: nexus 7 and android one broken
>
> Original change's description:
> > Reland "Remove support for copyAsDraw in gpu copySurface."
> >
> > This reverts commit c5167c053bd58e6afbad83fe493c0231df3f9704.
> >
> > Reason for revert: fixed
> >
> > Original change's description:
> > > Revert "Remove support for copyAsDraw in gpu copySurface."
> > >
> > > This reverts commit 6565506463db042d3d543a1707f473cdf1ef4e9e.
> > >
> > > Reason for revert: seems to break things?
> > >
> > > Original change's description:
> > > > Remove support for copyAsDraw in gpu copySurface.
> > > >
> > > > The major changes on a higher lever are:
> > > > 1) The majority of all copies now go through GrSurfaceProxy::Copy which
> > > > takes in a proxy and returns a new one with the data copied to it. This
> > > > is the most common use case within Ganesh.
> > > >
> > > > 2) The backend copy calls no longer do draws, require origins to be the
> > > > same, and won't do any swizzling or adjustment of subrects. They are
> > > > all implemented to be dumb copy this data to this other spot.
> > > >
> > > > 3) The GrSurfaceContext copy call has now been moved to priv and renamed
> > > > copyNoDraw, and a new priv copyAsDraw was added to GrRenderTargetContext.
> > > >
> > > > 4) WritePixels and ReplaceRenderTarget both need to specifiy the destination
> > > > of copies. They are the only users (besides the GrSurfaceProxy::Copy) which
> > > > call the priv methods on GrSurfaceContext.
> > > >
> > > > Change-Id: Iaf1eb3a73ccaf39a75af77e281dae594f809186f
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217459
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > >
> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> > >
> > > Change-Id: Id43aa8aa1451e794342e930441d9975b90e6b59f
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218549
> > > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> >
> > Change-Id: I1a96f85ae2ff7622a6b57406755d478e7fbcf56e
> > No-Presubmit: true
> > No-Tree-Checks: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218797
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: I310930a9df30535f45a065263a40239141e15562
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219384
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: I88df4f19aa26ed77b5af4e25d138387cbabd1934
No-Presubmit: true
No-Tree-Checks: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219386
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2019-06-07 15:43:30 +00:00
|
|
|
static void test_copy_to_surface(skiatest::Reporter* reporter,
|
2020-08-11 16:02:22 +00:00
|
|
|
GrDirectContext* dContext,
|
Reland "Reland "Remove support for copyAsDraw in gpu copySurface.""
This reverts commit 4c6f9b767034c6812d868108516c2580dce3cb56.
Reason for revert: Landing with neuxs 7 and androind one fixes
Original change's description:
> Revert "Reland "Remove support for copyAsDraw in gpu copySurface.""
>
> This reverts commit 84ea04949cabc87a88d06c5c6f6aeb944a745911.
>
> Reason for revert: nexus 7 and android one broken
>
> Original change's description:
> > Reland "Remove support for copyAsDraw in gpu copySurface."
> >
> > This reverts commit c5167c053bd58e6afbad83fe493c0231df3f9704.
> >
> > Reason for revert: fixed
> >
> > Original change's description:
> > > Revert "Remove support for copyAsDraw in gpu copySurface."
> > >
> > > This reverts commit 6565506463db042d3d543a1707f473cdf1ef4e9e.
> > >
> > > Reason for revert: seems to break things?
> > >
> > > Original change's description:
> > > > Remove support for copyAsDraw in gpu copySurface.
> > > >
> > > > The major changes on a higher lever are:
> > > > 1) The majority of all copies now go through GrSurfaceProxy::Copy which
> > > > takes in a proxy and returns a new one with the data copied to it. This
> > > > is the most common use case within Ganesh.
> > > >
> > > > 2) The backend copy calls no longer do draws, require origins to be the
> > > > same, and won't do any swizzling or adjustment of subrects. They are
> > > > all implemented to be dumb copy this data to this other spot.
> > > >
> > > > 3) The GrSurfaceContext copy call has now been moved to priv and renamed
> > > > copyNoDraw, and a new priv copyAsDraw was added to GrRenderTargetContext.
> > > >
> > > > 4) WritePixels and ReplaceRenderTarget both need to specifiy the destination
> > > > of copies. They are the only users (besides the GrSurfaceProxy::Copy) which
> > > > call the priv methods on GrSurfaceContext.
> > > >
> > > > Change-Id: Iaf1eb3a73ccaf39a75af77e281dae594f809186f
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217459
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > >
> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> > >
> > > Change-Id: Id43aa8aa1451e794342e930441d9975b90e6b59f
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218549
> > > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> >
> > Change-Id: I1a96f85ae2ff7622a6b57406755d478e7fbcf56e
> > No-Presubmit: true
> > No-Tree-Checks: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218797
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: I310930a9df30535f45a065263a40239141e15562
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219384
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: I88df4f19aa26ed77b5af4e25d138387cbabd1934
No-Presubmit: true
No-Tree-Checks: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219386
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2019-06-07 15:43:30 +00:00
|
|
|
GrSurfaceContext* dstContext,
|
|
|
|
const char* testName) {
|
|
|
|
|
|
|
|
int pixelCnt = dstContext->width() * dstContext->height();
|
|
|
|
SkAutoTMalloc<uint32_t> pixels(pixelCnt);
|
|
|
|
for (int y = 0; y < dstContext->width(); ++y) {
|
|
|
|
for (int x = 0; x < dstContext->height(); ++x) {
|
|
|
|
pixels.get()[y * dstContext->width() + x] =
|
|
|
|
SkColorToPremulGrColor(SkColorSetARGB(2*y, y, x, x * y));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto renderable : {GrRenderable::kNo, GrRenderable::kYes}) {
|
2020-02-13 19:25:00 +00:00
|
|
|
auto origin = dstContext->origin();
|
2020-12-24 01:36:44 +00:00
|
|
|
GrImageInfo info(GrColorType::kRGBA_8888,
|
|
|
|
kPremul_SkAlphaType,
|
|
|
|
nullptr,
|
|
|
|
dstContext->dimensions());
|
|
|
|
GrPixmap pixmap(info, pixels.get(), dstContext->width()*sizeof(uint32_t));
|
|
|
|
auto srcView = sk_gpu_test::MakeTextureProxyViewFromData(dContext,
|
|
|
|
renderable,
|
|
|
|
origin,
|
|
|
|
pixmap);
|
Reland "Reland "Remove support for copyAsDraw in gpu copySurface.""
This reverts commit 4c6f9b767034c6812d868108516c2580dce3cb56.
Reason for revert: Landing with neuxs 7 and androind one fixes
Original change's description:
> Revert "Reland "Remove support for copyAsDraw in gpu copySurface.""
>
> This reverts commit 84ea04949cabc87a88d06c5c6f6aeb944a745911.
>
> Reason for revert: nexus 7 and android one broken
>
> Original change's description:
> > Reland "Remove support for copyAsDraw in gpu copySurface."
> >
> > This reverts commit c5167c053bd58e6afbad83fe493c0231df3f9704.
> >
> > Reason for revert: fixed
> >
> > Original change's description:
> > > Revert "Remove support for copyAsDraw in gpu copySurface."
> > >
> > > This reverts commit 6565506463db042d3d543a1707f473cdf1ef4e9e.
> > >
> > > Reason for revert: seems to break things?
> > >
> > > Original change's description:
> > > > Remove support for copyAsDraw in gpu copySurface.
> > > >
> > > > The major changes on a higher lever are:
> > > > 1) The majority of all copies now go through GrSurfaceProxy::Copy which
> > > > takes in a proxy and returns a new one with the data copied to it. This
> > > > is the most common use case within Ganesh.
> > > >
> > > > 2) The backend copy calls no longer do draws, require origins to be the
> > > > same, and won't do any swizzling or adjustment of subrects. They are
> > > > all implemented to be dumb copy this data to this other spot.
> > > >
> > > > 3) The GrSurfaceContext copy call has now been moved to priv and renamed
> > > > copyNoDraw, and a new priv copyAsDraw was added to GrRenderTargetContext.
> > > >
> > > > 4) WritePixels and ReplaceRenderTarget both need to specifiy the destination
> > > > of copies. They are the only users (besides the GrSurfaceProxy::Copy) which
> > > > call the priv methods on GrSurfaceContext.
> > > >
> > > > Change-Id: Iaf1eb3a73ccaf39a75af77e281dae594f809186f
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217459
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > >
> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> > >
> > > Change-Id: Id43aa8aa1451e794342e930441d9975b90e6b59f
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218549
> > > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> >
> > Change-Id: I1a96f85ae2ff7622a6b57406755d478e7fbcf56e
> > No-Presubmit: true
> > No-Tree-Checks: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218797
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: I310930a9df30535f45a065263a40239141e15562
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219384
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: I88df4f19aa26ed77b5af4e25d138387cbabd1934
No-Presubmit: true
No-Tree-Checks: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219386
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2019-06-07 15:43:30 +00:00
|
|
|
// If this assert ever fails we can add a fallback to do copy as draw, but until then we can
|
|
|
|
// be more restrictive.
|
2020-08-12 18:06:50 +00:00
|
|
|
SkAssertResult(dstContext->testCopy(srcView.proxy()));
|
2020-08-11 16:02:22 +00:00
|
|
|
TestReadPixels(reporter, dContext, dstContext, pixels.get(), testName);
|
Reland "Reland "Remove support for copyAsDraw in gpu copySurface.""
This reverts commit 4c6f9b767034c6812d868108516c2580dce3cb56.
Reason for revert: Landing with neuxs 7 and androind one fixes
Original change's description:
> Revert "Reland "Remove support for copyAsDraw in gpu copySurface.""
>
> This reverts commit 84ea04949cabc87a88d06c5c6f6aeb944a745911.
>
> Reason for revert: nexus 7 and android one broken
>
> Original change's description:
> > Reland "Remove support for copyAsDraw in gpu copySurface."
> >
> > This reverts commit c5167c053bd58e6afbad83fe493c0231df3f9704.
> >
> > Reason for revert: fixed
> >
> > Original change's description:
> > > Revert "Remove support for copyAsDraw in gpu copySurface."
> > >
> > > This reverts commit 6565506463db042d3d543a1707f473cdf1ef4e9e.
> > >
> > > Reason for revert: seems to break things?
> > >
> > > Original change's description:
> > > > Remove support for copyAsDraw in gpu copySurface.
> > > >
> > > > The major changes on a higher lever are:
> > > > 1) The majority of all copies now go through GrSurfaceProxy::Copy which
> > > > takes in a proxy and returns a new one with the data copied to it. This
> > > > is the most common use case within Ganesh.
> > > >
> > > > 2) The backend copy calls no longer do draws, require origins to be the
> > > > same, and won't do any swizzling or adjustment of subrects. They are
> > > > all implemented to be dumb copy this data to this other spot.
> > > >
> > > > 3) The GrSurfaceContext copy call has now been moved to priv and renamed
> > > > copyNoDraw, and a new priv copyAsDraw was added to GrRenderTargetContext.
> > > >
> > > > 4) WritePixels and ReplaceRenderTarget both need to specifiy the destination
> > > > of copies. They are the only users (besides the GrSurfaceProxy::Copy) which
> > > > call the priv methods on GrSurfaceContext.
> > > >
> > > > Change-Id: Iaf1eb3a73ccaf39a75af77e281dae594f809186f
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217459
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > >
> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> > >
> > > Change-Id: Id43aa8aa1451e794342e930441d9975b90e6b59f
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218549
> > > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> >
> > Change-Id: I1a96f85ae2ff7622a6b57406755d478e7fbcf56e
> > No-Presubmit: true
> > No-Tree-Checks: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218797
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: I310930a9df30535f45a065263a40239141e15562
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219384
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: I88df4f19aa26ed77b5af4e25d138387cbabd1934
No-Presubmit: true
No-Tree-Checks: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219386
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2019-06-07 15:43:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-08 21:18:15 +00:00
|
|
|
#ifdef SK_GL
|
2016-04-06 21:02:39 +00:00
|
|
|
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
|
2020-08-11 16:02:22 +00:00
|
|
|
auto dContext = ctxInfo.directContext();
|
2020-07-06 14:56:46 +00:00
|
|
|
|
2020-08-11 16:02:22 +00:00
|
|
|
GrProxyProvider* proxyProvider = dContext->priv().proxyProvider();
|
Reland "Reland "Remove support for copyAsDraw in gpu copySurface.""
This reverts commit 4c6f9b767034c6812d868108516c2580dce3cb56.
Reason for revert: Landing with neuxs 7 and androind one fixes
Original change's description:
> Revert "Reland "Remove support for copyAsDraw in gpu copySurface.""
>
> This reverts commit 84ea04949cabc87a88d06c5c6f6aeb944a745911.
>
> Reason for revert: nexus 7 and android one broken
>
> Original change's description:
> > Reland "Remove support for copyAsDraw in gpu copySurface."
> >
> > This reverts commit c5167c053bd58e6afbad83fe493c0231df3f9704.
> >
> > Reason for revert: fixed
> >
> > Original change's description:
> > > Revert "Remove support for copyAsDraw in gpu copySurface."
> > >
> > > This reverts commit 6565506463db042d3d543a1707f473cdf1ef4e9e.
> > >
> > > Reason for revert: seems to break things?
> > >
> > > Original change's description:
> > > > Remove support for copyAsDraw in gpu copySurface.
> > > >
> > > > The major changes on a higher lever are:
> > > > 1) The majority of all copies now go through GrSurfaceProxy::Copy which
> > > > takes in a proxy and returns a new one with the data copied to it. This
> > > > is the most common use case within Ganesh.
> > > >
> > > > 2) The backend copy calls no longer do draws, require origins to be the
> > > > same, and won't do any swizzling or adjustment of subrects. They are
> > > > all implemented to be dumb copy this data to this other spot.
> > > >
> > > > 3) The GrSurfaceContext copy call has now been moved to priv and renamed
> > > > copyNoDraw, and a new priv copyAsDraw was added to GrRenderTargetContext.
> > > >
> > > > 4) WritePixels and ReplaceRenderTarget both need to specifiy the destination
> > > > of copies. They are the only users (besides the GrSurfaceProxy::Copy) which
> > > > call the priv methods on GrSurfaceContext.
> > > >
> > > > Change-Id: Iaf1eb3a73ccaf39a75af77e281dae594f809186f
> > > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/217459
> > > > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > >
> > > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> > >
> > > Change-Id: Id43aa8aa1451e794342e930441d9975b90e6b59f
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218549
> > > Reviewed-by: Greg Daniel <egdaniel@google.com>
> > > Commit-Queue: Greg Daniel <egdaniel@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
> >
> > Change-Id: I1a96f85ae2ff7622a6b57406755d478e7fbcf56e
> > No-Presubmit: true
> > No-Tree-Checks: true
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/218797
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
>
> Change-Id: I310930a9df30535f45a065263a40239141e15562
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219384
> Reviewed-by: Greg Daniel <egdaniel@google.com>
> Commit-Queue: Greg Daniel <egdaniel@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com
Change-Id: I88df4f19aa26ed77b5af4e25d138387cbabd1934
No-Presubmit: true
No-Tree-Checks: true
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/219386
Commit-Queue: Greg Daniel <egdaniel@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
2019-06-07 15:43:30 +00:00
|
|
|
static const int kWidth = 16;
|
|
|
|
static const int kHeight = 16;
|
2016-01-14 17:24:09 +00:00
|
|
|
|
2020-06-19 23:51:21 +00:00
|
|
|
uint32_t pixels[kWidth * kHeight];
|
2016-01-14 17:24:09 +00:00
|
|
|
for (int y = 0; y < kHeight; ++y) {
|
|
|
|
for (int x = 0; x < kWidth; ++x) {
|
|
|
|
pixels[y * kWidth + x] = y * kWidth + x;
|
|
|
|
}
|
|
|
|
}
|
2020-06-19 23:51:21 +00:00
|
|
|
auto ii = SkImageInfo::Make(kWidth, kHeight, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
|
|
|
|
SkPixmap pm(ii, pixels, sizeof(uint32_t)*kWidth);
|
2016-01-14 17:24:09 +00:00
|
|
|
|
Revert "Revert "Plumb GrBackendTexture throughout skia.""
This reverts commit 7fa5c31c2c9af834bee66d5fcf476e250076c8d6.
Reason for revert: Relanding this change now that other fixes have landed.
Original change's description:
> Revert "Plumb GrBackendTexture throughout skia."
>
> This reverts commit 7da62b9059f3c1d31624a0e4da96ee5f908f9c12.
>
> Reason for revert: fix android roll
>
> Original change's description:
> > Plumb GrBackendTexture throughout skia.
> >
> > Bug: skia:
> > Change-Id: I1bae6768ee7229818a83ba608035a1f7867e6875
> > Reviewed-on: https://skia-review.googlesource.com/13645
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
> > Reviewed-by: Robert Phillips <robertphillips@google.com>
> >
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,brianosman@google.com,reviews@skia.org,stani@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
>
> Change-Id: I5cb8763cc837c83ebc6d10366fe2dd3efe35fb89
> Reviewed-on: https://skia-review.googlesource.com/13773
> Reviewed-by: Stan Iliev <stani@google.com>
> Commit-Queue: Stan Iliev <stani@google.com>
>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reviews@skia.org,brianosman@google.com,stani@google.com
# Not skipping CQ checks because original CL landed > 1 day ago.
Change-Id: I92bc074e4fe37fa5c83186afadc472c03802e8f2
Reviewed-on: https://skia-review.googlesource.com/13975
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-04-20 16:41:55 +00:00
|
|
|
for (auto origin : { kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin }) {
|
|
|
|
|
2020-06-19 23:51:21 +00:00
|
|
|
auto format = GrBackendFormat::MakeGL(GR_GL_RGBA8, GR_GL_TEXTURE_RECTANGLE);
|
2020-08-11 16:02:22 +00:00
|
|
|
GrBackendTexture rectangleTex = dContext->createBackendTexture(kWidth,
|
2020-12-07 17:19:47 +00:00
|
|
|
kHeight,
|
|
|
|
format,
|
|
|
|
GrMipmapped::kNo,
|
|
|
|
GrRenderable::kYes);
|
2020-06-19 23:51:21 +00:00
|
|
|
if (!rectangleTex.isValid()) {
|
|
|
|
continue;
|
2020-06-19 17:10:45 +00:00
|
|
|
}
|
2016-01-14 17:24:09 +00:00
|
|
|
|
2020-12-07 16:30:16 +00:00
|
|
|
if (!dContext->updateBackendTexture(rectangleTex, &pm, 1, origin, nullptr, nullptr)) {
|
2020-06-19 23:51:21 +00:00
|
|
|
continue;
|
|
|
|
}
|
2020-06-19 19:11:27 +00:00
|
|
|
|
2016-01-14 17:24:09 +00:00
|
|
|
GrColor refPixels[kWidth * kHeight];
|
|
|
|
for (int y = 0; y < kHeight; ++y) {
|
|
|
|
for (int x = 0; x < kWidth; ++x) {
|
2020-12-07 16:30:16 +00:00
|
|
|
refPixels[y * kWidth + x] = pixels[y * kWidth + x];
|
2016-01-14 17:24:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-06 15:00:03 +00:00
|
|
|
sk_sp<GrTextureProxy> rectProxy = proxyProvider->wrapBackendTexture(
|
2020-03-27 14:42:15 +00:00
|
|
|
rectangleTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
|
2018-01-16 13:06:32 +00:00
|
|
|
|
2017-01-27 15:58:31 +00:00
|
|
|
if (!rectProxy) {
|
2020-08-11 16:02:22 +00:00
|
|
|
dContext->deleteBackendTexture(rectangleTex);
|
2017-01-27 15:58:31 +00:00
|
|
|
continue;
|
2016-01-14 17:24:09 +00:00
|
|
|
}
|
|
|
|
|
2020-07-21 16:09:58 +00:00
|
|
|
SkASSERT(rectProxy->mipmapped() == GrMipmapped::kNo);
|
2020-07-23 14:33:24 +00:00
|
|
|
SkASSERT(rectProxy->peekTexture()->mipmapped() == GrMipmapped::kNo);
|
2018-03-21 16:13:37 +00:00
|
|
|
|
2018-07-31 21:25:29 +00:00
|
|
|
SkASSERT(rectProxy->textureType() == GrTextureType::kRectangle);
|
2020-07-23 14:33:24 +00:00
|
|
|
SkASSERT(rectProxy->peekTexture()->textureType() == GrTextureType::kRectangle);
|
2018-07-31 21:25:29 +00:00
|
|
|
SkASSERT(rectProxy->hasRestrictedSampling());
|
2020-07-23 14:33:24 +00:00
|
|
|
SkASSERT(rectProxy->peekTexture()->hasRestrictedSampling());
|
2018-03-21 16:13:37 +00:00
|
|
|
|
2020-12-07 17:19:47 +00:00
|
|
|
GrImageInfo grII = ii;
|
2020-08-11 16:02:22 +00:00
|
|
|
GrSwizzle swizzle = dContext->priv().caps()->getReadSwizzle(rectangleTex.getBackendFormat(),
|
2020-12-07 17:19:47 +00:00
|
|
|
grII.colorType());
|
2020-02-11 16:54:55 +00:00
|
|
|
GrSurfaceProxyView view(rectProxy, origin, swizzle);
|
|
|
|
|
2020-12-07 17:19:47 +00:00
|
|
|
test_basic_draw_as_src(reporter, dContext, view, grII.colorType(), kPremul_SkAlphaType,
|
|
|
|
refPixels);
|
2017-01-25 17:10:37 +00:00
|
|
|
|
2017-01-27 15:11:42 +00:00
|
|
|
// Test copy to both a texture and RT
|
2020-12-07 17:19:47 +00:00
|
|
|
TestCopyFromSurface(reporter, dContext, rectProxy.get(), origin, grII.colorType(),
|
2020-01-30 19:55:05 +00:00
|
|
|
refPixels, "RectangleTexture-copy-from");
|
2016-01-14 17:24:09 +00:00
|
|
|
|
2020-12-07 17:19:47 +00:00
|
|
|
auto rectContext = GrSurfaceContext::Make(dContext, std::move(view), grII.colorInfo());
|
2017-01-25 17:10:37 +00:00
|
|
|
SkASSERT(rectContext);
|
2016-11-07 14:53:44 +00:00
|
|
|
|
2020-08-11 16:02:22 +00:00
|
|
|
TestReadPixels(reporter, dContext, rectContext.get(), refPixels, "RectangleTexture-read");
|
2016-01-14 17:24:09 +00:00
|
|
|
|
2020-08-11 16:02:22 +00:00
|
|
|
test_copy_to_surface(reporter, dContext, rectContext.get(), "RectangleTexture-copy-to");
|
2016-01-14 17:24:09 +00:00
|
|
|
|
2020-08-11 16:02:22 +00:00
|
|
|
TestWritePixels(reporter, dContext, rectContext.get(), true, "RectangleTexture-write");
|
2016-01-14 17:24:09 +00:00
|
|
|
|
2020-08-11 16:02:22 +00:00
|
|
|
test_clear(reporter, dContext, rectContext.get());
|
2016-01-14 17:24:09 +00:00
|
|
|
|
2020-08-11 16:02:22 +00:00
|
|
|
dContext->deleteBackendTexture(rectangleTex);
|
2016-01-14 17:24:09 +00:00
|
|
|
}
|
|
|
|
}
|
2019-11-08 21:18:15 +00:00
|
|
|
#endif
|