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

Side by Side Diff: src/gpu/GrDrawContext.cpp

Issue 2267273006: GPU implementation of drawRegion() (Closed) Base URL: https://skia.googlesource.com/skia.git@drawregion
Patch Set: SkToBool Created 4 years, 3 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 unified diff | Download patch
« no previous file with comments | « include/gpu/GrDrawContext.h ('k') | src/gpu/SkGpuDevice.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2015 Google Inc. 2 * Copyright 2015 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "GrBatchTest.h" 8 #include "GrBatchTest.h"
9 #include "GrColor.h" 9 #include "GrColor.h"
10 #include "GrDrawContext.h" 10 #include "GrDrawContext.h"
11 #include "GrDrawContextPriv.h" 11 #include "GrDrawContextPriv.h"
12 #include "GrDrawingManager.h" 12 #include "GrDrawingManager.h"
13 #include "GrFixedClip.h" 13 #include "GrFixedClip.h"
14 #include "GrGpuResourcePriv.h" 14 #include "GrGpuResourcePriv.h"
15 #include "GrOvalRenderer.h" 15 #include "GrOvalRenderer.h"
16 #include "GrPathRenderer.h" 16 #include "GrPathRenderer.h"
17 #include "GrPipelineBuilder.h" 17 #include "GrPipelineBuilder.h"
18 #include "GrRenderTarget.h" 18 #include "GrRenderTarget.h"
19 #include "GrRenderTargetPriv.h" 19 #include "GrRenderTargetPriv.h"
20 #include "GrResourceProvider.h" 20 #include "GrResourceProvider.h"
21 #include "SkSurfacePriv.h" 21 #include "SkSurfacePriv.h"
22 22
23 #include "batches/GrBatch.h" 23 #include "batches/GrBatch.h"
24 #include "batches/GrClearBatch.h" 24 #include "batches/GrClearBatch.h"
25 #include "batches/GrDrawAtlasBatch.h" 25 #include "batches/GrDrawAtlasBatch.h"
26 #include "batches/GrDrawVerticesBatch.h" 26 #include "batches/GrDrawVerticesBatch.h"
27 #include "batches/GrRectBatchFactory.h" 27 #include "batches/GrRectBatchFactory.h"
28 #include "batches/GrNinePatch.h" // TODO Factory 28 #include "batches/GrNinePatch.h" // TODO Factory
29 #include "batches/GrRegionBatch.h"
29 30
30 #include "effects/GrRRectEffect.h" 31 #include "effects/GrRRectEffect.h"
31 32
32 #include "instanced/InstancedRendering.h" 33 #include "instanced/InstancedRendering.h"
33 34
34 #include "text/GrAtlasTextContext.h" 35 #include "text/GrAtlasTextContext.h"
35 #include "text/GrStencilAndCoverTextContext.h" 36 #include "text/GrStencilAndCoverTextContext.h"
36 37
37 #include "../private/GrAuditTrail.h" 38 #include "../private/GrAuditTrail.h"
38 39
(...skipping 898 matching lines...) Expand 10 before | Expand all | Expand 10 after
937 path.setIsVolatile(true); 938 path.setIsVolatile(true);
938 path.addRRect(inner); 939 path.addRRect(inner);
939 path.addRRect(outer); 940 path.addRRect(outer);
940 path.setFillType(SkPath::kEvenOdd_FillType); 941 path.setFillType(SkPath::kEvenOdd_FillType);
941 942
942 this->internalDrawPath(clip, paint, viewMatrix, path, GrStyle::SimpleFill()) ; 943 this->internalDrawPath(clip, paint, viewMatrix, path, GrStyle::SimpleFill()) ;
943 } 944 }
944 945
945 /////////////////////////////////////////////////////////////////////////////// 946 ///////////////////////////////////////////////////////////////////////////////
946 947
948 static inline bool is_int(float x) {
949 return x == (float) sk_float_round2int(x);
950 }
951
952 void GrDrawContext::drawRegion(const GrClip& clip,
953 const GrPaint& paint,
954 const SkMatrix& viewMatrix,
955 const SkRegion& region,
956 const GrStyle& style) {
957 ASSERT_SINGLE_OWNER
958 RETURN_IF_ABANDONED
959 SkDEBUGCODE(this->validate();)
960 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRegion");
961
962 bool isNonTranslate = SkToBool(viewMatrix.getType() & ~(SkMatrix::kTranslate _Mask));
963 bool complexStyle = !style.isSimpleFill();
964 bool antiAlias = paint.isAntiAlias() && (!is_int(viewMatrix.getTranslateX()) ||
965 !is_int(viewMatrix.getTranslateY()) );
966 if (isNonTranslate || complexStyle || antiAlias) {
967 SkPath path;
968 region.getBoundaryPath(&path);
969 return this->drawPath(clip, paint, viewMatrix, path, style);
970 }
971
972 SkAutoTUnref<GrDrawBatch> batch(GrRegionBatch::Create(paint.getColor(), view Matrix, region));
973 GrPipelineBuilder pipelineBuilder(paint, false);
974 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
975 }
976
947 void GrDrawContext::drawOval(const GrClip& clip, 977 void GrDrawContext::drawOval(const GrClip& clip,
948 const GrPaint& paint, 978 const GrPaint& paint,
949 const SkMatrix& viewMatrix, 979 const SkMatrix& viewMatrix,
950 const SkRect& oval, 980 const SkRect& oval,
951 const GrStyle& style) { 981 const GrStyle& style) {
952 ASSERT_SINGLE_OWNER 982 ASSERT_SINGLE_OWNER
953 RETURN_IF_ABANDONED 983 RETURN_IF_ABANDONED
954 SkDEBUGCODE(this->validate();) 984 SkDEBUGCODE(this->validate();)
955 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawOval"); 985 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawOval");
956 986
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 1375
1346 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr Clip& clip, 1376 void GrDrawContext::drawBatch(const GrPipelineBuilder& pipelineBuilder, const Gr Clip& clip,
1347 GrDrawBatch* batch) { 1377 GrDrawBatch* batch) {
1348 ASSERT_SINGLE_OWNER 1378 ASSERT_SINGLE_OWNER
1349 RETURN_IF_ABANDONED 1379 RETURN_IF_ABANDONED
1350 SkDEBUGCODE(this->validate();) 1380 SkDEBUGCODE(this->validate();)
1351 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch"); 1381 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch");
1352 1382
1353 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch); 1383 this->getDrawTarget()->drawBatch(pipelineBuilder, this, clip, batch);
1354 } 1384 }
OLDNEW
« no previous file with comments | « include/gpu/GrDrawContext.h ('k') | src/gpu/SkGpuDevice.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698