Fix for copy surface not handling dirty context
BUG=521943
Review URL: https://codereview.chromium.org/1304263003
diff --git a/src/gpu/GrGpu.cpp b/src/gpu/GrGpu.cpp
index 8c58321..6a1c1dd 100644
--- a/src/gpu/GrGpu.cpp
+++ b/src/gpu/GrGpu.cpp
@@ -234,6 +234,15 @@
this->onClearStencilClip(renderTarget, rect, insideClip);
}
+bool GrGpu::copySurface(GrSurface* dst,
+ GrSurface* src,
+ const SkIRect& srcRect,
+ const SkIPoint& dstPoint) {
+ SkASSERT(dst && src);
+ this->handleDirtyContext();
+ return this->onCopySurface(dst, src, srcRect, dstPoint);
+}
+
bool GrGpu::getReadPixelsInfo(GrSurface* srcSurface, int width, int height, size_t rowBytes,
GrPixelConfig readConfig, DrawPreference* drawPreference,
ReadPixelTempDrawInfo* tempDrawInfo) {
diff --git a/src/gpu/GrGpu.h b/src/gpu/GrGpu.h
index 69a4ec9..783376d 100644
--- a/src/gpu/GrGpu.h
+++ b/src/gpu/GrGpu.h
@@ -294,10 +294,10 @@
// take place at the GrDrawTarget level and this function implement faster copy paths. The rect
// and point are pre-clipped. The src rect and implied dst rect are guaranteed to be within the
// src/dst bounds and non-empty.
- virtual bool copySurface(GrSurface* dst,
- GrSurface* src,
- const SkIRect& srcRect,
- const SkIPoint& dstPoint) = 0;
+ bool copySurface(GrSurface* dst,
+ GrSurface* src,
+ const SkIRect& srcRect,
+ const SkIPoint& dstPoint);
struct DrawArgs {
DrawArgs(const GrPrimitiveProcessor* primProc,
@@ -482,6 +482,12 @@
// overridden by backend-specific derived class to perform the resolve
virtual void onResolveRenderTarget(GrRenderTarget* target) = 0;
+ // overridden by backend specific derived class to perform the copy surface
+ virtual bool onCopySurface(GrSurface* dst,
+ GrSurface* src,
+ const SkIRect& srcRect,
+ const SkIPoint& dstPoint) = 0;
+
// width and height may be larger than rt (if underlying API allows it).
// Should attach the SB to the RT. Returns false if compatible sb could
// not be created.
diff --git a/src/gpu/GrTest.cpp b/src/gpu/GrTest.cpp
index 2b03238..a41fb06 100644
--- a/src/gpu/GrTest.cpp
+++ b/src/gpu/GrTest.cpp
@@ -197,10 +197,10 @@
void discard(GrRenderTarget*) override {}
- bool copySurface(GrSurface* dst,
- GrSurface* src,
- const SkIRect& srcRect,
- const SkIPoint& dstPoint) override { return false; };
+ bool onCopySurface(GrSurface* dst,
+ GrSurface* src,
+ const SkIRect& srcRect,
+ const SkIPoint& dstPoint) override { return false; };
bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const override {
return false;
diff --git a/src/gpu/gl/GrGLGpu.cpp b/src/gpu/gl/GrGLGpu.cpp
index e48ddf2..9cc699c 100644
--- a/src/gpu/gl/GrGLGpu.cpp
+++ b/src/gpu/gl/GrGLGpu.cpp
@@ -2766,10 +2766,10 @@
return true;
}
-bool GrGLGpu::copySurface(GrSurface* dst,
- GrSurface* src,
- const SkIRect& srcRect,
- const SkIPoint& dstPoint) {
+bool GrGLGpu::onCopySurface(GrSurface* dst,
+ GrSurface* src,
+ const SkIRect& srcRect,
+ const SkIPoint& dstPoint) {
if (src->asTexture() && dst->asRenderTarget()) {
this->copySurfaceAsDraw(dst, src, srcRect, dstPoint);
return true;
diff --git a/src/gpu/gl/GrGLGpu.h b/src/gpu/gl/GrGLGpu.h
index 5d806a7..defb81a 100644
--- a/src/gpu/gl/GrGLGpu.h
+++ b/src/gpu/gl/GrGLGpu.h
@@ -91,11 +91,6 @@
fHWGeometryState.notifyIndexBufferDelete(id);
}
- bool copySurface(GrSurface* dst,
- GrSurface* src,
- const SkIRect& srcRect,
- const SkIPoint& dstPoint) override;
-
void buildProgramDesc(GrProgramDesc*,
const GrPrimitiveProcessor&,
const GrPipeline&,
@@ -152,6 +147,11 @@
void onDraw(const DrawArgs&, const GrNonInstancedVertices&) override;
+ bool onCopySurface(GrSurface* dst,
+ GrSurface* src,
+ const SkIRect& srcRect,
+ const SkIPoint& dstPoint) override;
+
void clearStencil(GrRenderTarget*) override;
// GrDrawTarget overrides