skia2/tests/RectangleTextureTest.cpp

204 lines
8.4 KiB
C++
Raw Normal View History

/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "tests/Test.h"
#include "tests/TestUtils.h"
#include "include/gpu/GrDirectContext.h"
#include "src/gpu/GrContextPriv.h"
#include "src/gpu/GrProxyProvider.h"
#include "src/gpu/GrRenderTargetContext.h"
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
#include "src/gpu/GrSurfaceContextPriv.h"
#include "src/gpu/GrSurfacePriv.h"
#include "src/gpu/GrTexturePriv.h"
#include "src/gpu/SkGr.h"
#ifdef SK_GL
#include "src/gpu/gl/GrGLGpu.h"
#include "src/gpu/gl/GrGLUtil.h"
#endif
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>
2019-06-05 20:52:02 +00:00
#include "tools/gpu/ProxyUtils.h"
// skbug.com/5932
static void test_basic_draw_as_src(skiatest::Reporter* reporter, GrRecordingContext* context,
GrSurfaceProxyView rectView, GrColorType colorType,
SkAlphaType alphaType, uint32_t expectedPixelValues[]) {
auto rtContext = GrRenderTargetContext::Make(
context, colorType, nullptr, SkBackingFit::kExact, rectView.proxy()->dimensions());
for (auto filter : {GrSamplerState::Filter::kNearest,
GrSamplerState::Filter::kLinear,
GrSamplerState::Filter::kMipMap}) {
Reland "Simplify GrRTC::clean APIs" This reverts commit 4730f29993783fc9e96e45098d7e708fe08f1f26. Reason for revert: Fix WIP Original change's description: > Revert "Simplify GrRTC::clean APIs" > > This reverts commit 6cbd7c2e57af9c499f7e99feb215b890fdd3a10a. > > Reason for revert: mac/generated files failures > > Original change's description: > > Simplify GrRTC::clean APIs > > > > The CanClearFullscreen enum type is removed. Most usages of clear() had > > kYes because a null scissor rect was provided, or had kNo because the > > scissor was really critical to the behavior. A few places did provide a > > scissor and kYes (e.g. for initializing the target). > > > > To simplify this, the public GrRTC has two variants of clear(). One with > > only a color (for fullscreen clears), and one with a rect for partial > > clears. The private API also adds a clearAtLeast() function that replaces > > the several cases where we'd have a scissor but could expand to fullscreen. > > > > I find the current control flow in internalClear() to be hard to > > follow (albeit I was the one to make it that way...), but later CLs > > will improve it. > > > > Bug: skia:10205 > > Change-Id: I87cf8d688c58fbe58ee854fbc4ffe22482d969c6 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290256 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com > > Change-Id: I7131df6f5323f4f9c120cbcfd9bc57e627e2eb65 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:10205 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291842 > Reviewed-by: Michael Ludwig <michaelludwig@google.com> > Commit-Queue: Michael Ludwig <michaelludwig@google.com> # Not skipping CQ checks because this is a reland. Bug: skia:10205 Change-Id: Id5db153d7c2500279cca8478818b66f67a53e143 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291844 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-05-26 20:57:38 +00:00
rtContext->clear(SkPMColor4f::FromBytes_RGBA(0xDDCCBBAA));
auto fp = GrTextureEffect::Make(rectView, alphaType, SkMatrix::I(), filter);
GrPaint paint;
paint.setPorterDuffXPFactory(SkBlendMode::kSrc);
paint.addColorFragmentProcessor(std::move(fp));
Reland "GrClips provided as pointers to GrRTC" This reverts commit 074414fed53efcab7f33b06454958707419e37d8. Reason for revert: updated to guard against nullptr before calling quickContains(rrect). Original change's description: > Revert "GrClips provided as pointers to GrRTC" > > This reverts commit 226b689471a0fbb7400bc166032458278957541b. > > Reason for revert: Breaks Android roller > > Original change's description: > > GrClips provided as pointers to GrRTC > > > > A null clip represents no high-level clipping is necessary (the implicit > > clip to the render target's logical dimensions is fine). > > > > This also removes GrNoClip and GrFixedClip::Disabled() since they are > > replaced with just nullptr. > > > > By allowing nullptr to represent no intended clipping, it makes it easier > > to require GrClip and GrAppliedClip objects to know about the dimensions > > of the device. If we required a non-null clip object to represent no > > clipping, we'd have to have an instance for each device based on its > > size and that just became cumbersome. > > > > Bug: skia:10205 > > Change-Id: Ie30cc71820b92d99356d393a4c98c8677082e761 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290539 > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com > > Change-Id: I42c4828bcf016ee3d30d5c20b771be96e125817b > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:10205 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292856 > Reviewed-by: Weston Tracey <westont@google.com> > Commit-Queue: Weston Tracey <westont@google.com> TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com,westont@google.com # Not skipping CQ checks because this is a reland. Bug: skia:10205 Change-Id: I5715a4de3b7c8847b73020dc4937d3816d879803 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/292876 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-05-29 13:54:07 +00:00
rtContext->drawPaint(nullptr, std::move(paint), SkMatrix::I());
TestReadPixels(reporter, rtContext.get(), expectedPixelValues,
"RectangleTexture-basic-draw");
}
}
static void test_clear(skiatest::Reporter* reporter, GrSurfaceContext* rectContext) {
if (GrRenderTargetContext* rtc = rectContext->asRenderTargetContext()) {
// Clear the whole thing.
GrColor color0 = GrColorPackRGBA(0xA, 0xB, 0xC, 0xD);
Reland "Simplify GrRTC::clean APIs" This reverts commit 4730f29993783fc9e96e45098d7e708fe08f1f26. Reason for revert: Fix WIP Original change's description: > Revert "Simplify GrRTC::clean APIs" > > This reverts commit 6cbd7c2e57af9c499f7e99feb215b890fdd3a10a. > > Reason for revert: mac/generated files failures > > Original change's description: > > Simplify GrRTC::clean APIs > > > > The CanClearFullscreen enum type is removed. Most usages of clear() had > > kYes because a null scissor rect was provided, or had kNo because the > > scissor was really critical to the behavior. A few places did provide a > > scissor and kYes (e.g. for initializing the target). > > > > To simplify this, the public GrRTC has two variants of clear(). One with > > only a color (for fullscreen clears), and one with a rect for partial > > clears. The private API also adds a clearAtLeast() function that replaces > > the several cases where we'd have a scissor but could expand to fullscreen. > > > > I find the current control flow in internalClear() to be hard to > > follow (albeit I was the one to make it that way...), but later CLs > > will improve it. > > > > Bug: skia:10205 > > Change-Id: I87cf8d688c58fbe58ee854fbc4ffe22482d969c6 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290256 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com > > Change-Id: I7131df6f5323f4f9c120cbcfd9bc57e627e2eb65 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:10205 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291842 > Reviewed-by: Michael Ludwig <michaelludwig@google.com> > Commit-Queue: Michael Ludwig <michaelludwig@google.com> # Not skipping CQ checks because this is a reland. Bug: skia:10205 Change-Id: Id5db153d7c2500279cca8478818b66f67a53e143 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291844 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-05-26 20:57:38 +00:00
rtc->clear(SkPMColor4f::FromBytes_RGBA(color0));
int w = rtc->width();
int h = rtc->height();
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.
uint32_t expectedColor0 = 0;
uint8_t* expectedBytes0 = reinterpret_cast<uint8_t*>(&expectedColor0);
expectedBytes0[0] = GrColorUnpackR(color0);
expectedBytes0[1] = GrColorUnpackG(color0);
expectedBytes0[2] = GrColorUnpackB(color0);
expectedBytes0[3] = GrColorUnpackA(color0);
for (int i = 0; i < rtc->width() * rtc->height(); ++i) {
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);
Reland "Simplify GrRTC::clean APIs" This reverts commit 4730f29993783fc9e96e45098d7e708fe08f1f26. Reason for revert: Fix WIP Original change's description: > Revert "Simplify GrRTC::clean APIs" > > This reverts commit 6cbd7c2e57af9c499f7e99feb215b890fdd3a10a. > > Reason for revert: mac/generated files failures > > Original change's description: > > Simplify GrRTC::clean APIs > > > > The CanClearFullscreen enum type is removed. Most usages of clear() had > > kYes because a null scissor rect was provided, or had kNo because the > > scissor was really critical to the behavior. A few places did provide a > > scissor and kYes (e.g. for initializing the target). > > > > To simplify this, the public GrRTC has two variants of clear(). One with > > only a color (for fullscreen clears), and one with a rect for partial > > clears. The private API also adds a clearAtLeast() function that replaces > > the several cases where we'd have a scissor but could expand to fullscreen. > > > > I find the current control flow in internalClear() to be hard to > > follow (albeit I was the one to make it that way...), but later CLs > > will improve it. > > > > Bug: skia:10205 > > Change-Id: I87cf8d688c58fbe58ee854fbc4ffe22482d969c6 > > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/290256 > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > Commit-Queue: Michael Ludwig <michaelludwig@google.com> > > TBR=bsalomon@google.com,csmartdalton@google.com,michaelludwig@google.com > > Change-Id: I7131df6f5323f4f9c120cbcfd9bc57e627e2eb65 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: skia:10205 > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291842 > Reviewed-by: Michael Ludwig <michaelludwig@google.com> > Commit-Queue: Michael Ludwig <michaelludwig@google.com> # Not skipping CQ checks because this is a reland. Bug: skia:10205 Change-Id: Id5db153d7c2500279cca8478818b66f67a53e143 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/291844 Reviewed-by: Michael Ludwig <michaelludwig@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
2020-05-26 20:57:38 +00:00
rtc->clear(rect, SkPMColor4f::FromBytes_RGBA(color1));
uint32_t expectedColor1 = 0;
uint8_t* expectedBytes1 = reinterpret_cast<uint8_t*>(&expectedColor1);
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;
}
}
TestReadPixels(reporter, rtc, expectedPixels.get(), "RectangleTexture-clear");
}
}
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,
GrDirectContext* context,
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}) {
auto origin = dstContext->origin();
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
auto src = sk_gpu_test::MakeTextureProxyFromData(
context, renderable, origin,
{GrColorType::kRGBA_8888, kPremul_SkAlphaType, nullptr, dstContext->width(),
dstContext->height()},
pixels.get(), 0);
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.
SkAssertResult(dstContext->testCopy(src.get()));
TestReadPixels(reporter, 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
}
}
#ifdef SK_GL
DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(RectangleTexture, reporter, ctxInfo) {
auto direct = ctxInfo.directContext();
GrProxyProvider* proxyProvider = direct->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;
uint32_t pixels[kWidth * kHeight];
for (int y = 0; y < kHeight; ++y) {
for (int x = 0; x < kWidth; ++x) {
pixels[y * kWidth + x] = y * kWidth + x;
}
}
auto ii = SkImageInfo::Make(kWidth, kHeight, kRGBA_8888_SkColorType, kPremul_SkAlphaType);
SkPixmap pm(ii, pixels, sizeof(uint32_t)*kWidth);
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 }) {
bool useBLOrigin = kBottomLeft_GrSurfaceOrigin == origin;
auto format = GrBackendFormat::MakeGL(GR_GL_RGBA8, GR_GL_TEXTURE_RECTANGLE);
GrBackendTexture rectangleTex = direct->createBackendTexture(kWidth,
kHeight,
format,
GrMipmapped::kNo,
GrRenderable::kYes);
if (!rectangleTex.isValid()) {
continue;
}
if (!direct->updateBackendTexture(rectangleTex, &pm, 1, nullptr, nullptr)) {
continue;
}
GrColor refPixels[kWidth * kHeight];
for (int y = 0; y < kHeight; ++y) {
for (int x = 0; x < kWidth; ++x) {
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
int y0 = useBLOrigin ? kHeight - y - 1 : y;
refPixels[y * kWidth + x] = pixels[y0 * kWidth + x];
}
}
sk_sp<GrTextureProxy> rectProxy = proxyProvider->wrapBackendTexture(
rectangleTex, kBorrow_GrWrapOwnership, GrWrapCacheable::kNo, kRW_GrIOType);
if (!rectProxy) {
direct->deleteBackendTexture(rectangleTex);
continue;
}
SkASSERT(rectProxy->mipMapped() == GrMipmapped::kNo);
SkASSERT(rectProxy->peekTexture()->texturePriv().mipMapped() == GrMipmapped::kNo);
SkASSERT(rectProxy->textureType() == GrTextureType::kRectangle);
SkASSERT(rectProxy->peekTexture()->texturePriv().textureType() ==
GrTextureType::kRectangle);
SkASSERT(rectProxy->hasRestrictedSampling());
SkASSERT(rectProxy->peekTexture()->texturePriv().hasRestrictedSampling());
GrSwizzle swizzle = direct->priv().caps()->getReadSwizzle(rectangleTex.getBackendFormat(),
GrColorType::kRGBA_8888);
GrSurfaceProxyView view(rectProxy, origin, swizzle);
test_basic_draw_as_src(reporter, direct, view, GrColorType::kRGBA_8888,
kPremul_SkAlphaType, refPixels);
// Test copy to both a texture and RT
TestCopyFromSurface(reporter, direct, rectProxy.get(), origin, GrColorType::kRGBA_8888,
refPixels, "RectangleTexture-copy-from");
auto rectContext = GrSurfaceContext::Make(direct, std::move(view),
GrColorType::kRGBA_8888, kPremul_SkAlphaType,
nullptr);
SkASSERT(rectContext);
TestReadPixels(reporter, rectContext.get(), refPixels, "RectangleTexture-read");
test_copy_to_surface(reporter, direct, rectContext.get(), "RectangleTexture-copy-to");
TestWritePixels(reporter, rectContext.get(), true, "RectangleTexture-write");
test_clear(reporter, rectContext.get());
direct->deleteBackendTexture(rectangleTex);
}
}
#endif