2012-07-27 21:10:42 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2018-06-08 15:49:19 +00:00
|
|
|
/* Generated by tools/bookmaker from include/core/SkSurface.h and docs/SkSurface_Reference.bmh
|
2018-07-13 12:21:59 +00:00
|
|
|
on 2018-07-13 08:15:11. Additional documentation and examples can be found at:
|
2018-06-08 15:49:19 +00:00
|
|
|
https://skia.org/user/api/SkSurface_Reference
|
|
|
|
|
|
|
|
You may edit either file directly. Structural changes to public interfaces require
|
|
|
|
editing both files. After editing docs/SkSurface_Reference.bmh, run:
|
|
|
|
bookmaker -b docs -i include/core/SkSurface.h -p
|
|
|
|
to create an updated version of this file.
|
|
|
|
*/
|
|
|
|
|
2012-07-27 21:10:42 +00:00
|
|
|
#ifndef SkSurface_DEFINED
|
|
|
|
#define SkSurface_DEFINED
|
|
|
|
|
|
|
|
#include "SkRefCnt.h"
|
|
|
|
#include "SkImage.h"
|
2014-09-22 14:29:03 +00:00
|
|
|
#include "SkSurfaceProps.h"
|
2012-07-27 21:10:42 +00:00
|
|
|
|
Revert "Revert "Revert "Revert "Add support for semaphores to be inserted on GrContext flush""""
This reverts commit cc8eb60c486eaf397685c60b28998682025fee1a.
Reason for revert: Chrome change landed that should fix chrome roll
Original change's description:
> Revert "Revert "Revert "Add support for semaphores to be inserted on GrContext flush"""
>
> This reverts commit 876aed8758b7109574999ffac43b1ea47f359bd7.
>
> Reason for revert: the bots seem to be unhappily red with this CL
>
> Original change's description:
> > Revert "Revert "Add support for semaphores to be inserted on GrContext flush""
> >
> > This reverts commit 8724b4609996eb6369b454611e31b065f3d8d2cf.
> >
> > Reason for revert: Creating a test CL to see what happens on the bots
> >
> > Original change's description:
> > > Revert "Add support for semaphores to be inserted on GrContext flush"
> > >
> > > This reverts commit cd1416efbc7af6f115dbaa09dce48e075d1d96ca.
> > >
> > > Reason for revert: speculative, to try to fix roll see gpu_tests.pixel_integration_test.PixelIntegrationTest.Pixel_GpuRasterization_ConcavePaths
> > >
> > > Original change's description:
> > > > Add support for semaphores to be inserted on GrContext flush
> > > >
> > > > This also moves the logic of inserting semaphores down into GrDrawingManager
> > > > and finishFlush on GrGpu. With it being on finishFlush, there should be no
> > > > issues when the DrawingManager starts respecting the proxy passed in assuming
> > > > it always calls finishFlush at the end (which it should).
> > > >
> > > > Bug: skia:
> > > > Change-Id: I925c2a289dcbbb9159b9120878af1d34f21a2dc7
> > > > Reviewed-on: https://skia-review.googlesource.com/25641
> > > > 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: I9c5b9cf8c060193e1861dbb8f0c10fb11dfb5249
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:
> > > Reviewed-on: https://skia-review.googlesource.com/25980
> > > Reviewed-by: Mike Reed <reed@google.com>
> > > Commit-Queue: Mike Reed <reed@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reed@google.com
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: skia:
> > Change-Id: I5edbeaa0769670ee58f362f0ccaa78319410aa6c
> > Reviewed-on: https://skia-review.googlesource.com/26160
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reed@google.com
>
> Change-Id: I22fd6febafe70489a5fdb695c6f4263368eb423d
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:
> Reviewed-on: https://skia-review.googlesource.com/29422
> Reviewed-by: Yuqian Li <liyuqian@google.com>
> Commit-Queue: Yuqian Li <liyuqian@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,liyuqian@google.com,reed@google.com
Change-Id: Ie3eae818b02599a70f714ef6b6635ce7d171bde6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/30000
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-08-02 15:10:09 +00:00
|
|
|
#include "GrTypes.h"
|
|
|
|
|
2012-07-27 21:10:42 +00:00
|
|
|
class SkCanvas;
|
2017-08-30 16:06:35 +00:00
|
|
|
class SkDeferredDisplayList;
|
2012-07-27 21:10:42 +00:00
|
|
|
class SkPaint;
|
2017-08-30 16:06:35 +00:00
|
|
|
class SkSurfaceCharacterization;
|
2017-04-18 19:52:36 +00:00
|
|
|
class GrBackendRenderTarget;
|
2017-06-16 13:45:32 +00:00
|
|
|
class GrBackendSemaphore;
|
2018-04-05 13:30:38 +00:00
|
|
|
class GrBackendTexture;
|
2012-07-31 15:45:27 +00:00
|
|
|
class GrContext;
|
|
|
|
class GrRenderTarget;
|
2012-07-27 21:10:42 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** \class SkSurface
|
|
|
|
SkSurface is responsible for managing the pixels that a canvas draws into. The pixels can be
|
|
|
|
allocated either in CPU memory (a raster surface) or on the GPU (a GrRenderTarget surface).
|
|
|
|
SkSurface takes care of allocating a SkCanvas that will draw into the surface. Call
|
|
|
|
surface->getCanvas() to use that canvas (but don't delete it, it is owned by the surface).
|
|
|
|
SkSurface always has non-zero dimensions. If there is a request for a new surface, and either
|
|
|
|
of the requested dimensions are zero, then nullptr will be returned.
|
|
|
|
*/
|
2013-04-18 13:28:19 +00:00
|
|
|
class SK_API SkSurface : public SkRefCnt {
|
2012-07-27 21:10:42 +00:00
|
|
|
public:
|
2018-02-27 15:22:04 +00:00
|
|
|
|
|
|
|
/** Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into pixels.
|
|
|
|
|
|
|
|
SkSurface is returned if all parameters are valid.
|
|
|
|
Valid parameters include:
|
|
|
|
info dimensions are greater than zero;
|
|
|
|
info contains SkColorType and SkAlphaType supported by raster surface;
|
|
|
|
pixels is not nullptr;
|
|
|
|
rowBytes is large enough to contain info width pixels of SkColorType.
|
|
|
|
|
|
|
|
Pixel buffer size should be info height times computed rowBytes.
|
|
|
|
Pixels are not initialized.
|
|
|
|
To access pixels after drawing, call flush() or peekPixels().
|
|
|
|
|
|
|
|
@param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
|
|
|
|
of raster surface; width and height must be greater than zero
|
|
|
|
@param pixels pointer to destination pixels buffer
|
|
|
|
@param rowBytes interval from one SkSurface row to the next
|
|
|
|
@param surfaceProps LCD striping orientation and setting for device independent fonts;
|
|
|
|
may be nullptr
|
|
|
|
@return SkSurface if all parameters are valid; otherwise, nullptr
|
|
|
|
*/
|
2017-11-03 12:06:09 +00:00
|
|
|
static sk_sp<SkSurface> MakeRasterDirect(const SkImageInfo& imageInfo, void* pixels,
|
|
|
|
size_t rowBytes,
|
|
|
|
const SkSurfaceProps* surfaceProps = nullptr);
|
2012-07-27 21:10:42 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into pixels.
|
|
|
|
releaseProc is called with pixels and context when SkSurface is deleted.
|
|
|
|
|
|
|
|
SkSurface is returned if all parameters are valid.
|
|
|
|
Valid parameters include:
|
|
|
|
info dimensions are greater than zero;
|
|
|
|
info contains SkColorType and SkAlphaType supported by raster surface;
|
|
|
|
pixels is not nullptr;
|
|
|
|
rowBytes is large enough to contain info width pixels of SkColorType.
|
|
|
|
|
|
|
|
Pixel buffer size should be info height times computed rowBytes.
|
|
|
|
Pixels are not initialized.
|
|
|
|
To access pixels after drawing, call flush() or peekPixels().
|
|
|
|
|
|
|
|
@param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
|
|
|
|
of raster surface; width and height must be greater than zero
|
|
|
|
@param pixels pointer to destination pixels buffer
|
|
|
|
@param rowBytes interval from one SkSurface row to the next
|
|
|
|
@param releaseProc called when SkSurface is deleted; may be nullptr
|
|
|
|
@param context passed to releaseProc; may be nullptr
|
|
|
|
@param surfaceProps LCD striping orientation and setting for device independent fonts;
|
|
|
|
may be nullptr
|
|
|
|
@return SkSurface if all parameters are valid; otherwise, nullptr
|
|
|
|
*/
|
2017-11-03 12:06:09 +00:00
|
|
|
static sk_sp<SkSurface> MakeRasterDirectReleaseProc(const SkImageInfo& imageInfo, void* pixels,
|
|
|
|
size_t rowBytes,
|
|
|
|
void (*releaseProc)(void* pixels, void* context),
|
|
|
|
void* context, const SkSurfaceProps* surfaceProps = nullptr);
|
2014-06-27 13:48:14 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into pixels.
|
|
|
|
Allocates and zeroes pixel memory. Pixel memory size is imageInfo.height() times
|
|
|
|
rowBytes, or times imageInfo.minRowBytes() if rowBytes is zero.
|
|
|
|
Pixel memory is deleted when SkSurface is deleted.
|
|
|
|
|
|
|
|
SkSurface is returned if all parameters are valid.
|
|
|
|
Valid parameters include:
|
|
|
|
info dimensions are greater than zero;
|
|
|
|
info contains SkColorType and SkAlphaType supported by raster surface;
|
|
|
|
rowBytes is large enough to contain info width pixels of SkColorType, or is zero.
|
|
|
|
|
|
|
|
If rowBytes is not zero, subsequent images returned by makeImageSnapshot()
|
|
|
|
have the same rowBytes.
|
|
|
|
|
|
|
|
@param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
|
|
|
|
of raster surface; width and height must be greater than zero
|
|
|
|
@param rowBytes interval from one SkSurface row to the next; may be zero
|
|
|
|
@param surfaceProps LCD striping orientation and setting for device independent fonts;
|
|
|
|
may be nullptr
|
|
|
|
@return SkSurface if all parameters are valid; otherwise, nullptr
|
|
|
|
*/
|
2017-11-03 12:06:09 +00:00
|
|
|
static sk_sp<SkSurface> MakeRaster(const SkImageInfo& imageInfo, size_t rowBytes,
|
|
|
|
const SkSurfaceProps* surfaceProps);
|
2016-01-30 18:01:06 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into pixels.
|
|
|
|
Allocates and zeroes pixel memory. Pixel memory size is imageInfo.height() times
|
|
|
|
imageInfo.minRowBytes().
|
|
|
|
Pixel memory is deleted when SkSurface is deleted.
|
|
|
|
|
|
|
|
SkSurface is returned if all parameters are valid.
|
|
|
|
Valid parameters include:
|
|
|
|
info dimensions are greater than zero;
|
|
|
|
info contains SkColorType and SkAlphaType supported by raster surface.
|
|
|
|
|
|
|
|
@param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
|
|
|
|
of raster surface; width and height must be greater than zero
|
|
|
|
@param props LCD striping orientation and setting for device independent fonts;
|
|
|
|
may be nullptr
|
|
|
|
@return SkSurface if all parameters are valid; otherwise, nullptr
|
|
|
|
*/
|
2017-11-03 12:06:09 +00:00
|
|
|
static sk_sp<SkSurface> MakeRaster(const SkImageInfo& imageInfo,
|
2016-07-06 13:22:06 +00:00
|
|
|
const SkSurfaceProps* props = nullptr) {
|
2017-11-03 12:06:09 +00:00
|
|
|
return MakeRaster(imageInfo, 0, props);
|
2016-07-06 13:22:06 +00:00
|
|
|
}
|
2012-07-27 21:10:42 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Allocates raster SkSurface. SkCanvas returned by SkSurface draws directly into pixels.
|
|
|
|
Allocates and zeroes pixel memory. Pixel memory size is height times width times
|
|
|
|
four. Pixel memory is deleted when SkSurface is deleted.
|
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
Internally, sets SkImageInfo to width, height, native color type, and
|
2018-02-27 15:22:04 +00:00
|
|
|
kPremul_SkAlphaType.
|
|
|
|
|
|
|
|
SkSurface is returned if width and height are greater than zero.
|
|
|
|
|
|
|
|
Use to create SkSurface that matches SkPMColor, the native pixel arrangement on
|
|
|
|
the platform. SkSurface drawn to output device skips converting its pixel format.
|
|
|
|
|
|
|
|
@param width pixel column count; must be greater than zero
|
|
|
|
@param height pixel row count; must be greater than zero
|
|
|
|
@param surfaceProps LCD striping orientation and setting for device independent
|
|
|
|
fonts; may be nullptr
|
|
|
|
@return SkSurface if all parameters are valid; otherwise, nullptr
|
|
|
|
*/
|
2016-03-24 01:59:25 +00:00
|
|
|
static sk_sp<SkSurface> MakeRasterN32Premul(int width, int height,
|
2017-11-03 12:06:09 +00:00
|
|
|
const SkSurfaceProps* surfaceProps = nullptr) {
|
|
|
|
return MakeRaster(SkImageInfo::MakeN32Premul(width, height), surfaceProps);
|
2014-12-10 15:24:28 +00:00
|
|
|
}
|
2013-09-17 20:03:43 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Wraps a GPU-backed texture into SkSurface. Caller must ensure the texture is
|
|
|
|
valid for the lifetime of returned SkSurface. If sampleCnt greater than zero,
|
|
|
|
creates an intermediate MSAA SkSurface which is used for drawing backendTexture.
|
|
|
|
|
|
|
|
SkSurface is returned if all parameters are valid. backendTexture is valid if
|
|
|
|
its pixel configuration agrees with colorSpace and context; for instance, if
|
|
|
|
backendTexture has an sRGB configuration, then context must support sRGB,
|
|
|
|
and colorSpace must be present. Further, backendTexture width and height must
|
|
|
|
not exceed context capabilities, and the context must be able to support
|
|
|
|
back-end textures.
|
|
|
|
|
|
|
|
If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr.
|
|
|
|
|
|
|
|
@param context GPU context
|
|
|
|
@param backendTexture texture residing on GPU
|
|
|
|
@param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin
|
|
|
|
@param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing
|
2018-04-03 15:49:10 +00:00
|
|
|
@param colorType one of:
|
|
|
|
kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType,
|
|
|
|
kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType,
|
|
|
|
kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType,
|
2018-02-27 15:22:04 +00:00
|
|
|
kGray_8_SkColorType, kRGBA_F16_SkColorType
|
2018-04-03 15:49:10 +00:00
|
|
|
@param colorSpace range of colors; may be nullptr
|
2018-02-27 15:22:04 +00:00
|
|
|
@param surfaceProps LCD striping orientation and setting for device independent
|
|
|
|
fonts; may be nullptr
|
|
|
|
@return SkSurface if all parameters are valid; otherwise, nullptr
|
|
|
|
*/
|
2017-12-19 18:15:02 +00:00
|
|
|
static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* context,
|
|
|
|
const GrBackendTexture& backendTexture,
|
|
|
|
GrSurfaceOrigin origin, int sampleCnt,
|
|
|
|
SkColorType colorType,
|
|
|
|
sk_sp<SkColorSpace> colorSpace,
|
|
|
|
const SkSurfaceProps* surfaceProps);
|
|
|
|
|
2018-04-03 15:49:10 +00:00
|
|
|
/** Wraps a GPU-backed buffer into SkSurface. Caller must ensure backendRenderTarget
|
|
|
|
is valid for the lifetime of returned SkSurface.
|
2018-02-27 15:22:04 +00:00
|
|
|
|
|
|
|
SkSurface is returned if all parameters are valid. backendRenderTarget is valid if
|
|
|
|
its pixel configuration agrees with colorSpace and context; for instance, if
|
|
|
|
backendRenderTarget has an sRGB configuration, then context must support sRGB,
|
|
|
|
and colorSpace must be present. Further, backendRenderTarget width and height must
|
|
|
|
not exceed context capabilities, and the context must be able to support
|
|
|
|
back-end render targets.
|
|
|
|
|
|
|
|
If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr.
|
|
|
|
|
|
|
|
@param context GPU context
|
|
|
|
@param backendRenderTarget GPU intermediate memory buffer
|
|
|
|
@param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin
|
2018-04-03 15:49:10 +00:00
|
|
|
@param colorType one of:
|
|
|
|
kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType,
|
|
|
|
kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType,
|
|
|
|
kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType,
|
2018-02-27 15:22:04 +00:00
|
|
|
kGray_8_SkColorType, kRGBA_F16_SkColorType
|
|
|
|
@param colorSpace range of colors
|
|
|
|
@param surfaceProps LCD striping orientation and setting for device independent
|
|
|
|
fonts; may be nullptr
|
|
|
|
@return SkSurface if all parameters are valid; otherwise, nullptr
|
|
|
|
*/
|
2017-11-03 12:06:09 +00:00
|
|
|
static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext* context,
|
|
|
|
const GrBackendRenderTarget& backendRenderTarget,
|
|
|
|
GrSurfaceOrigin origin,
|
2017-12-19 18:15:02 +00:00
|
|
|
SkColorType colorType,
|
2017-11-03 12:06:09 +00:00
|
|
|
sk_sp<SkColorSpace> colorSpace,
|
|
|
|
const SkSurfaceProps* surfaceProps);
|
2017-04-18 19:52:36 +00:00
|
|
|
|
2018-04-03 15:49:10 +00:00
|
|
|
/** Wraps a GPU-backed texture into SkSurface. Caller must ensure backendTexture is
|
|
|
|
valid for the lifetime of returned SkSurface. If sampleCnt greater than zero,
|
|
|
|
creates an intermediate MSAA SkSurface which is used for drawing backendTexture.
|
|
|
|
|
|
|
|
SkSurface is returned if all parameters are valid. backendTexture is valid if
|
|
|
|
its pixel configuration agrees with colorSpace and context; for instance, if
|
|
|
|
backendTexture has an sRGB configuration, then context must support sRGB,
|
|
|
|
and colorSpace must be present. Further, backendTexture width and height must
|
|
|
|
not exceed context capabilities.
|
|
|
|
|
|
|
|
Returned SkSurface is available only for drawing into, and cannot generate an
|
|
|
|
SkImage.
|
2018-02-27 15:22:04 +00:00
|
|
|
|
|
|
|
If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr.
|
|
|
|
|
|
|
|
@param context GPU context
|
|
|
|
@param backendTexture texture residing on GPU
|
|
|
|
@param origin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin
|
|
|
|
@param sampleCnt samples per pixel, or 0 to disable full scene anti-aliasing
|
2018-04-03 15:49:10 +00:00
|
|
|
@param colorType one of:
|
|
|
|
kUnknown_SkColorType, kAlpha_8_SkColorType, kRGB_565_SkColorType,
|
|
|
|
kARGB_4444_SkColorType, kRGBA_8888_SkColorType, kRGB_888x_SkColorType,
|
|
|
|
kBGRA_8888_SkColorType, kRGBA_1010102_SkColorType, kRGB_101010x_SkColorType,
|
2018-02-27 15:22:04 +00:00
|
|
|
kGray_8_SkColorType, kRGBA_F16_SkColorType
|
2018-04-03 15:49:10 +00:00
|
|
|
@param colorSpace range of colors; may be nullptr
|
2018-02-27 15:22:04 +00:00
|
|
|
@param surfaceProps LCD striping orientation and setting for device independent
|
|
|
|
fonts; may be nullptr
|
|
|
|
@return SkSurface if all parameters are valid; otherwise, nullptr
|
|
|
|
*/
|
2017-12-19 18:15:02 +00:00
|
|
|
static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(GrContext* context,
|
|
|
|
const GrBackendTexture& backendTexture,
|
|
|
|
GrSurfaceOrigin origin,
|
|
|
|
int sampleCnt,
|
2017-12-20 19:53:21 +00:00
|
|
|
SkColorType colorType,
|
2017-12-19 18:15:02 +00:00
|
|
|
sk_sp<SkColorSpace> colorSpace,
|
|
|
|
const SkSurfaceProps* surfaceProps);
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Returns SkSurface on GPU indicated by context. Allocates memory for
|
|
|
|
pixels, based on the width, height, and SkColorType in ImageInfo. budgeted
|
|
|
|
selects whether allocation for pixels is tracked by context. imageInfo
|
|
|
|
describes the pixel format in SkColorType, and transparency in
|
|
|
|
SkAlphaType, and color matching in SkColorSpace.
|
|
|
|
|
|
|
|
sampleCount requests the number of samples per pixel.
|
2018-06-14 17:21:08 +00:00
|
|
|
Pass zero to disable multi-sample anti-aliasing. The request is rounded
|
2018-02-27 15:22:04 +00:00
|
|
|
up to the next supported count, or rounded down if it is larger than the
|
|
|
|
maximum supported count.
|
|
|
|
|
|
|
|
surfaceOrigin pins either the top-left or the bottom-left corner to the origin.
|
|
|
|
|
2018-06-14 17:21:08 +00:00
|
|
|
shouldCreateWithMips hints that SkImage returned by makeImageSnapshot() is mip map.
|
2018-02-27 15:22:04 +00:00
|
|
|
|
|
|
|
If SK_SUPPORT_GPU is defined as zero, has no effect and returns nullptr.
|
|
|
|
|
|
|
|
@param context GPU context
|
|
|
|
@param budgeted one of: SkBudgeted::kNo, SkBudgeted::kYes
|
|
|
|
@param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace;
|
|
|
|
width, or height, or both, may be zero
|
|
|
|
@param sampleCount samples per pixel, or 0 to disable full scene anti-aliasing
|
|
|
|
@param surfaceOrigin one of: kBottomLeft_GrSurfaceOrigin, kTopLeft_GrSurfaceOrigin
|
|
|
|
@param surfaceProps LCD striping orientation and setting for device independent
|
|
|
|
fonts; may be nullptr
|
2018-06-14 17:21:08 +00:00
|
|
|
@param shouldCreateWithMips hint that SkSurface will host mip map images
|
2018-02-27 15:22:04 +00:00
|
|
|
@return SkSurface if all parameters are valid; otherwise, nullptr
|
|
|
|
*/
|
2017-11-03 12:06:09 +00:00
|
|
|
static sk_sp<SkSurface> MakeRenderTarget(GrContext* context, SkBudgeted budgeted,
|
|
|
|
const SkImageInfo& imageInfo,
|
|
|
|
int sampleCount, GrSurfaceOrigin surfaceOrigin,
|
|
|
|
const SkSurfaceProps* surfaceProps,
|
2017-10-23 20:05:23 +00:00
|
|
|
bool shouldCreateWithMips = false);
|
2016-07-26 18:38:17 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Returns SkSurface on GPU indicated by context. Allocates memory for
|
|
|
|
pixels, based on the width, height, and SkColorType in ImageInfo. budgeted
|
|
|
|
selects whether allocation for pixels is tracked by context. imageInfo
|
|
|
|
describes the pixel format in SkColorType, and transparency in
|
|
|
|
SkAlphaType, and color matching in SkColorSpace.
|
|
|
|
|
|
|
|
sampleCount requests the number of samples per pixel.
|
2018-06-14 17:21:08 +00:00
|
|
|
Pass zero to disable multi-sample anti-aliasing. The request is rounded
|
2018-02-27 15:22:04 +00:00
|
|
|
up to the next supported count, or rounded down if it is larger than the
|
|
|
|
maximum supported count.
|
|
|
|
|
|
|
|
SkSurface bottom-left corner is pinned to the origin.
|
|
|
|
|
|
|
|
@param context GPU context
|
|
|
|
@param budgeted one of: SkBudgeted::kNo, SkBudgeted::kYes
|
|
|
|
@param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
|
|
|
|
of raster surface; width, or height, or both, may be zero
|
2018-06-14 17:21:08 +00:00
|
|
|
@param sampleCount samples per pixel, or 0 to disable multi-sample anti-aliasing
|
2018-02-27 15:22:04 +00:00
|
|
|
@param props LCD striping orientation and setting for device independent
|
|
|
|
fonts; may be nullptr
|
|
|
|
@return SkSurface if all parameters are valid; otherwise, nullptr
|
|
|
|
*/
|
2016-07-26 18:38:17 +00:00
|
|
|
static sk_sp<SkSurface> MakeRenderTarget(GrContext* context, SkBudgeted budgeted,
|
2017-11-03 12:06:09 +00:00
|
|
|
const SkImageInfo& imageInfo, int sampleCount,
|
2016-07-26 18:38:17 +00:00
|
|
|
const SkSurfaceProps* props) {
|
2017-11-03 12:06:09 +00:00
|
|
|
return MakeRenderTarget(context, budgeted, imageInfo, sampleCount,
|
2016-07-26 18:38:17 +00:00
|
|
|
kBottomLeft_GrSurfaceOrigin, props);
|
|
|
|
}
|
2016-03-24 01:59:25 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Returns SkSurface on GPU indicated by context. Allocates memory for
|
|
|
|
pixels, based on the width, height, and SkColorType in ImageInfo. budgeted
|
|
|
|
selects whether allocation for pixels is tracked by context. imageInfo
|
|
|
|
describes the pixel format in SkColorType, and transparency in
|
|
|
|
SkAlphaType, and color matching in SkColorSpace.
|
|
|
|
|
|
|
|
SkSurface bottom-left corner is pinned to the origin.
|
|
|
|
|
|
|
|
@param context GPU context
|
|
|
|
@param budgeted one of: SkBudgeted::kNo, SkBudgeted::kYes
|
|
|
|
@param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
|
|
|
|
of raster surface; width, or height, or both, may be zero
|
|
|
|
@return SkSurface if all parameters are valid; otherwise, nullptr
|
|
|
|
*/
|
2017-11-03 12:06:09 +00:00
|
|
|
static sk_sp<SkSurface> MakeRenderTarget(GrContext* context, SkBudgeted budgeted,
|
|
|
|
const SkImageInfo& imageInfo) {
|
|
|
|
if (!imageInfo.width() || !imageInfo.height()) {
|
2016-11-07 13:23:48 +00:00
|
|
|
return nullptr;
|
|
|
|
}
|
2017-11-03 12:06:09 +00:00
|
|
|
return MakeRenderTarget(context, budgeted, imageInfo, 0, kBottomLeft_GrSurfaceOrigin,
|
|
|
|
nullptr);
|
2016-03-24 01:59:25 +00:00
|
|
|
}
|
2014-09-22 14:29:03 +00:00
|
|
|
|
2018-03-30 17:57:00 +00:00
|
|
|
/** Returns SkSurface on GPU indicated by context that is compatible with the provided
|
|
|
|
characterization. budgeted selects whether allocation for pixels is tracked by context.
|
|
|
|
|
|
|
|
@param context GPU context
|
|
|
|
@param characterization description of the desired SkSurface
|
|
|
|
@param budgeted one of: SkBudgeted::kNo, SkBudgeted::kYes
|
|
|
|
@return SkSurface if all parameters are valid; otherwise, nullptr
|
|
|
|
*/
|
|
|
|
static sk_sp<SkSurface> MakeRenderTarget(GrContext* context,
|
|
|
|
const SkSurfaceCharacterization& characterization,
|
|
|
|
SkBudgeted budgeted);
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Returns SkSurface without backing pixels. Drawing to SkCanvas returned from SkSurface
|
|
|
|
has no effect. Calling makeImageSnapshot() on returned SkSurface returns nullptr.
|
|
|
|
|
|
|
|
@param width one or greater
|
|
|
|
@param height one or greater
|
|
|
|
@return SkSurface if width and height are positive; otherwise, nullptr
|
|
|
|
*/
|
2017-06-28 23:57:21 +00:00
|
|
|
static sk_sp<SkSurface> MakeNull(int width, int height);
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Returns pixel count in each row; may be zero or greater.
|
|
|
|
|
|
|
|
@return number of pixel columns
|
|
|
|
*/
|
2012-07-27 21:10:42 +00:00
|
|
|
int width() const { return fWidth; }
|
2018-02-27 15:22:04 +00:00
|
|
|
|
|
|
|
/** Returns pixel row count; may be zero or greater.
|
|
|
|
|
|
|
|
@return number of pixel rows
|
|
|
|
*/
|
2012-07-27 21:10:42 +00:00
|
|
|
int height() const { return fHeight; }
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Returns unique value identifying the content of SkSurface. Returned value changes
|
|
|
|
each time the content changes. Content is changed by drawing, or by calling
|
|
|
|
notifyContentWillChange().
|
|
|
|
|
|
|
|
@return unique content identifier
|
|
|
|
*/
|
2012-08-28 12:19:02 +00:00
|
|
|
uint32_t generationID();
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** \enum SkSurface::ContentChangeMode
|
|
|
|
ContentChangeMode members are parameters to notifyContentWillChange().
|
|
|
|
*/
|
2013-04-22 14:28:01 +00:00
|
|
|
enum ContentChangeMode {
|
2018-05-30 13:20:29 +00:00
|
|
|
kDiscard_ContentChangeMode, //!< discards surface on change
|
|
|
|
kRetain_ContentChangeMode, //!< preserves surface on change
|
2013-04-22 14:28:01 +00:00
|
|
|
};
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Notifies that SkSurface contents will be changed by code outside of Skia.
|
|
|
|
Subsequent calls to generationID() return a different value.
|
|
|
|
|
|
|
|
mode is normally passed as kRetain_ContentChangeMode.
|
2018-05-30 13:20:29 +00:00
|
|
|
Can we deprecate this?
|
2018-02-27 15:22:04 +00:00
|
|
|
|
|
|
|
@param mode one of: kDiscard_ContentChangeMode, kRetain_ContentChangeMode
|
|
|
|
*/
|
2013-04-22 14:28:01 +00:00
|
|
|
void notifyContentWillChange(ContentChangeMode mode);
|
2012-08-23 18:09:54 +00:00
|
|
|
|
2015-07-08 19:54:04 +00:00
|
|
|
enum BackendHandleAccess {
|
2018-05-30 13:20:29 +00:00
|
|
|
kFlushRead_BackendHandleAccess, //!< back-end object is readable
|
|
|
|
kFlushWrite_BackendHandleAccess, //!< back-end object is writable
|
|
|
|
kDiscardWrite_BackendHandleAccess, //!< back-end object must be overwritten
|
2015-06-29 14:37:01 +00:00
|
|
|
};
|
2015-07-08 19:54:04 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Deprecated.
|
|
|
|
*/
|
2015-07-08 19:54:04 +00:00
|
|
|
static const BackendHandleAccess kFlushRead_TextureHandleAccess =
|
|
|
|
kFlushRead_BackendHandleAccess;
|
2018-02-27 15:22:04 +00:00
|
|
|
|
|
|
|
/** Deprecated.
|
|
|
|
*/
|
2015-07-08 19:54:04 +00:00
|
|
|
static const BackendHandleAccess kFlushWrite_TextureHandleAccess =
|
|
|
|
kFlushWrite_BackendHandleAccess;
|
2018-02-27 15:22:04 +00:00
|
|
|
|
|
|
|
/** Deprecated.
|
|
|
|
*/
|
2015-07-08 19:54:04 +00:00
|
|
|
static const BackendHandleAccess kDiscardWrite_TextureHandleAccess =
|
|
|
|
kDiscardWrite_BackendHandleAccess;
|
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
/** Retrieves the back-end texture. If SkSurface has no back-end texture, an invalid
|
2018-04-05 13:30:38 +00:00
|
|
|
object is returned. Call GrBackendTexture::isValid to determine if the result
|
|
|
|
is valid.
|
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
The returned GrBackendTexture should be discarded if the SkSurface is drawn to or deleted.
|
2018-04-05 13:30:38 +00:00
|
|
|
|
|
|
|
@param backendHandleAccess one of: kFlushRead_BackendHandleAccess,
|
2018-05-30 13:20:29 +00:00
|
|
|
kFlushWrite_BackendHandleAccess, kDiscardWrite_BackendHandleAccess
|
2018-04-05 13:30:38 +00:00
|
|
|
@return GPU texture reference; invalid on failure
|
|
|
|
*/
|
|
|
|
GrBackendTexture getBackendTexture(BackendHandleAccess backendHandleAccess);
|
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
/** Retrieves the back-end render target. If SkSurface has no back-end render target, an invalid
|
2018-04-05 13:30:38 +00:00
|
|
|
object is returned. Call GrBackendRenderTarget::isValid to determine if the result
|
|
|
|
is valid.
|
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
The returned GrBackendRenderTarget should be discarded if the SkSurface is drawn to
|
2018-04-05 13:30:38 +00:00
|
|
|
or deleted.
|
|
|
|
|
|
|
|
@param backendHandleAccess one of: kFlushRead_BackendHandleAccess,
|
2018-05-30 13:20:29 +00:00
|
|
|
kFlushWrite_BackendHandleAccess, kDiscardWrite_BackendHandleAccess
|
2018-04-05 13:30:38 +00:00
|
|
|
@return GPU render target reference; invalid on failure
|
|
|
|
*/
|
|
|
|
GrBackendRenderTarget getBackendRenderTarget(BackendHandleAccess backendHandleAccess);
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Returns SkCanvas that draws into SkSurface. Subsequent calls return the same SkCanvas.
|
|
|
|
SkCanvas returned is managed and owned by SkSurface, and is deleted when SkSurface
|
|
|
|
is deleted.
|
|
|
|
|
|
|
|
@return drawing SkCanvas for SkSurface
|
|
|
|
*/
|
2012-07-30 21:03:46 +00:00
|
|
|
SkCanvas* getCanvas();
|
2012-07-27 21:10:42 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Returns a compatible SkSurface, or nullptr. Returned SkSurface contains
|
|
|
|
the same raster, GPU, or null properties as the original. Returned SkSurface
|
|
|
|
does not share the same pixels.
|
|
|
|
|
|
|
|
Returns nullptr if imageInfo width or height are zero, or if imageInfo
|
|
|
|
is incompatible with SkSurface.
|
|
|
|
|
|
|
|
@param imageInfo width, height, SkColorType, SkAlphaType, SkColorSpace,
|
|
|
|
of SkSurface; width and height must be greater than zero
|
|
|
|
@return compatible SkSurface or nullptr
|
|
|
|
*/
|
2017-11-03 12:06:09 +00:00
|
|
|
sk_sp<SkSurface> makeSurface(const SkImageInfo& imageInfo);
|
2012-07-27 21:10:42 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Returns SkImage capturing SkSurface contents. Subsequent drawing to SkSurface contents
|
|
|
|
are not captured. SkImage allocation is accounted for if SkSurface was created with
|
|
|
|
SkBudgeted::kYes.
|
|
|
|
|
|
|
|
@return SkImage initialized with SkSurface contents
|
|
|
|
*/
|
2017-03-20 12:38:50 +00:00
|
|
|
sk_sp<SkImage> makeImageSnapshot();
|
2012-07-27 21:10:42 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Draws SkSurface contents to canvas, with its top-left corner at (x, y).
|
|
|
|
|
2018-05-30 13:20:29 +00:00
|
|
|
If SkPaint paint is not nullptr, apply SkColorFilter, alpha, SkImageFilter,
|
2018-02-27 15:22:04 +00:00
|
|
|
SkBlendMode, and SkDrawLooper.
|
|
|
|
|
|
|
|
@param canvas SkCanvas drawn into
|
|
|
|
@param x horizontal offset in SkCanvas
|
|
|
|
@param y vertical offset in SkCanvas
|
|
|
|
@param paint SkPaint containing SkBlendMode, SkColorFilter, SkImageFilter,
|
|
|
|
and so on; or nullptr
|
|
|
|
*/
|
2017-11-03 12:06:09 +00:00
|
|
|
void draw(SkCanvas* canvas, SkScalar x, SkScalar y, const SkPaint* paint);
|
2012-07-27 21:10:42 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Copies SkSurface pixel address, row bytes, and SkImageInfo to SkPixmap, if address
|
|
|
|
is available, and returns true. If pixel address is not available, return
|
|
|
|
false and leave SkPixmap unchanged.
|
|
|
|
|
|
|
|
pixmap contents become invalid on any future change to SkSurface.
|
|
|
|
|
|
|
|
@param pixmap storage for pixel state if pixels are readable; otherwise, ignored
|
|
|
|
@return true if SkSurface has direct access to pixels
|
|
|
|
*/
|
2017-11-03 12:06:09 +00:00
|
|
|
bool peekPixels(SkPixmap* pixmap);
|
2016-03-09 22:26:26 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Copies SkRect of pixels to dst.
|
|
|
|
|
|
|
|
Source SkRect corners are (srcX, srcY) and SkSurface (width(), height()).
|
|
|
|
Destination SkRect corners are (0, 0) and (dst.width(), dst.height()).
|
|
|
|
Copies each readable pixel intersecting both rectangles, without scaling,
|
|
|
|
converting to dst.colorType() and dst.alphaType() if required.
|
|
|
|
|
|
|
|
Pixels are readable when SkSurface is raster, or backed by a GPU.
|
|
|
|
|
|
|
|
The destination pixel storage must be allocated by the caller.
|
|
|
|
|
|
|
|
Pixel values are converted only if SkColorType and SkAlphaType
|
|
|
|
do not match. Only pixels within both source and destination rectangles
|
|
|
|
are copied. dst contents outside SkRect intersection are unchanged.
|
|
|
|
|
|
|
|
Pass negative values for srcX or srcY to offset pixels across or down destination.
|
|
|
|
|
|
|
|
Does not copy, and returns false if:
|
|
|
|
- Source and destination rectangles do not intersect.
|
|
|
|
- SkPixmap pixels could not be allocated.
|
|
|
|
- dst.rowBytes() is too small to contain one row of pixels.
|
|
|
|
|
|
|
|
@param dst storage for pixels copied from SkSurface
|
2018-06-14 17:21:08 +00:00
|
|
|
@param srcX offset into readable pixels on x-axis; may be negative
|
|
|
|
@param srcY offset into readable pixels on y-axis; may be negative
|
2018-02-27 15:22:04 +00:00
|
|
|
@return true if pixels were copied
|
|
|
|
*/
|
2017-07-21 15:01:18 +00:00
|
|
|
bool readPixels(const SkPixmap& dst, int srcX, int srcY);
|
2018-02-27 15:22:04 +00:00
|
|
|
|
|
|
|
/** Copies SkRect of pixels from SkCanvas into dstPixels.
|
|
|
|
|
|
|
|
Source SkRect corners are (srcX, srcY) and SkSurface (width(), height()).
|
|
|
|
Destination SkRect corners are (0, 0) and (dstInfo.width(), dstInfo.height()).
|
|
|
|
Copies each readable pixel intersecting both rectangles, without scaling,
|
|
|
|
converting to dstInfo.colorType() and dstInfo.alphaType() if required.
|
|
|
|
|
|
|
|
Pixels are readable when SkSurface is raster, or backed by a GPU.
|
|
|
|
|
|
|
|
The destination pixel storage must be allocated by the caller.
|
|
|
|
|
|
|
|
Pixel values are converted only if SkColorType and SkAlphaType
|
|
|
|
do not match. Only pixels within both source and destination rectangles
|
|
|
|
are copied. dstPixels contents outside SkRect intersection are unchanged.
|
|
|
|
|
|
|
|
Pass negative values for srcX or srcY to offset pixels across or down destination.
|
|
|
|
|
|
|
|
Does not copy, and returns false if:
|
|
|
|
- Source and destination rectangles do not intersect.
|
|
|
|
- SkSurface pixels could not be converted to dstInfo.colorType() or dstInfo.alphaType().
|
|
|
|
- dstRowBytes is too small to contain one row of pixels.
|
|
|
|
|
|
|
|
@param dstInfo width, height, SkColorType, and SkAlphaType of dstPixels
|
|
|
|
@param dstPixels storage for pixels; dstInfo.height() times dstRowBytes, or larger
|
|
|
|
@param dstRowBytes size of one destination row; dstInfo.width() times pixel size, or larger
|
2018-06-14 17:21:08 +00:00
|
|
|
@param srcX offset into readable pixels on x-axis; may be negative
|
|
|
|
@param srcY offset into readable pixels on y-axis; may be negative
|
2018-02-27 15:22:04 +00:00
|
|
|
@return true if pixels were copied
|
|
|
|
*/
|
2014-12-09 22:39:44 +00:00
|
|
|
bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
|
|
|
|
int srcX, int srcY);
|
2018-02-27 15:22:04 +00:00
|
|
|
|
|
|
|
/** Copies SkRect of pixels from SkSurface into bitmap.
|
|
|
|
|
|
|
|
Source SkRect corners are (srcX, srcY) and SkSurface (width(), height()).
|
|
|
|
Destination SkRect corners are (0, 0) and (bitmap.width(), bitmap.height()).
|
|
|
|
Copies each readable pixel intersecting both rectangles, without scaling,
|
|
|
|
converting to bitmap.colorType() and bitmap.alphaType() if required.
|
|
|
|
|
|
|
|
Pixels are readable when SkSurface is raster, or backed by a GPU.
|
|
|
|
|
|
|
|
The destination pixel storage must be allocated by the caller.
|
|
|
|
|
|
|
|
Pixel values are converted only if SkColorType and SkAlphaType
|
|
|
|
do not match. Only pixels within both source and destination rectangles
|
|
|
|
are copied. dst contents outside SkRect intersection are unchanged.
|
|
|
|
|
|
|
|
Pass negative values for srcX or srcY to offset pixels across or down destination.
|
|
|
|
|
|
|
|
Does not copy, and returns false if:
|
|
|
|
- Source and destination rectangles do not intersect.
|
|
|
|
- SkSurface pixels could not be converted to dst.colorType() or dst.alphaType().
|
|
|
|
- dst pixels could not be allocated.
|
|
|
|
- dst.rowBytes() is too small to contain one row of pixels.
|
|
|
|
|
|
|
|
@param dst storage for pixels copied from SkSurface
|
2018-06-14 17:21:08 +00:00
|
|
|
@param srcX offset into readable pixels on x-axis; may be negative
|
|
|
|
@param srcY offset into readable pixels on y-axis; may be negative
|
2018-02-27 15:22:04 +00:00
|
|
|
@return true if pixels were copied
|
|
|
|
*/
|
2017-07-21 15:01:18 +00:00
|
|
|
bool readPixels(const SkBitmap& dst, int srcX, int srcY);
|
2014-12-09 22:39:44 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Copies SkRect of pixels from the src SkPixmap to the SkSurface.
|
|
|
|
|
|
|
|
Source SkRect corners are (0, 0) and (src.width(), src.height()).
|
|
|
|
Destination SkRect corners are (dstX, dstY) and (dstX + Surface width(), dstY + Surface height()).
|
2018-07-13 12:21:59 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
Copies each readable pixel intersecting both rectangles, without scaling,
|
|
|
|
converting to SkSurface colorType() and SkSurface alphaType() if required.
|
|
|
|
|
|
|
|
@param src storage for pixels to copy to SkSurface
|
2018-06-14 17:21:08 +00:00
|
|
|
@param dstX x-axis position relative to SkSurface to begin copy; may be negative
|
|
|
|
@param dstY y-axis position relative to SkSurface to begin copy; may be negative
|
2018-02-27 15:22:04 +00:00
|
|
|
*/
|
2018-02-08 19:10:40 +00:00
|
|
|
void writePixels(const SkPixmap& src, int dstX, int dstY);
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Copies SkRect of pixels from the src SkBitmap to the SkSurface.
|
|
|
|
|
|
|
|
Source SkRect corners are (0, 0) and (src.width(), src.height()).
|
|
|
|
Destination SkRect corners are (dstX, dstY) and (dstX + Surface width(), dstY + Surface height()).
|
2018-07-13 12:21:59 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
Copies each readable pixel intersecting both rectangles, without scaling,
|
|
|
|
converting to SkSurface colorType() and SkSurface alphaType() if required.
|
|
|
|
|
|
|
|
@param src storage for pixels to copy to SkSurface
|
2018-06-14 17:21:08 +00:00
|
|
|
@param dstX x-axis position relative to SkSurface to begin copy; may be negative
|
|
|
|
@param dstY y-axis position relative to SkSurface to begin copy; may be negative
|
2018-02-27 15:22:04 +00:00
|
|
|
*/
|
2018-02-08 19:10:40 +00:00
|
|
|
void writePixels(const SkBitmap& src, int dstX, int dstY);
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Returns SkSurfaceProps for surface.
|
|
|
|
|
|
|
|
@return LCD striping orientation and setting for device independent fonts
|
|
|
|
*/
|
2014-09-22 14:29:03 +00:00
|
|
|
const SkSurfaceProps& props() const { return fProps; }
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** To be deprecated soon.
|
|
|
|
*/
|
Add wrapBackendTextureAsRenderTarget API
Skia's GrTextureProvider currently exposes two APIs for wrapping backend
objects:
* wrapBackendTexture - wraps a texture into a GrTexture. Depending on
flags, this GrTexture can be converted to a GrRenderTarget. Skia
manages the render target objects it may create to provide a render
target for the texture. This allows Skia to create stencil buffers
if needed and manager MSAA resolves.
* wrapBackendRenderTarget - wraps a FBO into a GrRenderTarget. This
object cannot be converted to a GrTexture. Skia does not manage
the render target objects for such a GrRenderTarget, and as such
cannot attach stencil buffers or perform MSAA resolves on the
created GrRenderTarget.
Given these two options, wrapBackendTexture provides more versatility
and allows Skia more room for optimization. Chrome currently uses
wrapBackendTexture for this reason.
While these two functions cover most cases, they do not provide a way
for Skia to wrap a texture into a render target (and gain the MSAA and
stencil buffer management), without also creating a GrTexture. This is
problematic in cases where a texture can be bound to a render target,
but cannot be textured from, as is the case in Chrome's limited support
for GL_TEXTURE_RECTANGLE.
To address this, a new function is created:
* wrapBackendTextureAsRenderTarget - wraps a texture into a
GrRenderTarget. As with wrapBackendTexture, the created render
target objects are fully managed by Skia. Unlike wrapBackendTexture
no GrTexture is created, and the created object will never be
textured from.
BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1709163003
Review URL: https://codereview.chromium.org/1709163003
2016-02-24 22:49:51 +00:00
|
|
|
void prepareForExternalIO();
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Issues pending SkSurface commands to the GPU-backed API and resolves any SkSurface MSAA.
|
|
|
|
|
|
|
|
Skia flushes as needed, so it is not necessary to call this if Skia manages
|
|
|
|
drawing and object lifetime. Call when interleaving Skia calls with native
|
|
|
|
GPU calls.
|
|
|
|
*/
|
2017-06-16 13:45:32 +00:00
|
|
|
void flush();
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Issues pending SkSurface commands to the GPU-backed API and resolves any SkSurface MSAA.
|
|
|
|
After issuing all commands, signalSemaphores of count numSemaphores semaphores
|
|
|
|
are signaled by the GPU.
|
|
|
|
|
|
|
|
For each GrBackendSemaphore in signalSemaphores:
|
|
|
|
if GrBackendSemaphore is initialized, the GPU back-end uses the semaphore as is;
|
|
|
|
otherwise, a new semaphore is created and initializes GrBackendSemaphore.
|
|
|
|
|
|
|
|
The caller must delete the semaphores created and returned in signalSemaphores.
|
|
|
|
GrBackendSemaphore can be deleted as soon as this function returns.
|
|
|
|
|
|
|
|
If the back-end API is OpenGL only uninitialized backend semaphores are supported.
|
|
|
|
|
|
|
|
If the back-end API is Vulkan semaphores may be initialized or uninitialized.
|
|
|
|
If uninitialized, created semaphores are valid only with the VkDevice
|
|
|
|
with which they were created.
|
|
|
|
|
|
|
|
If GrSemaphoresSubmitted::kNo is returned, the GPU back-end did not create or
|
|
|
|
add any semaphores to signal on the GPU; the caller should not instruct the GPU
|
|
|
|
to wait on any of the semaphores.
|
|
|
|
|
|
|
|
Pending surface commands are flushed regardless of the return result.
|
|
|
|
|
|
|
|
@param numSemaphores size of signalSemaphores array
|
|
|
|
@param signalSemaphores array of semaphore containers
|
|
|
|
@return one of: GrSemaphoresSubmitted::kYes, GrSemaphoresSubmitted::kNo
|
|
|
|
*/
|
Revert "Revert "Revert "Revert "Add support for semaphores to be inserted on GrContext flush""""
This reverts commit cc8eb60c486eaf397685c60b28998682025fee1a.
Reason for revert: Chrome change landed that should fix chrome roll
Original change's description:
> Revert "Revert "Revert "Add support for semaphores to be inserted on GrContext flush"""
>
> This reverts commit 876aed8758b7109574999ffac43b1ea47f359bd7.
>
> Reason for revert: the bots seem to be unhappily red with this CL
>
> Original change's description:
> > Revert "Revert "Add support for semaphores to be inserted on GrContext flush""
> >
> > This reverts commit 8724b4609996eb6369b454611e31b065f3d8d2cf.
> >
> > Reason for revert: Creating a test CL to see what happens on the bots
> >
> > Original change's description:
> > > Revert "Add support for semaphores to be inserted on GrContext flush"
> > >
> > > This reverts commit cd1416efbc7af6f115dbaa09dce48e075d1d96ca.
> > >
> > > Reason for revert: speculative, to try to fix roll see gpu_tests.pixel_integration_test.PixelIntegrationTest.Pixel_GpuRasterization_ConcavePaths
> > >
> > > Original change's description:
> > > > Add support for semaphores to be inserted on GrContext flush
> > > >
> > > > This also moves the logic of inserting semaphores down into GrDrawingManager
> > > > and finishFlush on GrGpu. With it being on finishFlush, there should be no
> > > > issues when the DrawingManager starts respecting the proxy passed in assuming
> > > > it always calls finishFlush at the end (which it should).
> > > >
> > > > Bug: skia:
> > > > Change-Id: I925c2a289dcbbb9159b9120878af1d34f21a2dc7
> > > > Reviewed-on: https://skia-review.googlesource.com/25641
> > > > 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: I9c5b9cf8c060193e1861dbb8f0c10fb11dfb5249
> > > No-Presubmit: true
> > > No-Tree-Checks: true
> > > No-Try: true
> > > Bug: skia:
> > > Reviewed-on: https://skia-review.googlesource.com/25980
> > > Reviewed-by: Mike Reed <reed@google.com>
> > > Commit-Queue: Mike Reed <reed@google.com>
> >
> > TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reed@google.com
> >
> > # Not skipping CQ checks because original CL landed > 1 day ago.
> >
> > Bug: skia:
> > Change-Id: I5edbeaa0769670ee58f362f0ccaa78319410aa6c
> > Reviewed-on: https://skia-review.googlesource.com/26160
> > Reviewed-by: Brian Salomon <bsalomon@google.com>
> > Commit-Queue: Greg Daniel <egdaniel@google.com>
>
> TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,reed@google.com
>
> Change-Id: I22fd6febafe70489a5fdb695c6f4263368eb423d
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: skia:
> Reviewed-on: https://skia-review.googlesource.com/29422
> Reviewed-by: Yuqian Li <liyuqian@google.com>
> Commit-Queue: Yuqian Li <liyuqian@google.com>
TBR=egdaniel@google.com,bsalomon@google.com,robertphillips@google.com,liyuqian@google.com,reed@google.com
Change-Id: Ie3eae818b02599a70f714ef6b6635ce7d171bde6
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: skia:
Reviewed-on: https://skia-review.googlesource.com/30000
Reviewed-by: Greg Daniel <egdaniel@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
2017-08-02 15:10:09 +00:00
|
|
|
GrSemaphoresSubmitted flushAndSignalSemaphores(int numSemaphores,
|
|
|
|
GrBackendSemaphore signalSemaphores[]);
|
2017-06-16 13:45:32 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Inserts a list of GPU semaphores that the current GPU-backed API must wait on before
|
|
|
|
executing any more commands on the GPU for this surface. Skia will take ownership of the
|
|
|
|
underlying semaphores and delete them once they have been signaled and waited on.
|
|
|
|
If this call returns false, then the GPU back-end will not wait on any passed in semaphores,
|
|
|
|
and the client will still own the semaphores.
|
|
|
|
|
|
|
|
@param numSemaphores size of waitSemaphores array
|
|
|
|
@param waitSemaphores array of semaphore containers
|
|
|
|
@return true if GPU is waiting on semaphores
|
|
|
|
*/
|
2017-06-15 20:59:49 +00:00
|
|
|
bool wait(int numSemaphores, const GrBackendSemaphore* waitSemaphores);
|
2017-06-16 13:45:32 +00:00
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Initializes SkSurfaceCharacterization that can be used to perform GPU back-end
|
|
|
|
processing in a separate thread. Typically this is used to divide drawing
|
|
|
|
into multiple tiles. DeferredDisplayListRecorder records the drawing commands
|
|
|
|
for each tile.
|
|
|
|
|
|
|
|
Return true if SkSurface supports characterization. raster surface returns false.
|
|
|
|
|
|
|
|
@param characterization properties for parallel drawing
|
|
|
|
@return true if supported
|
|
|
|
*/
|
2017-08-30 16:06:35 +00:00
|
|
|
bool characterize(SkSurfaceCharacterization* characterization) const;
|
|
|
|
|
2018-02-27 15:22:04 +00:00
|
|
|
/** Draws deferred display list created using SkDeferredDisplayListRecorder.
|
|
|
|
Has no effect and returns false if SkSurfaceCharacterization stored in
|
|
|
|
deferredDisplayList is not compatible with SkSurface.
|
|
|
|
|
|
|
|
raster surface returns false.
|
|
|
|
|
|
|
|
@param deferredDisplayList drawing commands
|
|
|
|
@return false if deferredDisplayList is not compatible
|
|
|
|
*/
|
2017-12-04 17:52:46 +00:00
|
|
|
bool draw(SkDeferredDisplayList* deferredDisplayList);
|
2017-08-30 16:06:35 +00:00
|
|
|
|
2012-07-27 21:10:42 +00:00
|
|
|
protected:
|
2017-11-03 12:06:09 +00:00
|
|
|
SkSurface(int width, int height, const SkSurfaceProps* surfaceProps);
|
|
|
|
SkSurface(const SkImageInfo& imageInfo, const SkSurfaceProps* surfaceProps);
|
2012-07-27 21:10:42 +00:00
|
|
|
|
2012-08-28 12:19:02 +00:00
|
|
|
// called by subclass if their contents have changed
|
|
|
|
void dirtyGenerationID() {
|
|
|
|
fGenerationID = 0;
|
|
|
|
}
|
|
|
|
|
2012-07-27 21:10:42 +00:00
|
|
|
private:
|
2014-09-22 14:29:03 +00:00
|
|
|
const SkSurfaceProps fProps;
|
|
|
|
const int fWidth;
|
|
|
|
const int fHeight;
|
|
|
|
uint32_t fGenerationID;
|
2012-08-30 14:38:00 +00:00
|
|
|
|
2012-08-28 12:48:35 +00:00
|
|
|
typedef SkRefCnt INHERITED;
|
2012-07-27 21:10:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|