Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Unified Diff: src/gpu/GrDrawTarget.cpp

Issue 1289673004: GrCopySurfaceBatch (Closed) Base URL: https://skia.googlesource.com/skia.git@cs
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrImmediateDrawTarget.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrDrawTarget.cpp
diff --git a/src/gpu/GrDrawTarget.cpp b/src/gpu/GrDrawTarget.cpp
index 3926739f19c185ea3d8dfecfe4749e98a31f9d8b..1102b18dc120f04f86948d6870ced3ff45c4dd98 100644
--- a/src/gpu/GrDrawTarget.cpp
+++ b/src/gpu/GrDrawTarget.cpp
@@ -21,6 +21,7 @@
#include "GrVertexBuffer.h"
#include "batches/GrClearBatch.h"
+#include "batches/GrCopySurfaceBatch.h"
#include "batches/GrDiscardBatch.h"
#include "batches/GrDrawBatch.h"
#include "batches/GrRectBatchFactory.h"
@@ -398,79 +399,15 @@ void GrDrawTarget::removeGpuTraceMarker(const GrGpuTraceMarker* marker) {
////////////////////////////////////////////////////////////////////////////////
-namespace {
-// returns true if the read/written rect intersects the src/dst and false if not.
-bool clip_srcrect_and_dstpoint(const GrSurface* dst,
- const GrSurface* src,
- const SkIRect& srcRect,
- const SkIPoint& dstPoint,
- SkIRect* clippedSrcRect,
- SkIPoint* clippedDstPoint) {
- *clippedSrcRect = srcRect;
- *clippedDstPoint = dstPoint;
-
- // clip the left edge to src and dst bounds, adjusting dstPoint if necessary
- if (clippedSrcRect->fLeft < 0) {
- clippedDstPoint->fX -= clippedSrcRect->fLeft;
- clippedSrcRect->fLeft = 0;
- }
- if (clippedDstPoint->fX < 0) {
- clippedSrcRect->fLeft -= clippedDstPoint->fX;
- clippedDstPoint->fX = 0;
- }
-
- // clip the top edge to src and dst bounds, adjusting dstPoint if necessary
- if (clippedSrcRect->fTop < 0) {
- clippedDstPoint->fY -= clippedSrcRect->fTop;
- clippedSrcRect->fTop = 0;
- }
- if (clippedDstPoint->fY < 0) {
- clippedSrcRect->fTop -= clippedDstPoint->fY;
- clippedDstPoint->fY = 0;
- }
-
- // clip the right edge to the src and dst bounds.
- if (clippedSrcRect->fRight > src->width()) {
- clippedSrcRect->fRight = src->width();
- }
- if (clippedDstPoint->fX + clippedSrcRect->width() > dst->width()) {
- clippedSrcRect->fRight = clippedSrcRect->fLeft + dst->width() - clippedDstPoint->fX;
- }
-
- // clip the bottom edge to the src and dst bounds.
- if (clippedSrcRect->fBottom > src->height()) {
- clippedSrcRect->fBottom = src->height();
- }
- if (clippedDstPoint->fY + clippedSrcRect->height() > dst->height()) {
- clippedSrcRect->fBottom = clippedSrcRect->fTop + dst->height() - clippedDstPoint->fY;
- }
-
- // The above clipping steps may have inverted the rect if it didn't intersect either the src or
- // dst bounds.
- return !clippedSrcRect->isEmpty();
-}
-}
-
void GrDrawTarget::copySurface(GrSurface* dst,
GrSurface* src,
const SkIRect& srcRect,
const SkIPoint& dstPoint) {
- SkASSERT(dst);
- SkASSERT(src);
-
- SkIRect clippedSrcRect;
- SkIPoint clippedDstPoint;
- // If the rect is outside the src or dst then we've already succeeded.
- if (!clip_srcrect_and_dstpoint(dst,
- src,
- srcRect,
- dstPoint,
- &clippedSrcRect,
- &clippedDstPoint)) {
- return;
+ GrBatch* batch = GrCopySurfaceBatch::Create(dst, src, srcRect, dstPoint);
+ if (batch) {
+ this->onDrawBatch(batch);
+ batch->unref();
}
-
- this->onCopySurface(dst, src, clippedSrcRect, clippedDstPoint);
}
///////////////////////////////////////////////////////////////////////////////
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrImmediateDrawTarget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698