2017-01-27 15:11:42 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2017 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 "include/core/SkBitmap.h"
|
2019-07-15 16:30:44 +00:00
|
|
|
#include "src/gpu/GrDataUtils.h"
|
2019-04-23 17:05:21 +00:00
|
|
|
#include "tests/Test.h"
|
2017-01-27 15:11:42 +00:00
|
|
|
|
|
|
|
class GrSurfaceContext;
|
|
|
|
class GrSurfaceProxy;
|
2018-07-17 17:28:20 +00:00
|
|
|
typedef uint32_t GrColor;
|
2017-01-27 15:11:42 +00:00
|
|
|
|
|
|
|
// Ensure that reading back from 'srcContext' as RGBA 8888 matches 'expectedPixelValues
|
2019-06-24 19:50:07 +00:00
|
|
|
void test_read_pixels(skiatest::Reporter*, GrSurfaceContext* srcContext,
|
|
|
|
uint32_t expectedPixelValues[], const char* testName);
|
2017-01-27 15:11:42 +00:00
|
|
|
|
|
|
|
// See if trying to write RGBA 8888 pixels to 'dstContext' matches matches the
|
|
|
|
// expectation ('expectedToWork')
|
2019-06-24 19:50:07 +00:00
|
|
|
void test_write_pixels(skiatest::Reporter*, GrSurfaceContext* srcContext, bool expectedToWork,
|
|
|
|
const char* testName);
|
2017-01-27 15:11:42 +00:00
|
|
|
|
2019-06-24 19:50:07 +00:00
|
|
|
// Ensure that the pixels can be copied from 'proxy' viewed as colorType, to an RGBA 8888
|
|
|
|
// destination (both texture-backed and rendertarget-backed).
|
|
|
|
void test_copy_from_surface(skiatest::Reporter*, GrContext*, GrSurfaceProxy* proxy,
|
|
|
|
GrColorType colorType, uint32_t expectedPixelValues[],
|
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
|
|
|
const char* testName);
|
2018-07-17 17:28:20 +00:00
|
|
|
|
|
|
|
// Fills data with a red-green gradient
|
|
|
|
void fill_pixel_data(int width, int height, GrColor* data);
|
|
|
|
|
2019-05-07 17:29:22 +00:00
|
|
|
// Create a solid colored backend texture
|
|
|
|
bool create_backend_texture(GrContext*, GrBackendTexture* backendTex,
|
|
|
|
const SkImageInfo& ii, GrMipMapped mipMapped, SkColor color,
|
2019-05-13 14:40:06 +00:00
|
|
|
GrRenderable);
|
2019-05-07 17:29:22 +00:00
|
|
|
|
|
|
|
void delete_backend_texture(GrContext*, const GrBackendTexture& backendTex);
|
|
|
|
|
2018-07-17 17:28:20 +00:00
|
|
|
// Checks srcBuffer and dstBuffer contain the same colors
|
2019-06-10 19:09:34 +00:00
|
|
|
bool does_full_buffer_contain_correct_color(const GrColor* srcBuffer, const GrColor* dstBuffer,
|
|
|
|
int width, int height);
|
2018-10-01 16:42:53 +00:00
|
|
|
|
|
|
|
// Encodes the bitmap into a data:/image/png;base64,... url suitable to view in a browser after
|
|
|
|
// printing to a log. If false is returned, dst holds an error message instead of a URI.
|
|
|
|
bool bitmap_to_base64_data_uri(const SkBitmap& bitmap, SkString* dst);
|
2019-07-15 16:30:44 +00:00
|
|
|
|
|
|
|
/** Used by compare_pixels. */
|
|
|
|
using ComparePixmapsErrorReporter = void(int x, int y, const float diffs[4]);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Compares pixels pointed to by 'a' with 'infoA' and rowBytesA to pixels pointed to by 'b' with
|
|
|
|
* 'infoB' and 'rowBytesB'.
|
|
|
|
*
|
|
|
|
* If the infos have different dimensions error is called with negative coordinate values and
|
|
|
|
* zero diffs and no comparisons are made.
|
|
|
|
*
|
|
|
|
* Before comparison pixels are converted to a common color type, alpha type, and color space.
|
|
|
|
* The color type is always 32 bit float. The alpha type is premul if one of 'infoA' and 'infoB' is
|
|
|
|
* premul and the other is unpremul. The color space is linear sRGB if 'infoA' and 'infoB' have
|
|
|
|
* different colorspaces, otherwise their common color space is used.
|
|
|
|
*
|
|
|
|
* 'tolRGBA' expresses the allowed difference between pixels in the comparison space per channel. If
|
|
|
|
* pixel components differ more than by 'tolRGBA' in absolute value in any channel then 'error' is
|
|
|
|
* called with the coordinate and difference in the comparison space (B - A).
|
|
|
|
*
|
|
|
|
* The function quits after a single error is reported and returns false if 'error' was called and
|
|
|
|
* true otherwise.
|
|
|
|
*/
|
|
|
|
bool compare_pixels(const GrPixelInfo& infoA, const char* a, size_t rowBytesA,
|
|
|
|
const GrPixelInfo& infoB, const char* b, size_t rowBytesB,
|
|
|
|
const float tolRGBA[4], std::function<ComparePixmapsErrorReporter>& error);
|
|
|
|
|
|
|
|
/** Convenience version of above that takes SkPixmap inputs. */
|
|
|
|
bool compare_pixels(const SkPixmap& a, const SkPixmap& b, const float tolRGBA[4],
|
|
|
|
std::function<ComparePixmapsErrorReporter>& error);
|