06ee8e8a3e
This reverts commit31249bb2df
. Reason for revert: Android build is still broken as shown below. out/target/product/bullhead/obj/NATIVE_TESTS/hwui_unit_tests_intermediates/tests/unit/SkiaPipelineTests.o frameworks/base/libs/hwui/tests/unit/SkiaPipelineTests.cpp" frameworks/base/libs/hwui/tests/unit/SkiaPipelineTests.cpp:211:51: error: non-virtual member function marked 'override' hides virtual member function sk_sp<SkImage> onNewImageSnapshot(SkBudgeted) override { ^ external/skia/src/image/SkSurface_Base.h:46:28: note: hidden overloaded virtual function 'SkSurface_Base::onNewImageSnapshot' declared here: different number of parameters (0 vs 1) virtual sk_sp<SkImage> onNewImageSnapshot() = 0; ^ frameworks/base/libs/hwui/tests/unit/SkiaPipelineTests.cpp:281:84: error: no viable conversion from 'sk_sp<DeferLayer<DeferTestCanvas>>' to 'sk_sp<SkSurface>' pipeline->renderFrame(layerUpdateQueue, dirty, nodes, true, contentDrawBounds, surface); ^~~~~~~ external/skia/include/core/SkRefCnt.h:253:15: note: candidate constructor not viable: no known conversion from 'sk_sp<DeferLayer<DeferTestCanvas> >' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument constexpr sk_sp(std::nullptr_t) : fPtr(nullptr) {} ^ external/skia/include/core/SkRefCnt.h:259:5: note: candidate constructor not viable: no known conversion from 'sk_sp<DeferLayer<DeferTestCanvas> >' to 'const sk_sp<SkSurface> &' for 1st argument sk_sp(const sk_sp<T>& that) : fPtr(SkSafeRef(that.get())) {} ^ external/skia/include/core/SkRefCnt.h:268:5: note: candidate constructor not viable: no known conversion from 'sk_sp<DeferLayer<DeferTestCanvas> >' to 'sk_sp<SkSurface> &&' for 1st argument sk_sp(sk_sp<T>&& that) : fPtr(that.release()) {} ^ external/skia/include/gpu/../private/SkTLogic.h:27:82: note: candidate template ignored: disabled by 'enable_if' [with U = (anonymous namespace)::DeferLayer<DeferTestCanvas>] template <bool B, typename T = void> using enable_if_t = typename std::enable_if<B, T>::type; ^ external/skia/include/gpu/../private/SkTLogic.h:27:82: note: candidate template ignored: disabled by 'enable_if' [with U = (anonymous namespace)::DeferLayer<DeferTestCanvas>] external/skia/include/core/SkRefCnt.h:327:5: note: candidate function operator unspecified_bool_type() const { return this->get() ? &sk_sp::fPtr : nullptr; } ^ frameworks/base/libs/hwui/pipeline/skia/SkiaPipeline.h:50:30: note: passing argument to parameter 'surface' here sk_sp<SkSurface> surface); ^ frameworks/base/libs/hwui/tests/unit/SkiaPipelineTests.cpp:312:58: error: no viable conversion from 'sk_sp<DeferLayer<ClippedTestCanvas>>' to 'sk_sp<SkSurface>' SkRect::MakeWH(CANVAS_WIDTH, CANVAS_HEIGHT), surface); ^~~~~~~ external/skia/include/core/SkRefCnt.h:253:15: note: candidate constructor not viable: no known conversion from 'sk_sp<DeferLayer<ClippedTestCanvas> >' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument constexpr sk_sp(std::nullptr_t) : fPtr(nullptr) {} ^ external/skia/include/core/SkRefCnt.h:259:5: note: candidate constructor not viable: no known conversion from 'sk_sp<DeferLayer<ClippedTestCanvas> >' to 'const sk_sp<SkSurface> &' for 1st argument sk_sp(const sk_sp<T>& that) : fPtr(SkSafeRef(that.get())) {} ^ external/skia/include/core/SkRefCnt.h:268:5: note: candidate constructor not viable: no known conversion from 'sk_sp<DeferLayer<ClippedTestCanvas> >' to 'sk_sp<SkSurface> &&' for 1st argument sk_sp(sk_sp<T>&& that) : fPtr(that.release()) {} ^ external/skia/include/gpu/../private/SkTLogic.h:27:82: note: candidate template ignored: disabled by 'enable_if' [with U = (anonymous namespace)::DeferLayer<ClippedTestCanvas>] template <bool B, typename T = void> using enable_if_t = typename std::enable_if<B, T>::type; ^ external/skia/include/gpu/../private/SkTLogic.h:27:82: note: candidate template ignored: disabled by 'enable_if' [with U = (anonymous namespace)::DeferLayer<ClippedTestCanvas>] external/skia/include/core/SkRefCnt.h:327:5: note: candidate function operator unspecified_bool_type() const { return this->get() ? &sk_sp::fPtr : nullptr; } ^ frameworks/base/libs/hwui/pipeline/skia/SkiaPipeline.h:50:30: note: passing argument to parameter 'surface' here sk_sp<SkSurface> surface); ^ frameworks/base/libs/hwui/tests/unit/SkiaPipelineTests.cpp:343:58: error: no viable conversion from 'sk_sp<DeferLayer<ClipReplaceTestCanvas>>' to 'sk_sp<SkSurface>' SkRect::MakeWH(CANVAS_WIDTH, CANVAS_HEIGHT), surface); ^~~~~~~ external/skia/include/core/SkRefCnt.h:253:15: note: candidate constructor not viable: no known conversion from 'sk_sp<DeferLayer<ClipReplaceTestCanvas> >' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument constexpr sk_sp(std::nullptr_t) : fPtr(nullptr) {} ^ external/skia/include/core/SkRefCnt.h:259:5: note: candidate constructor not viable: no known conversion from 'sk_sp<DeferLayer<ClipReplaceTestCanvas> >' to 'const sk_sp<SkSurface> &' for 1st argument sk_sp(const sk_sp<T>& that) : fPtr(SkSafeRef(that.get())) {} ^ external/skia/include/core/SkRefCnt.h:268:5: note: candidate constructor not viable: no known conversion from 'sk_sp<DeferLayer<ClipReplaceTestCanvas> >' to 'sk_sp<SkSurface> &&' for 1st argument sk_sp(sk_sp<T>&& that) : fPtr(that.release()) {} ^ external/skia/include/gpu/../private/SkTLogic.h:27:82: note: candidate template ignored: disabled by 'enable_if' [with U = (anonymous namespace)::DeferLayer<ClipReplaceTestCanvas>] template <bool B, typename T = void> using enable_if_t = typename std::enable_if<B, T>::type; ^ external/skia/include/gpu/../private/SkTLogic.h:27:82: note: candidate template ignored: disabled by 'enable_if' [with U = (anonymous namespace)::DeferLayer<ClipReplaceTestCanvas>] external/skia/include/core/SkRefCnt.h:327:5: note: candidate function operator unspecified_bool_type() const { return this->get() ? &sk_sp::fPtr : nullptr; } ^ frameworks/base/libs/hwui/pipeline/skia/SkiaPipeline.h:50:30: note: passing argument to parameter 'surface' here sk_sp<SkSurface> surface); ^ frameworks/base/libs/hwui/tests/unit/SkiaPipelineTests.cpp:214:42: error: cannot initialize object parameter of type 'SkSurface' with an expression of type '(anonymous namespace)::DeferLayer<DeferTestCanvas>' T* canvas() { return static_cast<T*>(getCanvas()); } ^~~~~~~~~ frameworks/base/libs/hwui/tests/unit/SkiaPipelineTests.cpp:282:27: note: in instantiation of member function '(anonymous namespace)::DeferLayer<DeferTestCanvas>::canvas' requested here EXPECT_EQ(4, surface->canvas()->mDrawCounter); ^ frameworks/base/libs/hwui/tests/unit/SkiaPipelineTests.cpp:214:42: error: cannot initialize object parameter of type 'SkSurface' with an expression of type '(anonymous namespace)::DeferLayer<ClippedTestCanvas>' T* canvas() { return static_cast<T*>(getCanvas()); } ^~~~~~~~~ frameworks/base/libs/hwui/tests/unit/SkiaPipelineTests.cpp:313:27: note: in instantiation of member function '(anonymous namespace)::DeferLayer<ClippedTestCanvas>::canvas' requested here EXPECT_EQ(1, surface->canvas()->mDrawCounter); ^ frameworks/base/libs/hwui/tests/unit/SkiaPipelineTests.cpp:214:42: error: cannot initialize object parameter of type 'SkSurface' with an expression of type '(anonymous namespace)::DeferLayer<ClipReplaceTestCanvas>' T* canvas() { return static_cast<T*>(getCanvas()); } ^~~~~~~~~ frameworks/base/libs/hwui/tests/unit/SkiaPipelineTests.cpp:344:27: note: in instantiation of member function '(anonymous namespace)::DeferLayer<ClipReplaceTestCanvas>::canvas' requested here EXPECT_EQ(1, surface->canvas()->mDrawCounter); Original change's description: > Revert "Revert "Remove budgeted parameter from SkSurface::makeImageSnapshot"" > > This reverts commit9e9188f84b
. > > Reason for revert: Android-side fix has landed > > Original change's description: > > Revert "Remove budgeted parameter from SkSurface::makeImageSnapshot" > > > > This reverts commitb64bcbdc3a
. > > > > Reason for revert: > > > > Android build failed as shown below. > > > > frameworks/base/libs/hwui/VkLayer.cpp:32:41: error: too many arguments to function call, expected 0, have 1 > > mImage = surface->makeImageSnapshot(SkBudgeted::kNo); > > > > Original change's description: > > > Remove budgeted parameter from SkSurface::makeImageSnapshot > > > > > > This unused feature complicates MDB. > > > > > > Chrome compiles locally for me with this CL. > > > > > > Change-Id: I611e464885fb984030eace43ead42cf39d0e7f72 > > > Reviewed-on: https://skia-review.googlesource.com/9734 > > > Reviewed-by: Brian Salomon <bsalomon@google.com> > > > Commit-Queue: Robert Phillips <robertphillips@google.com> > > > > > > > TBR=bsalomon@google.com,robertphillips@google.com,reviews@skia.org > > NOPRESUBMIT=true > > NOTREECHECKS=true > > NOTRY=true > > > > Change-Id: Iae6e313c15b2352bd0d4fc7b5629de0a51ac398e > > Reviewed-on: https://skia-review.googlesource.com/9788 > > Reviewed-by: Yuqian Li <liyuqian@google.com> > > Commit-Queue: Yuqian Li <liyuqian@google.com> > > > > TBR=bsalomon@google.com,robertphillips@google.com,reviews@skia.org,liyuqian@google.com > # Not skipping CQ checks because original CL landed > 1 day ago. > > Change-Id: If07d1b5db6e6c618d37445a0cf127780ed243a92 > Reviewed-on: https://skia-review.googlesource.com/9843 > Reviewed-by: Robert Phillips <robertphillips@google.com> > Commit-Queue: Robert Phillips <robertphillips@google.com> > TBR=bsalomon@google.com,robertphillips@google.com,reviews@skia.org,liyuqian@google.com NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Change-Id: I674b0a9d4130e00164d2e0344a92c373cf70f4fd Reviewed-on: https://skia-review.googlesource.com/9873 Reviewed-by: Yuqian Li <liyuqian@google.com> Commit-Queue: Yuqian Li <liyuqian@google.com>
326 lines
14 KiB
C++
326 lines
14 KiB
C++
/*
|
|
* Copyright 2012 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#ifndef SkSurface_DEFINED
|
|
#define SkSurface_DEFINED
|
|
|
|
#include "SkRefCnt.h"
|
|
#include "SkImage.h"
|
|
#include "SkSurfaceProps.h"
|
|
|
|
class SkCanvas;
|
|
class SkPaint;
|
|
class GrContext;
|
|
class GrRenderTarget;
|
|
|
|
/**
|
|
* SkSurface represents the backend/results of drawing to a canvas. For raster
|
|
* drawing, the surface will be pixels, but (for example) when drawing into
|
|
* a PDF or Picture canvas, the surface stores the recorded commands.
|
|
*
|
|
* To draw into a canvas, first create the appropriate type of Surface, and
|
|
* then request the canvas from 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 NULL will be returned.
|
|
*/
|
|
class SK_API SkSurface : public SkRefCnt {
|
|
public:
|
|
/**
|
|
* Create a new surface, using the specified pixels/rowbytes as its
|
|
* backend.
|
|
*
|
|
* If the requested surface cannot be created, or the request is not a
|
|
* supported configuration, NULL will be returned.
|
|
*
|
|
* Callers are responsible for initialiazing the surface pixels.
|
|
*/
|
|
static sk_sp<SkSurface> MakeRasterDirect(const SkImageInfo&, void* pixels, size_t rowBytes,
|
|
const SkSurfaceProps* = nullptr);
|
|
|
|
/**
|
|
* The same as NewRasterDirect, but also accepts a call-back routine, which is invoked
|
|
* when the surface is deleted, and is passed the pixel memory and the specified context.
|
|
*/
|
|
static sk_sp<SkSurface> MakeRasterDirectReleaseProc(const SkImageInfo&, void* pixels, size_t rowBytes,
|
|
void (*releaseProc)(void* pixels, void* context),
|
|
void* context, const SkSurfaceProps* = nullptr);
|
|
|
|
/**
|
|
* Return a new surface, with the memory for the pixels automatically allocated and
|
|
* zero-initialized, but respecting the specified rowBytes. If rowBytes==0, then a default
|
|
* value will be chosen. If a non-zero rowBytes is specified, then any images snapped off of
|
|
* this surface (via makeImageSnapshot()) are guaranteed to have the same rowBytes.
|
|
*
|
|
* If the requested surface cannot be created, or the request is not a
|
|
* supported configuration, NULL will be returned.
|
|
*/
|
|
static sk_sp<SkSurface> MakeRaster(const SkImageInfo&, size_t rowBytes, const SkSurfaceProps*);
|
|
|
|
/**
|
|
* Allocate a new surface, automatically computing the rowBytes.
|
|
*/
|
|
static sk_sp<SkSurface> MakeRaster(const SkImageInfo& info,
|
|
const SkSurfaceProps* props = nullptr) {
|
|
return MakeRaster(info, 0, props);
|
|
}
|
|
|
|
/**
|
|
* Helper version of NewRaster. It creates a SkImageInfo with the
|
|
* specified width and height, and populates the rest of info to match
|
|
* pixels in SkPMColor format.
|
|
*/
|
|
static sk_sp<SkSurface> MakeRasterN32Premul(int width, int height,
|
|
const SkSurfaceProps* props = nullptr) {
|
|
return MakeRaster(SkImageInfo::MakeN32Premul(width, height), props);
|
|
}
|
|
|
|
/**
|
|
* Used to wrap a pre-existing backend 3D API texture as a SkSurface. The kRenderTarget flag
|
|
* must be set on GrBackendTextureDesc for this to succeed. Skia will not assume ownership
|
|
* of the texture and the client must ensure the texture is valid for the lifetime of the
|
|
* SkSurface.
|
|
*/
|
|
static sk_sp<SkSurface> MakeFromBackendTexture(GrContext*, const GrBackendTextureDesc&,
|
|
sk_sp<SkColorSpace>, const SkSurfaceProps*);
|
|
|
|
/**
|
|
* Used to wrap a pre-existing 3D API rendering target as a SkSurface. Skia will not assume
|
|
* ownership of the render target and the client must ensure the render target is valid for the
|
|
* lifetime of the SkSurface.
|
|
*/
|
|
static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext*,
|
|
const GrBackendRenderTargetDesc&,
|
|
sk_sp<SkColorSpace>,
|
|
const SkSurfaceProps*);
|
|
|
|
/**
|
|
* Used to wrap a pre-existing 3D API texture as a SkSurface. Skia will treat the texture as
|
|
* a rendering target only, but unlike NewFromBackendRenderTarget, Skia will manage and own
|
|
* the associated render target objects (but not the provided texture). The kRenderTarget flag
|
|
* must be set on GrBackendTextureDesc for this to succeed. Skia will not assume ownership
|
|
* of the texture and the client must ensure the texture is valid for the lifetime of the
|
|
* SkSurface.
|
|
*/
|
|
static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(
|
|
GrContext*, const GrBackendTextureDesc&, sk_sp<SkColorSpace>, const SkSurfaceProps*);
|
|
|
|
/**
|
|
* Legacy versions of the above factories, without color space support. These create "legacy"
|
|
* surfaces that operate without gamma correction or color management.
|
|
*/
|
|
static sk_sp<SkSurface> MakeFromBackendTexture(GrContext* ctx, const GrBackendTextureDesc& desc,
|
|
const SkSurfaceProps* props) {
|
|
return MakeFromBackendTexture(ctx, desc, nullptr, props);
|
|
}
|
|
|
|
static sk_sp<SkSurface> MakeFromBackendRenderTarget(GrContext* ctx,
|
|
const GrBackendRenderTargetDesc& desc,
|
|
const SkSurfaceProps* props) {
|
|
return MakeFromBackendRenderTarget(ctx, desc, nullptr, props);
|
|
}
|
|
|
|
static sk_sp<SkSurface> MakeFromBackendTextureAsRenderTarget(
|
|
GrContext* ctx, const GrBackendTextureDesc& desc, const SkSurfaceProps* props) {
|
|
return MakeFromBackendTextureAsRenderTarget(ctx, desc, nullptr, props);
|
|
}
|
|
|
|
|
|
/**
|
|
* Return a new surface whose contents will be drawn to an offscreen
|
|
* render target, allocated by the surface.
|
|
*/
|
|
static sk_sp<SkSurface> MakeRenderTarget(GrContext*, SkBudgeted, const SkImageInfo&,
|
|
int sampleCount, GrSurfaceOrigin,
|
|
const SkSurfaceProps*);
|
|
|
|
static sk_sp<SkSurface> MakeRenderTarget(GrContext* context, SkBudgeted budgeted,
|
|
const SkImageInfo& info, int sampleCount,
|
|
const SkSurfaceProps* props) {
|
|
return MakeRenderTarget(context, budgeted, info, sampleCount,
|
|
kBottomLeft_GrSurfaceOrigin, props);
|
|
}
|
|
|
|
static sk_sp<SkSurface> MakeRenderTarget(GrContext* gr, SkBudgeted b, const SkImageInfo& info) {
|
|
if (!info.width() || !info.height()) {
|
|
return nullptr;
|
|
}
|
|
return MakeRenderTarget(gr, b, info, 0, kBottomLeft_GrSurfaceOrigin, nullptr);
|
|
}
|
|
|
|
int width() const { return fWidth; }
|
|
int height() const { return fHeight; }
|
|
|
|
/**
|
|
* Returns a unique non-zero, unique value identifying the content of this
|
|
* surface. Each time the content is changed changed, either by drawing
|
|
* into this surface, or explicitly calling notifyContentChanged()) this
|
|
* method will return a new value.
|
|
*
|
|
* If this surface is empty (i.e. has a zero-dimention), this will return
|
|
* 0.
|
|
*/
|
|
uint32_t generationID();
|
|
|
|
/**
|
|
* Modes that can be passed to notifyContentWillChange
|
|
*/
|
|
enum ContentChangeMode {
|
|
/**
|
|
* Use this mode if it is known that the upcoming content changes will
|
|
* clear or overwrite prior contents, thus making them discardable.
|
|
*/
|
|
kDiscard_ContentChangeMode,
|
|
/**
|
|
* Use this mode if prior surface contents need to be preserved or
|
|
* if in doubt.
|
|
*/
|
|
kRetain_ContentChangeMode,
|
|
};
|
|
|
|
/**
|
|
* Call this if the contents are about to change. This will (lazily) force a new
|
|
* value to be returned from generationID() when it is called next.
|
|
*
|
|
* CAN WE DEPRECATE THIS?
|
|
*/
|
|
void notifyContentWillChange(ContentChangeMode mode);
|
|
|
|
enum BackendHandleAccess {
|
|
kFlushRead_BackendHandleAccess, //!< caller may read from the backend object
|
|
kFlushWrite_BackendHandleAccess, //!< caller may write to the backend object
|
|
kDiscardWrite_BackendHandleAccess, //!< caller must over-write the entire backend object
|
|
};
|
|
|
|
/*
|
|
* These are legacy aliases which will be removed soon
|
|
*/
|
|
static const BackendHandleAccess kFlushRead_TextureHandleAccess =
|
|
kFlushRead_BackendHandleAccess;
|
|
static const BackendHandleAccess kFlushWrite_TextureHandleAccess =
|
|
kFlushWrite_BackendHandleAccess;
|
|
static const BackendHandleAccess kDiscardWrite_TextureHandleAccess =
|
|
kDiscardWrite_BackendHandleAccess;
|
|
|
|
|
|
/**
|
|
* Retrieves the backend API handle of the texture used by this surface, or 0 if the surface
|
|
* is not backed by a GPU texture.
|
|
*
|
|
* The returned texture-handle is only valid until the next draw-call into the surface,
|
|
* or the surface is deleted.
|
|
*/
|
|
GrBackendObject getTextureHandle(BackendHandleAccess);
|
|
|
|
/**
|
|
* Retrieves the backend API handle of the RenderTarget backing this surface. Callers must
|
|
* ensure this function returns 'true' or else the GrBackendObject will be invalid
|
|
*
|
|
* In OpenGL this will return the FramebufferObject ID.
|
|
*/
|
|
bool getRenderTargetHandle(GrBackendObject*, BackendHandleAccess);
|
|
|
|
/**
|
|
* Return a canvas that will draw into this surface. This will always
|
|
* return the same canvas for a given surface, and is manged/owned by the
|
|
* surface. It should not be used when its parent surface has gone out of
|
|
* scope.
|
|
*/
|
|
SkCanvas* getCanvas();
|
|
|
|
/**
|
|
* Return a new surface that is "compatible" with this one, in that it will
|
|
* efficiently be able to be drawn into this surface. Typical calling
|
|
* pattern:
|
|
*
|
|
* SkSurface* A = SkSurface::New...();
|
|
* SkCanvas* canvasA = surfaceA->newCanvas();
|
|
* ...
|
|
* SkSurface* surfaceB = surfaceA->newSurface(...);
|
|
* SkCanvas* canvasB = surfaceB->newCanvas();
|
|
* ... // draw using canvasB
|
|
* canvasA->drawSurface(surfaceB); // <--- this will always be optimal!
|
|
*/
|
|
sk_sp<SkSurface> makeSurface(const SkImageInfo&);
|
|
|
|
/**
|
|
* Returns an image of the current state of the surface pixels up to this
|
|
* point. Subsequent changes to the surface (by drawing into its canvas)
|
|
* will not be reflected in this image. If a copy must be made the Budgeted
|
|
* parameter controls whether it counts against the resource budget
|
|
* (currently for the gpu backend only).
|
|
*/
|
|
sk_sp<SkImage> makeImageSnapshot(SkBudgeted = SkBudgeted::kYes);
|
|
|
|
/**
|
|
* Though the caller could get a snapshot image explicitly, and draw that,
|
|
* it seems that directly drawing a surface into another canvas might be
|
|
* a common pattern, and that we could possibly be more efficient, since
|
|
* we'd know that the "snapshot" need only live until we've handed it off
|
|
* to the canvas.
|
|
*/
|
|
void draw(SkCanvas*, SkScalar x, SkScalar y, const SkPaint*);
|
|
|
|
/**
|
|
* If the surface has direct access to its pixels (i.e. they are in local
|
|
* RAM) return true, and if not null, set the pixmap parameter to point to the information
|
|
* about the surface's pixels. The pixel address in the pixmap is only valid while
|
|
* the surface object is in scope, and no API call is made on the surface
|
|
* or its canvas.
|
|
*
|
|
* On failure, returns false and the pixmap parameter is ignored.
|
|
*/
|
|
bool peekPixels(SkPixmap*);
|
|
|
|
/**
|
|
* Copy the pixels from the surface into the specified buffer (pixels + rowBytes),
|
|
* converting them into the requested format (dstInfo). The surface pixels are read
|
|
* starting at the specified (srcX,srcY) location.
|
|
*
|
|
* The specified ImageInfo and (srcX,srcY) offset specifies a source rectangle
|
|
*
|
|
* srcR.setXYWH(srcX, srcY, dstInfo.width(), dstInfo.height());
|
|
*
|
|
* srcR is intersected with the bounds of the base-layer. If this intersection is not empty,
|
|
* then we have two sets of pixels (of equal size). Replace the dst pixels with the
|
|
* corresponding src pixels, performing any colortype/alphatype transformations needed
|
|
* (in the case where the src and dst have different colortypes or alphatypes).
|
|
*
|
|
* This call can fail, returning false, for several reasons:
|
|
* - If srcR does not intersect the surface bounds.
|
|
* - If the requested colortype/alphatype cannot be converted from the surface's types.
|
|
*/
|
|
bool readPixels(const SkImageInfo& dstInfo, void* dstPixels, size_t dstRowBytes,
|
|
int srcX, int srcY);
|
|
|
|
const SkSurfaceProps& props() const { return fProps; }
|
|
|
|
/**
|
|
* Issue any pending surface IO to the current backend 3D API and resolve any surface MSAA.
|
|
*/
|
|
void prepareForExternalIO();
|
|
|
|
protected:
|
|
SkSurface(int width, int height, const SkSurfaceProps*);
|
|
SkSurface(const SkImageInfo&, const SkSurfaceProps*);
|
|
|
|
// called by subclass if their contents have changed
|
|
void dirtyGenerationID() {
|
|
fGenerationID = 0;
|
|
}
|
|
|
|
private:
|
|
const SkSurfaceProps fProps;
|
|
const int fWidth;
|
|
const int fHeight;
|
|
uint32_t fGenerationID;
|
|
|
|
typedef SkRefCnt INHERITED;
|
|
};
|
|
|
|
#endif
|