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

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

Issue 1413673002: Remove DrawingMgr shims from GrContext (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix names in comments Created 5 years, 2 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 | « src/gpu/GrContext.cpp ('k') | src/gpu/GrDrawingManager.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 /* 2 /*
3 * Copyright 2015 Google Inc. 3 * Copyright 2015 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrAtlasTextContext.h" 9 #include "GrAtlasTextContext.h"
10 #include "GrBatchTest.h" 10 #include "GrBatchTest.h"
11 #include "GrColor.h" 11 #include "GrColor.h"
12 #include "GrDrawContext.h" 12 #include "GrDrawContext.h"
13 #include "GrDrawingManager.h"
13 #include "GrOvalRenderer.h" 14 #include "GrOvalRenderer.h"
14 #include "GrPathRenderer.h" 15 #include "GrPathRenderer.h"
15 #include "GrRenderTarget.h" 16 #include "GrRenderTarget.h"
16 #include "GrRenderTargetPriv.h" 17 #include "GrRenderTargetPriv.h"
17 #include "GrResourceProvider.h" 18 #include "GrResourceProvider.h"
18 #include "GrStencilAndCoverTextContext.h" 19 #include "GrStencilAndCoverTextContext.h"
19 #include "SkSurfacePriv.h" 20 #include "SkSurfacePriv.h"
20 21
21 #include "batches/GrBatch.h" 22 #include "batches/GrBatch.h"
22 #include "batches/GrDrawAtlasBatch.h" 23 #include "batches/GrDrawAtlasBatch.h"
23 #include "batches/GrDrawVerticesBatch.h" 24 #include "batches/GrDrawVerticesBatch.h"
24 #include "batches/GrRectBatchFactory.h" 25 #include "batches/GrRectBatchFactory.h"
25 26
26 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fContext) 27 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM anager->getContext())
27 #define RETURN_IF_ABANDONED if (fContext->abandoned()) { return; } 28 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; }
28 #define RETURN_FALSE_IF_ABANDONED if (fContext->abandoned()) { return false; } 29 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fa lse; }
29 #define RETURN_NULL_IF_ABANDONED if (fContext->abandoned()) { return nullptr; } 30 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nu llptr; }
30 31
31 class AutoCheckFlush { 32 class AutoCheckFlush {
32 public: 33 public:
33 AutoCheckFlush(GrContext* context) : fContext(context) { SkASSERT(context); } 34 AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingMa nager) {
34 ~AutoCheckFlush() { fContext->flushIfNecessary(); } 35 SkASSERT(fDrawingManager);
36 }
37 ~AutoCheckFlush() { fDrawingManager->getContext()->flushIfNecessary(); }
35 38
36 private: 39 private:
37 GrContext* fContext; 40 GrDrawingManager* fDrawingManager;
38 }; 41 };
39 42
40 // In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-pr ogress 43 // In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-pr ogress
41 // drawTargets to be picked up and added to by drawContexts lower in the call 44 // drawTargets to be picked up and added to by drawContexts lower in the call
42 // stack. When this occurs with a closed drawTarget, a new one will be allocated 45 // stack. When this occurs with a closed drawTarget, a new one will be allocated
43 // when the drawContext attempts to use it (via getDrawTarget). 46 // when the drawContext attempts to use it (via getDrawTarget).
44 GrDrawContext::GrDrawContext(GrContext* context, 47 GrDrawContext::GrDrawContext(GrDrawingManager* drawingMgr,
45 GrRenderTarget* rt, 48 GrRenderTarget* rt,
46 const SkSurfaceProps* surfaceProps) 49 const SkSurfaceProps* surfaceProps)
47 : fContext(context) 50 : fDrawingManager(drawingMgr)
48 , fRenderTarget(rt) 51 , fRenderTarget(rt)
49 , fDrawTarget(SkSafeRef(rt->getLastDrawTarget())) 52 , fDrawTarget(SkSafeRef(rt->getLastDrawTarget()))
50 , fTextContext(nullptr) 53 , fTextContext(nullptr)
51 , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) { 54 , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) {
52 SkDEBUGCODE(this->validate();) 55 SkDEBUGCODE(this->validate();)
53 } 56 }
54 57
55 #ifdef SK_DEBUG 58 #ifdef SK_DEBUG
56 void GrDrawContext::validate() const { 59 void GrDrawContext::validate() const {
57 SkASSERT(fRenderTarget); 60 SkASSERT(fRenderTarget);
58 ASSERT_OWNED_RESOURCE(fRenderTarget); 61 ASSERT_OWNED_RESOURCE(fRenderTarget);
59 62
60 if (fDrawTarget && !fDrawTarget->isClosed()) { 63 if (fDrawTarget && !fDrawTarget->isClosed()) {
61 SkASSERT(fRenderTarget->getLastDrawTarget() == fDrawTarget); 64 SkASSERT(fRenderTarget->getLastDrawTarget() == fDrawTarget);
62 } 65 }
63 } 66 }
64 #endif 67 #endif
65 68
66 GrDrawContext::~GrDrawContext() { 69 GrDrawContext::~GrDrawContext() {
67 SkSafeUnref(fDrawTarget); 70 SkSafeUnref(fDrawTarget);
68 } 71 }
69 72
70 GrDrawTarget* GrDrawContext::getDrawTarget() { 73 GrDrawTarget* GrDrawContext::getDrawTarget() {
71 SkDEBUGCODE(this->validate();) 74 SkDEBUGCODE(this->validate();)
72 75
73 if (!fDrawTarget || fDrawTarget->isClosed()) { 76 if (!fDrawTarget || fDrawTarget->isClosed()) {
74 fDrawTarget = fContext->newDrawTarget(fRenderTarget); 77 fDrawTarget = fDrawingManager->newDrawTarget(fRenderTarget);
75 fRenderTarget->setLastDrawTarget(fDrawTarget); 78 fRenderTarget->setLastDrawTarget(fDrawTarget);
76 } 79 }
77 80
78 return fDrawTarget; 81 return fDrawTarget;
79 } 82 }
80 83
81 void GrDrawContext::copySurface(GrSurface* src, const SkIRect& srcRect, const Sk IPoint& dstPoint) { 84 void GrDrawContext::copySurface(GrSurface* src, const SkIRect& srcRect, const Sk IPoint& dstPoint) {
82 RETURN_IF_ABANDONED 85 RETURN_IF_ABANDONED
83 SkDEBUGCODE(this->validate();) 86 SkDEBUGCODE(this->validate();)
84 87
85 this->getDrawTarget()->copySurface(fRenderTarget, src, srcRect, dstPoint); 88 this->getDrawTarget()->copySurface(fRenderTarget, src, srcRect, dstPoint);
86 } 89 }
87 90
88 91
89 void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint, 92 void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint,
90 const SkPaint& skPaint, 93 const SkPaint& skPaint,
91 const SkMatrix& viewMatrix, 94 const SkMatrix& viewMatrix,
92 const char text[], size_t byteLength, 95 const char text[], size_t byteLength,
93 SkScalar x, SkScalar y, const SkIRect& clipBounds) { 96 SkScalar x, SkScalar y, const SkIRect& clipBounds) {
94 RETURN_IF_ABANDONED 97 RETURN_IF_ABANDONED
95 SkDEBUGCODE(this->validate();) 98 SkDEBUGCODE(this->validate();)
96 99
97 if (!fTextContext) { 100 if (!fTextContext) {
98 fTextContext = fContext->textContext(fSurfaceProps, fRenderTarget); 101 fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget );
99 } 102 }
100 103
101 fTextContext->drawText(this, fRenderTarget, clip, grPaint, skPaint, viewMatr ix, 104 fTextContext->drawText(this, fRenderTarget, clip, grPaint, skPaint, viewMatr ix,
102 text, byteLength, x, y, clipBounds); 105 text, byteLength, x, y, clipBounds);
103 106
104 } 107 }
105 void GrDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint, 108 void GrDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint,
106 const SkPaint& skPaint, 109 const SkPaint& skPaint,
107 const SkMatrix& viewMatrix, 110 const SkMatrix& viewMatrix,
108 const char text[], size_t byteLength, 111 const char text[], size_t byteLength,
109 const SkScalar pos[], int scalarsPerPosition, 112 const SkScalar pos[], int scalarsPerPosition,
110 const SkPoint& offset, const SkIRect& clipBounds ) { 113 const SkPoint& offset, const SkIRect& clipBounds ) {
111 RETURN_IF_ABANDONED 114 RETURN_IF_ABANDONED
112 SkDEBUGCODE(this->validate();) 115 SkDEBUGCODE(this->validate();)
113 116
114 if (!fTextContext) { 117 if (!fTextContext) {
115 fTextContext = fContext->textContext(fSurfaceProps, fRenderTarget); 118 fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget );
116 } 119 }
117 120
118 fTextContext->drawPosText(this, fRenderTarget, clip, grPaint, skPaint, viewM atrix, text, byteLength, 121 fTextContext->drawPosText(this, fRenderTarget, clip, grPaint, skPaint, viewM atrix, text, byteLength,
119 pos, scalarsPerPosition, offset, clipBounds); 122 pos, scalarsPerPosition, offset, clipBounds);
120 123
121 } 124 }
122 void GrDrawContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint, 125 void GrDrawContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint,
123 const SkMatrix& viewMatrix, const SkTextBlob* b lob, 126 const SkMatrix& viewMatrix, const SkTextBlob* b lob,
124 SkScalar x, SkScalar y, 127 SkScalar x, SkScalar y,
125 SkDrawFilter* filter, const SkIRect& clipBounds ) { 128 SkDrawFilter* filter, const SkIRect& clipBounds ) {
126 RETURN_IF_ABANDONED 129 RETURN_IF_ABANDONED
127 SkDEBUGCODE(this->validate();) 130 SkDEBUGCODE(this->validate();)
128 131
129 if (!fTextContext) { 132 if (!fTextContext) {
130 fTextContext = fContext->textContext(fSurfaceProps, fRenderTarget); 133 fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget );
131 } 134 }
132 135
133 fTextContext->drawTextBlob(this, fRenderTarget, 136 fTextContext->drawTextBlob(this, fRenderTarget,
134 clip, skPaint, viewMatrix, blob, x, y, filter, cl ipBounds); 137 clip, skPaint, viewMatrix, blob, x, y, filter, cl ipBounds);
135 } 138 }
136 139
137 void GrDrawContext::drawPathsFromRange(const GrPipelineBuilder* pipelineBuilder, 140 void GrDrawContext::drawPathsFromRange(const GrPipelineBuilder* pipelineBuilder,
138 const SkMatrix& viewMatrix, 141 const SkMatrix& viewMatrix,
139 const SkMatrix& localMatrix, 142 const SkMatrix& localMatrix,
140 GrColor color, 143 GrColor color,
141 GrPathRange* range, 144 GrPathRange* range,
142 GrPathRangeDraw* draw, 145 GrPathRangeDraw* draw,
143 int /*GrPathRendering::FillType*/ fill) { 146 int /*GrPathRendering::FillType*/ fill) {
144 RETURN_IF_ABANDONED 147 RETURN_IF_ABANDONED
145 SkDEBUGCODE(this->validate();) 148 SkDEBUGCODE(this->validate();)
146 149
147 this->getDrawTarget()->drawPathsFromRange(*pipelineBuilder, viewMatrix, loca lMatrix, color, 150 this->getDrawTarget()->drawPathsFromRange(*pipelineBuilder, viewMatrix, loca lMatrix, color,
148 range, draw, (GrPathRendering::Fil lType) fill); 151 range, draw, (GrPathRendering::Fil lType) fill);
149 } 152 }
150 153
151 void GrDrawContext::discard() { 154 void GrDrawContext::discard() {
152 RETURN_IF_ABANDONED 155 RETURN_IF_ABANDONED
153 SkDEBUGCODE(this->validate();) 156 SkDEBUGCODE(this->validate();)
154 157
155 AutoCheckFlush acf(fContext); 158 AutoCheckFlush acf(fDrawingManager);
156 this->getDrawTarget()->discard(fRenderTarget); 159 this->getDrawTarget()->discard(fRenderTarget);
157 } 160 }
158 161
159 void GrDrawContext::clear(const SkIRect* rect, 162 void GrDrawContext::clear(const SkIRect* rect,
160 const GrColor color, 163 const GrColor color,
161 bool canIgnoreRect) { 164 bool canIgnoreRect) {
162 RETURN_IF_ABANDONED 165 RETURN_IF_ABANDONED
163 SkDEBUGCODE(this->validate();) 166 SkDEBUGCODE(this->validate();)
164 167
165 AutoCheckFlush acf(fContext); 168 AutoCheckFlush acf(fDrawingManager);
166 this->getDrawTarget()->clear(rect, color, canIgnoreRect, fRenderTarget); 169 this->getDrawTarget()->clear(rect, color, canIgnoreRect, fRenderTarget);
167 } 170 }
168 171
169 172
170 void GrDrawContext::drawPaint(const GrClip& clip, 173 void GrDrawContext::drawPaint(const GrClip& clip,
171 const GrPaint& origPaint, 174 const GrPaint& origPaint,
172 const SkMatrix& viewMatrix) { 175 const SkMatrix& viewMatrix) {
173 RETURN_IF_ABANDONED 176 RETURN_IF_ABANDONED
174 SkDEBUGCODE(this->validate();) 177 SkDEBUGCODE(this->validate();)
175 178
(...skipping 23 matching lines...) Expand all
199 } 202 }
200 inverse.mapRect(&r); 203 inverse.mapRect(&r);
201 this->drawRect(clip, *paint, viewMatrix, r); 204 this->drawRect(clip, *paint, viewMatrix, r);
202 } else { 205 } else {
203 SkMatrix localMatrix; 206 SkMatrix localMatrix;
204 if (!viewMatrix.invert(&localMatrix)) { 207 if (!viewMatrix.invert(&localMatrix)) {
205 SkDebugf("Could not invert matrix\n"); 208 SkDebugf("Could not invert matrix\n");
206 return; 209 return;
207 } 210 }
208 211
209 AutoCheckFlush acf(fContext); 212 AutoCheckFlush acf(fDrawingManager);
210 213
211 GrPipelineBuilder pipelineBuilder(*paint, fRenderTarget, clip); 214 GrPipelineBuilder pipelineBuilder(*paint, fRenderTarget, clip);
212 this->getDrawTarget()->drawNonAARect(pipelineBuilder, 215 this->getDrawTarget()->drawNonAARect(pipelineBuilder,
213 paint->getColor(), 216 paint->getColor(),
214 SkMatrix::I(), 217 SkMatrix::I(),
215 r, 218 r,
216 localMatrix); 219 localMatrix);
217 } 220 }
218 } 221 }
219 222
(...skipping 11 matching lines...) Expand all
231 SkDEBUGCODE(this->validate();) 234 SkDEBUGCODE(this->validate();)
232 235
233 if (strokeInfo && strokeInfo->isDashed()) { 236 if (strokeInfo && strokeInfo->isDashed()) {
234 SkPath path; 237 SkPath path;
235 path.setIsVolatile(true); 238 path.setIsVolatile(true);
236 path.addRect(rect); 239 path.addRect(rect);
237 this->drawPath(clip, paint, viewMatrix, path, *strokeInfo); 240 this->drawPath(clip, paint, viewMatrix, path, *strokeInfo);
238 return; 241 return;
239 } 242 }
240 243
241 AutoCheckFlush acf(fContext); 244 AutoCheckFlush acf(fDrawingManager);
242 245
243 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 246 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
244 247
245 SkScalar width = nullptr == strokeInfo ? -1 : strokeInfo->getWidth(); 248 SkScalar width = nullptr == strokeInfo ? -1 : strokeInfo->getWidth();
246 249
247 // Check if this is a full RT draw and can be replaced with a clear. We don' t bother checking 250 // Check if this is a full RT draw and can be replaced with a clear. We don' t bother checking
248 // cases where the RT is fully inside a stroke. 251 // cases where the RT is fully inside a stroke.
249 if (width < 0) { 252 if (width < 0) {
250 SkRect rtRect; 253 SkRect rtRect;
251 pipelineBuilder.getRenderTarget()->getBoundsRect(&rtRect); 254 pipelineBuilder.getRenderTarget()->getBoundsRect(&rtRect);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 } 323 }
321 324
322 void GrDrawContext::drawNonAARectToRect(const GrClip& clip, 325 void GrDrawContext::drawNonAARectToRect(const GrClip& clip,
323 const GrPaint& paint, 326 const GrPaint& paint,
324 const SkMatrix& viewMatrix, 327 const SkMatrix& viewMatrix,
325 const SkRect& rectToDraw, 328 const SkRect& rectToDraw,
326 const SkRect& localRect) { 329 const SkRect& localRect) {
327 RETURN_IF_ABANDONED 330 RETURN_IF_ABANDONED
328 SkDEBUGCODE(this->validate();) 331 SkDEBUGCODE(this->validate();)
329 332
330 AutoCheckFlush acf(fContext); 333 AutoCheckFlush acf(fDrawingManager);
331 334
332 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 335 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
333 this->getDrawTarget()->drawNonAARect(pipelineBuilder, 336 this->getDrawTarget()->drawNonAARect(pipelineBuilder,
334 paint.getColor(), 337 paint.getColor(),
335 viewMatrix, 338 viewMatrix,
336 rectToDraw, 339 rectToDraw,
337 localRect); 340 localRect);
338 } 341 }
339 342
340 void GrDrawContext::drawNonAARectWithLocalMatrix(const GrClip& clip, 343 void GrDrawContext::drawNonAARectWithLocalMatrix(const GrClip& clip,
341 const GrPaint& paint, 344 const GrPaint& paint,
342 const SkMatrix& viewMatrix, 345 const SkMatrix& viewMatrix,
343 const SkRect& rectToDraw, 346 const SkRect& rectToDraw,
344 const SkMatrix& localMatrix) { 347 const SkMatrix& localMatrix) {
345 RETURN_IF_ABANDONED 348 RETURN_IF_ABANDONED
346 SkDEBUGCODE(this->validate();) 349 SkDEBUGCODE(this->validate();)
347 350
348 AutoCheckFlush acf(fContext); 351 AutoCheckFlush acf(fDrawingManager);
349 352
350 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 353 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
351 this->getDrawTarget()->drawNonAARect(pipelineBuilder, 354 this->getDrawTarget()->drawNonAARect(pipelineBuilder,
352 paint.getColor(), 355 paint.getColor(),
353 viewMatrix, 356 viewMatrix,
354 rectToDraw, 357 rectToDraw,
355 localMatrix); 358 localMatrix);
356 } 359 }
357 360
358 void GrDrawContext::drawVertices(const GrClip& clip, 361 void GrDrawContext::drawVertices(const GrClip& clip,
359 const GrPaint& paint, 362 const GrPaint& paint,
360 const SkMatrix& viewMatrix, 363 const SkMatrix& viewMatrix,
361 GrPrimitiveType primitiveType, 364 GrPrimitiveType primitiveType,
362 int vertexCount, 365 int vertexCount,
363 const SkPoint positions[], 366 const SkPoint positions[],
364 const SkPoint texCoords[], 367 const SkPoint texCoords[],
365 const GrColor colors[], 368 const GrColor colors[],
366 const uint16_t indices[], 369 const uint16_t indices[],
367 int indexCount) { 370 int indexCount) {
368 RETURN_IF_ABANDONED 371 RETURN_IF_ABANDONED
369 SkDEBUGCODE(this->validate();) 372 SkDEBUGCODE(this->validate();)
370 373
371 AutoCheckFlush acf(fContext); 374 AutoCheckFlush acf(fDrawingManager);
372 375
373 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 376 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
374 377
375 // TODO clients should give us bounds 378 // TODO clients should give us bounds
376 SkRect bounds; 379 SkRect bounds;
377 if (!bounds.setBoundsCheck(positions, vertexCount)) { 380 if (!bounds.setBoundsCheck(positions, vertexCount)) {
378 SkDebugf("drawVertices call empty bounds\n"); 381 SkDebugf("drawVertices call empty bounds\n");
379 return; 382 return;
380 } 383 }
381 384
(...skipping 20 matching lines...) Expand all
402 void GrDrawContext::drawAtlas(const GrClip& clip, 405 void GrDrawContext::drawAtlas(const GrClip& clip,
403 const GrPaint& paint, 406 const GrPaint& paint,
404 const SkMatrix& viewMatrix, 407 const SkMatrix& viewMatrix,
405 int spriteCount, 408 int spriteCount,
406 const SkRSXform xform[], 409 const SkRSXform xform[],
407 const SkRect texRect[], 410 const SkRect texRect[],
408 const SkColor colors[]) { 411 const SkColor colors[]) {
409 RETURN_IF_ABANDONED 412 RETURN_IF_ABANDONED
410 SkDEBUGCODE(this->validate();) 413 SkDEBUGCODE(this->validate();)
411 414
412 AutoCheckFlush acf(fContext); 415 AutoCheckFlush acf(fDrawingManager);
413 416
414 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 417 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
415 418
416 GrDrawAtlasBatch::Geometry geometry; 419 GrDrawAtlasBatch::Geometry geometry;
417 geometry.fColor = paint.getColor(); 420 geometry.fColor = paint.getColor();
418 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri x, spriteCount, 421 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri x, spriteCount,
419 xform, texRect, col ors)); 422 xform, texRect, col ors));
420 423
421 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 424 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
422 } 425 }
(...skipping 13 matching lines...) Expand all
436 } 439 }
437 440
438 if (strokeInfo.isDashed()) { 441 if (strokeInfo.isDashed()) {
439 SkPath path; 442 SkPath path;
440 path.setIsVolatile(true); 443 path.setIsVolatile(true);
441 path.addRRect(rrect); 444 path.addRRect(rrect);
442 this->drawPath(clip, paint, viewMatrix, path, strokeInfo); 445 this->drawPath(clip, paint, viewMatrix, path, strokeInfo);
443 return; 446 return;
444 } 447 }
445 448
446 AutoCheckFlush acf(fContext); 449 AutoCheckFlush acf(fDrawingManager);
447 450
448 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 451 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
449 GrColor color = paint.getColor(); 452 GrColor color = paint.getColor();
450 453
451 if (!GrOvalRenderer::DrawRRect(this->getDrawTarget(), 454 if (!GrOvalRenderer::DrawRRect(this->getDrawTarget(),
452 pipelineBuilder, 455 pipelineBuilder,
453 color, 456 color,
454 viewMatrix, 457 viewMatrix,
455 paint.isAntiAlias(), 458 paint.isAntiAlias(),
456 rrect, 459 rrect,
(...skipping 13 matching lines...) Expand all
470 const SkMatrix& viewMatrix, 473 const SkMatrix& viewMatrix,
471 const SkRRect& outer, 474 const SkRRect& outer,
472 const SkRRect& inner) { 475 const SkRRect& inner) {
473 RETURN_IF_ABANDONED 476 RETURN_IF_ABANDONED
474 SkDEBUGCODE(this->validate();) 477 SkDEBUGCODE(this->validate();)
475 478
476 if (outer.isEmpty()) { 479 if (outer.isEmpty()) {
477 return; 480 return;
478 } 481 }
479 482
480 AutoCheckFlush acf(fContext); 483 AutoCheckFlush acf(fDrawingManager);
481 484
482 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 485 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
483 GrColor color = paint.getColor(); 486 GrColor color = paint.getColor();
484 if (!GrOvalRenderer::DrawDRRect(this->getDrawTarget(), 487 if (!GrOvalRenderer::DrawDRRect(this->getDrawTarget(),
485 pipelineBuilder, 488 pipelineBuilder,
486 color, 489 color,
487 viewMatrix, 490 viewMatrix,
488 paint.isAntiAlias(), 491 paint.isAntiAlias(),
489 outer, 492 outer,
490 inner)) { 493 inner)) {
(...skipping 24 matching lines...) Expand all
515 } 518 }
516 519
517 if (strokeInfo.isDashed()) { 520 if (strokeInfo.isDashed()) {
518 SkPath path; 521 SkPath path;
519 path.setIsVolatile(true); 522 path.setIsVolatile(true);
520 path.addOval(oval); 523 path.addOval(oval);
521 this->drawPath(clip, paint, viewMatrix, path, strokeInfo); 524 this->drawPath(clip, paint, viewMatrix, path, strokeInfo);
522 return; 525 return;
523 } 526 }
524 527
525 AutoCheckFlush acf(fContext); 528 AutoCheckFlush acf(fDrawingManager);
526 529
527 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 530 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
528 GrColor color = paint.getColor(); 531 GrColor color = paint.getColor();
529 532
530 if (!GrOvalRenderer::DrawOval(this->getDrawTarget(), 533 if (!GrOvalRenderer::DrawOval(this->getDrawTarget(),
531 pipelineBuilder, 534 pipelineBuilder,
532 color, 535 color,
533 viewMatrix, 536 viewMatrix,
534 paint.isAntiAlias(), 537 paint.isAntiAlias(),
535 oval, 538 oval,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 } 593 }
591 594
592 return allEq || allGoE1; 595 return allEq || allGoE1;
593 } 596 }
594 597
595 void GrDrawContext::drawBatch(const GrClip& clip, 598 void GrDrawContext::drawBatch(const GrClip& clip,
596 const GrPaint& paint, GrDrawBatch* batch) { 599 const GrPaint& paint, GrDrawBatch* batch) {
597 RETURN_IF_ABANDONED 600 RETURN_IF_ABANDONED
598 SkDEBUGCODE(this->validate();) 601 SkDEBUGCODE(this->validate();)
599 602
600 AutoCheckFlush acf(fContext); 603 AutoCheckFlush acf(fDrawingManager);
601 604
602 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 605 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
603 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 606 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
604 } 607 }
605 608
606 void GrDrawContext::drawPath(const GrClip& clip, 609 void GrDrawContext::drawPath(const GrClip& clip,
607 const GrPaint& paint, 610 const GrPaint& paint,
608 const SkMatrix& viewMatrix, 611 const SkMatrix& viewMatrix,
609 const SkPath& path, 612 const SkPath& path,
610 const GrStrokeInfo& strokeInfo) { 613 const GrStrokeInfo& strokeInfo) {
611 RETURN_IF_ABANDONED 614 RETURN_IF_ABANDONED
612 SkDEBUGCODE(this->validate();) 615 SkDEBUGCODE(this->validate();)
613 616
614 if (path.isEmpty()) { 617 if (path.isEmpty()) {
615 if (path.isInverseFillType()) { 618 if (path.isInverseFillType()) {
616 this->drawPaint(clip, paint, viewMatrix); 619 this->drawPaint(clip, paint, viewMatrix);
617 } 620 }
618 return; 621 return;
619 } 622 }
620 623
621 GrColor color = paint.getColor(); 624 GrColor color = paint.getColor();
622 625
623 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re. 626 // Note that internalDrawPath may sw-rasterize the path into a scratch textu re.
624 // Scratch textures can be recycled after they are returned to the texture 627 // Scratch textures can be recycled after they are returned to the texture
625 // cache. This presents a potential hazard for buffered drawing. However, 628 // cache. This presents a potential hazard for buffered drawing. However,
626 // the writePixels that uploads to the scratch will perform a flush so we're 629 // the writePixels that uploads to the scratch will perform a flush so we're
627 // OK. 630 // OK.
628 AutoCheckFlush acf(fContext); 631 AutoCheckFlush acf(fDrawingManager);
629 632
630 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 633 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
631 if (!strokeInfo.isDashed()) { 634 if (!strokeInfo.isDashed()) {
632 bool useCoverageAA = paint.isAntiAlias() && 635 bool useCoverageAA = paint.isAntiAlias() &&
633 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled(); 636 !pipelineBuilder.getRenderTarget()->isUnifiedMultisampled();
634 637
635 if (useCoverageAA && strokeInfo.getWidth() < 0 && !path.isConvex()) { 638 if (useCoverageAA && strokeInfo.getWidth() < 0 && !path.isConvex()) {
636 // Concave AA paths are expensive - try to avoid them for special ca ses 639 // Concave AA paths are expensive - try to avoid them for special ca ses
637 SkRect rects[2]; 640 SkRect rects[2];
638 641
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
682 685
683 GrPathRendererChain::DrawType type = 686 GrPathRendererChain::DrawType type =
684 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType : 687 useCoverageAA ? GrPathRendererChain::kColorAntiAlias_DrawType :
685 GrPathRendererChain::kColor_DrawType; 688 GrPathRendererChain::kColor_DrawType;
686 689
687 const SkPath* pathPtr = &path; 690 const SkPath* pathPtr = &path;
688 SkTLazy<SkPath> tmpPath; 691 SkTLazy<SkPath> tmpPath;
689 const GrStrokeInfo* strokeInfoPtr = &strokeInfo; 692 const GrStrokeInfo* strokeInfoPtr = &strokeInfo;
690 693
691 // Try a 1st time without stroking the path and without allowing the SW rend erer 694 // Try a 1st time without stroking the path and without allowing the SW rend erer
692 GrPathRenderer* pr = fContext->getPathRenderer(target, pipelineBuilder, view Matrix, *pathPtr, 695 GrPathRenderer* pr = fDrawingManager->getContext()->getPathRenderer(target, pipelineBuilder,
693 *strokeInfoPtr, false, type) ; 696 viewMatr ix, *pathPtr,
697 *strokeI nfoPtr, false,
698 type);
694 699
695 GrStrokeInfo dashlessStrokeInfo(strokeInfo, false); 700 GrStrokeInfo dashlessStrokeInfo(strokeInfo, false);
696 if (nullptr == pr && strokeInfo.isDashed()) { 701 if (nullptr == pr && strokeInfo.isDashed()) {
697 // It didn't work above, so try again with dashed stroke converted to a dashless stroke. 702 // It didn't work above, so try again with dashed stroke converted to a dashless stroke.
698 if (!strokeInfo.applyDashToPath(tmpPath.init(), &dashlessStrokeInfo, *pa thPtr)) { 703 if (!strokeInfo.applyDashToPath(tmpPath.init(), &dashlessStrokeInfo, *pa thPtr)) {
699 return; 704 return;
700 } 705 }
701 pathPtr = tmpPath.get(); 706 pathPtr = tmpPath.get();
702 if (pathPtr->isEmpty()) { 707 if (pathPtr->isEmpty()) {
703 return; 708 return;
704 } 709 }
705 strokeInfoPtr = &dashlessStrokeInfo; 710 strokeInfoPtr = &dashlessStrokeInfo;
706 pr = fContext->getPathRenderer(target, pipelineBuilder, viewMatrix, *pat hPtr, *strokeInfoPtr, 711 pr = fDrawingManager->getContext()->getPathRenderer(target, pipelineBuil der, viewMatrix,
707 false, type); 712 *pathPtr, *strokeInf oPtr,
713 false, type);
708 } 714 }
709 715
710 if (nullptr == pr) { 716 if (nullptr == pr) {
711 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*strokeInfoPtr, viewMa trix, nullptr) && 717 if (!GrPathRenderer::IsStrokeHairlineOrEquivalent(*strokeInfoPtr, viewMa trix, nullptr) &&
712 !strokeInfoPtr->isFillStyle()) { 718 !strokeInfoPtr->isFillStyle()) {
713 // It didn't work above, so try again with stroke converted to a fil l. 719 // It didn't work above, so try again with stroke converted to a fil l.
714 if (!tmpPath.isValid()) { 720 if (!tmpPath.isValid()) {
715 tmpPath.init(); 721 tmpPath.init();
716 } 722 }
717 dashlessStrokeInfo.setResScale(SkScalarAbs(viewMatrix.getMaxScale()) ); 723 dashlessStrokeInfo.setResScale(SkScalarAbs(viewMatrix.getMaxScale()) );
718 if (!dashlessStrokeInfo.applyToPath(tmpPath.get(), *pathPtr)) { 724 if (!dashlessStrokeInfo.applyToPath(tmpPath.get(), *pathPtr)) {
719 return; 725 return;
720 } 726 }
721 pathPtr = tmpPath.get(); 727 pathPtr = tmpPath.get();
722 if (pathPtr->isEmpty()) { 728 if (pathPtr->isEmpty()) {
723 return; 729 return;
724 } 730 }
725 dashlessStrokeInfo.setFillStyle(); 731 dashlessStrokeInfo.setFillStyle();
726 strokeInfoPtr = &dashlessStrokeInfo; 732 strokeInfoPtr = &dashlessStrokeInfo;
727 } 733 }
728 734
729 // This time, allow SW renderer 735 // This time, allow SW renderer
730 pr = fContext->getPathRenderer(target, pipelineBuilder, viewMatrix, *pat hPtr, *strokeInfoPtr, 736 pr = fDrawingManager->getContext()->getPathRenderer(target, pipelineBuil der, viewMatrix,
731 true, type); 737 *pathPtr, *strokeInf oPtr,
738 true, type);
732 } 739 }
733 740
734 if (nullptr == pr) { 741 if (nullptr == pr) {
735 #ifdef SK_DEBUG 742 #ifdef SK_DEBUG
736 SkDebugf("Unable to find path renderer compatible with path.\n"); 743 SkDebugf("Unable to find path renderer compatible with path.\n");
737 #endif 744 #endif
738 return; 745 return;
739 } 746 }
740 747
741 GrPathRenderer::DrawPathArgs args; 748 GrPathRenderer::DrawPathArgs args;
742 args.fTarget = target; 749 args.fTarget = target;
743 args.fResourceProvider = fContext->resourceProvider(); 750 args.fResourceProvider = fDrawingManager->getContext()->resourceProvider();
744 args.fPipelineBuilder = pipelineBuilder; 751 args.fPipelineBuilder = pipelineBuilder;
745 args.fColor = color; 752 args.fColor = color;
746 args.fViewMatrix = &viewMatrix; 753 args.fViewMatrix = &viewMatrix;
747 args.fPath = pathPtr; 754 args.fPath = pathPtr;
748 args.fStroke = strokeInfoPtr; 755 args.fStroke = strokeInfoPtr;
749 args.fAntiAlias = useCoverageAA; 756 args.fAntiAlias = useCoverageAA;
750 pr->drawPath(args); 757 pr->drawPath(args);
751 } 758 }
752 759
753 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) { 760 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) {
754 RETURN_IF_ABANDONED 761 RETURN_IF_ABANDONED
755 SkDEBUGCODE(this->validate();) 762 SkDEBUGCODE(this->validate();)
756 763
757 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); 764 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch);
758 } 765 }
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrDrawingManager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698