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

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

Issue 1555953004: Create debug only SkSingleOwner (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 4 years, 11 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') | no next file » | 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 "GrBatchTest.h" 9 #include "GrBatchTest.h"
10 #include "GrColor.h" 10 #include "GrColor.h"
11 #include "GrDrawContext.h" 11 #include "GrDrawContext.h"
12 #include "GrDrawingManager.h" 12 #include "GrDrawingManager.h"
13 #include "GrOvalRenderer.h" 13 #include "GrOvalRenderer.h"
14 #include "GrPathRenderer.h" 14 #include "GrPathRenderer.h"
15 #include "GrRenderTarget.h" 15 #include "GrRenderTarget.h"
16 #include "GrRenderTargetPriv.h" 16 #include "GrRenderTargetPriv.h"
17 #include "GrResourceProvider.h" 17 #include "GrResourceProvider.h"
18 #include "SkSurfacePriv.h" 18 #include "SkSurfacePriv.h"
19 19
20 #include "batches/GrBatch.h" 20 #include "batches/GrBatch.h"
21 #include "batches/GrDrawAtlasBatch.h" 21 #include "batches/GrDrawAtlasBatch.h"
22 #include "batches/GrDrawVerticesBatch.h" 22 #include "batches/GrDrawVerticesBatch.h"
23 #include "batches/GrRectBatchFactory.h" 23 #include "batches/GrRectBatchFactory.h"
24 #include "batches/GrNinePatch.h" // TODO Factory 24 #include "batches/GrNinePatch.h" // TODO Factory
25 25
26 #include "text/GrAtlasTextContext.h" 26 #include "text/GrAtlasTextContext.h"
27 #include "text/GrStencilAndCoverTextContext.h" 27 #include "text/GrStencilAndCoverTextContext.h"
28 28
29 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM anager->getContext()) 29 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM anager->getContext())
30 #define ASSERT_SINGLE_OWNER \
31 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(&fSingleOwner);)
30 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } 32 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; }
31 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fa lse; } 33 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fa lse; }
32 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nu llptr; } 34 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nu llptr; }
33 35
34 class AutoCheckFlush { 36 class AutoCheckFlush {
35 public: 37 public:
36 AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingMa nager) { 38 AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingMa nager) {
37 SkASSERT(fDrawingManager); 39 SkASSERT(fDrawingManager);
38 } 40 }
39 ~AutoCheckFlush() { fDrawingManager->getContext()->flushIfNecessary(); } 41 ~AutoCheckFlush() { fDrawingManager->getContext()->flushIfNecessary(); }
(...skipping 22 matching lines...) Expand all
62 SkASSERT(fRenderTarget); 64 SkASSERT(fRenderTarget);
63 ASSERT_OWNED_RESOURCE(fRenderTarget); 65 ASSERT_OWNED_RESOURCE(fRenderTarget);
64 66
65 if (fDrawTarget && !fDrawTarget->isClosed()) { 67 if (fDrawTarget && !fDrawTarget->isClosed()) {
66 SkASSERT(fRenderTarget->getLastDrawTarget() == fDrawTarget); 68 SkASSERT(fRenderTarget->getLastDrawTarget() == fDrawTarget);
67 } 69 }
68 } 70 }
69 #endif 71 #endif
70 72
71 GrDrawContext::~GrDrawContext() { 73 GrDrawContext::~GrDrawContext() {
74 ASSERT_SINGLE_OWNER
72 SkSafeUnref(fDrawTarget); 75 SkSafeUnref(fDrawTarget);
73 } 76 }
74 77
75 GrDrawTarget* GrDrawContext::getDrawTarget() { 78 GrDrawTarget* GrDrawContext::getDrawTarget() {
79 ASSERT_SINGLE_OWNER
76 SkDEBUGCODE(this->validate();) 80 SkDEBUGCODE(this->validate();)
77 81
78 if (!fDrawTarget || fDrawTarget->isClosed()) { 82 if (!fDrawTarget || fDrawTarget->isClosed()) {
79 fDrawTarget = fDrawingManager->newDrawTarget(fRenderTarget); 83 fDrawTarget = fDrawingManager->newDrawTarget(fRenderTarget);
80 } 84 }
81 85
82 return fDrawTarget; 86 return fDrawTarget;
83 } 87 }
84 88
85 void GrDrawContext::copySurface(GrSurface* src, const SkIRect& srcRect, const Sk IPoint& dstPoint) { 89 void GrDrawContext::copySurface(GrSurface* src, const SkIRect& srcRect, const Sk IPoint& dstPoint) {
90 ASSERT_SINGLE_OWNER
86 RETURN_IF_ABANDONED 91 RETURN_IF_ABANDONED
87 SkDEBUGCODE(this->validate();) 92 SkDEBUGCODE(this->validate();)
88 93
89 this->getDrawTarget()->copySurface(fRenderTarget, src, srcRect, dstPoint); 94 this->getDrawTarget()->copySurface(fRenderTarget, src, srcRect, dstPoint);
90 } 95 }
91 96
92 void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint, 97 void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint,
93 const SkPaint& skPaint, 98 const SkPaint& skPaint,
94 const SkMatrix& viewMatrix, 99 const SkMatrix& viewMatrix,
95 const char text[], size_t byteLength, 100 const char text[], size_t byteLength,
96 SkScalar x, SkScalar y, const SkIRect& clipBounds) { 101 SkScalar x, SkScalar y, const SkIRect& clipBounds) {
102 ASSERT_SINGLE_OWNER
97 RETURN_IF_ABANDONED 103 RETURN_IF_ABANDONED
98 SkDEBUGCODE(this->validate();) 104 SkDEBUGCODE(this->validate();)
99 105
100 if (!fTextContext) { 106 if (!fTextContext) {
101 fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget ); 107 fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget );
102 } 108 }
103 109
104 fTextContext->drawText(this, clip, grPaint, skPaint, viewMatrix, 110 fTextContext->drawText(this, clip, grPaint, skPaint, viewMatrix,
105 text, byteLength, x, y, clipBounds); 111 text, byteLength, x, y, clipBounds);
106 } 112 }
107 113
108 void GrDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint, 114 void GrDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint,
109 const SkPaint& skPaint, 115 const SkPaint& skPaint,
110 const SkMatrix& viewMatrix, 116 const SkMatrix& viewMatrix,
111 const char text[], size_t byteLength, 117 const char text[], size_t byteLength,
112 const SkScalar pos[], int scalarsPerPosition, 118 const SkScalar pos[], int scalarsPerPosition,
113 const SkPoint& offset, const SkIRect& clipBounds ) { 119 const SkPoint& offset, const SkIRect& clipBounds ) {
120 ASSERT_SINGLE_OWNER
114 RETURN_IF_ABANDONED 121 RETURN_IF_ABANDONED
115 SkDEBUGCODE(this->validate();) 122 SkDEBUGCODE(this->validate();)
116 123
117 if (!fTextContext) { 124 if (!fTextContext) {
118 fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget ); 125 fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget );
119 } 126 }
120 127
121 fTextContext->drawPosText(this, clip, grPaint, skPaint, viewMatrix, text, by teLength, 128 fTextContext->drawPosText(this, clip, grPaint, skPaint, viewMatrix, text, by teLength,
122 pos, scalarsPerPosition, offset, clipBounds); 129 pos, scalarsPerPosition, offset, clipBounds);
123 130
124 } 131 }
125 132
126 void GrDrawContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint, 133 void GrDrawContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint,
127 const SkMatrix& viewMatrix, const SkTextBlob* b lob, 134 const SkMatrix& viewMatrix, const SkTextBlob* b lob,
128 SkScalar x, SkScalar y, 135 SkScalar x, SkScalar y,
129 SkDrawFilter* filter, const SkIRect& clipBounds ) { 136 SkDrawFilter* filter, const SkIRect& clipBounds ) {
137 ASSERT_SINGLE_OWNER
130 RETURN_IF_ABANDONED 138 RETURN_IF_ABANDONED
131 SkDEBUGCODE(this->validate();) 139 SkDEBUGCODE(this->validate();)
132 140
133 if (!fTextContext) { 141 if (!fTextContext) {
134 fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget ); 142 fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget );
135 } 143 }
136 144
137 fTextContext->drawTextBlob(this, clip, skPaint, viewMatrix, blob, x, y, filt er, clipBounds); 145 fTextContext->drawTextBlob(this, clip, skPaint, viewMatrix, blob, x, y, filt er, clipBounds);
138 } 146 }
139 147
140 void GrDrawContext::discard() { 148 void GrDrawContext::discard() {
149 ASSERT_SINGLE_OWNER
141 RETURN_IF_ABANDONED 150 RETURN_IF_ABANDONED
142 SkDEBUGCODE(this->validate();) 151 SkDEBUGCODE(this->validate();)
143 152
144 AutoCheckFlush acf(fDrawingManager); 153 AutoCheckFlush acf(fDrawingManager);
145 this->getDrawTarget()->discard(fRenderTarget); 154 this->getDrawTarget()->discard(fRenderTarget);
146 } 155 }
147 156
148 void GrDrawContext::clear(const SkIRect* rect, 157 void GrDrawContext::clear(const SkIRect* rect,
149 const GrColor color, 158 const GrColor color,
150 bool canIgnoreRect) { 159 bool canIgnoreRect) {
160 ASSERT_SINGLE_OWNER
151 RETURN_IF_ABANDONED 161 RETURN_IF_ABANDONED
152 SkDEBUGCODE(this->validate();) 162 SkDEBUGCODE(this->validate();)
153 163
154 AutoCheckFlush acf(fDrawingManager); 164 AutoCheckFlush acf(fDrawingManager);
155 this->getDrawTarget()->clear(rect, color, canIgnoreRect, fRenderTarget); 165 this->getDrawTarget()->clear(rect, color, canIgnoreRect, fRenderTarget);
156 } 166 }
157 167
158 168
159 void GrDrawContext::drawPaint(const GrClip& clip, 169 void GrDrawContext::drawPaint(const GrClip& clip,
160 const GrPaint& origPaint, 170 const GrPaint& origPaint,
161 const SkMatrix& viewMatrix) { 171 const SkMatrix& viewMatrix) {
172 ASSERT_SINGLE_OWNER
162 RETURN_IF_ABANDONED 173 RETURN_IF_ABANDONED
163 SkDEBUGCODE(this->validate();) 174 SkDEBUGCODE(this->validate();)
164 175
165 // set rect to be big enough to fill the space, but not super-huge, so we 176 // set rect to be big enough to fill the space, but not super-huge, so we
166 // don't overflow fixed-point implementations 177 // don't overflow fixed-point implementations
167 SkRect r; 178 SkRect r;
168 r.setLTRB(0, 0, 179 r.setLTRB(0, 0,
169 SkIntToScalar(fRenderTarget->width()), 180 SkIntToScalar(fRenderTarget->width()),
170 SkIntToScalar(fRenderTarget->height())); 181 SkIntToScalar(fRenderTarget->height()));
171 SkTCopyOnFirstWrite<GrPaint> paint(origPaint); 182 SkTCopyOnFirstWrite<GrPaint> paint(origPaint);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 228
218 static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt) { 229 static bool should_apply_coverage_aa(const GrPaint& paint, GrRenderTarget* rt) {
219 return paint.isAntiAlias() && !rt->isUnifiedMultisampled(); 230 return paint.isAntiAlias() && !rt->isUnifiedMultisampled();
220 } 231 }
221 232
222 void GrDrawContext::drawRect(const GrClip& clip, 233 void GrDrawContext::drawRect(const GrClip& clip,
223 const GrPaint& paint, 234 const GrPaint& paint,
224 const SkMatrix& viewMatrix, 235 const SkMatrix& viewMatrix,
225 const SkRect& rect, 236 const SkRect& rect,
226 const GrStrokeInfo* strokeInfo) { 237 const GrStrokeInfo* strokeInfo) {
238 ASSERT_SINGLE_OWNER
227 RETURN_IF_ABANDONED 239 RETURN_IF_ABANDONED
228 SkDEBUGCODE(this->validate();) 240 SkDEBUGCODE(this->validate();)
229 241
230 // Dashing should've been devolved to a path in SkGpuDevice 242 // Dashing should've been devolved to a path in SkGpuDevice
231 SkASSERT(!strokeInfo || !strokeInfo->isDashed()); 243 SkASSERT(!strokeInfo || !strokeInfo->isDashed());
232 244
233 AutoCheckFlush acf(fDrawingManager); 245 AutoCheckFlush acf(fDrawingManager);
234 246
235 SkScalar width = nullptr == strokeInfo ? -1 : strokeInfo->getWidth(); 247 SkScalar width = nullptr == strokeInfo ? -1 : strokeInfo->getWidth();
236 248
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 // filled BW rect 321 // filled BW rect
310 this->getDrawTarget()->drawNonAARect(pipelineBuilder, color, viewMatrix, rect); 322 this->getDrawTarget()->drawNonAARect(pipelineBuilder, color, viewMatrix, rect);
311 } 323 }
312 } 324 }
313 325
314 void GrDrawContext::fillRectToRect(const GrClip& clip, 326 void GrDrawContext::fillRectToRect(const GrClip& clip,
315 const GrPaint& paint, 327 const GrPaint& paint,
316 const SkMatrix& viewMatrix, 328 const SkMatrix& viewMatrix,
317 const SkRect& rectToDraw, 329 const SkRect& rectToDraw,
318 const SkRect& localRect) { 330 const SkRect& localRect) {
331 ASSERT_SINGLE_OWNER
319 RETURN_IF_ABANDONED 332 RETURN_IF_ABANDONED
320 SkDEBUGCODE(this->validate();) 333 SkDEBUGCODE(this->validate();)
321 334
322 AutoCheckFlush acf(fDrawingManager); 335 AutoCheckFlush acf(fDrawingManager);
323 336
324 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 337 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
325 if (should_apply_coverage_aa(paint, fRenderTarget) && 338 if (should_apply_coverage_aa(paint, fRenderTarget) &&
326 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { 339 view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
327 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::CreateWithLocalRect( 340 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::CreateWithLocalRect(
328 paint.getColor(), viewMatrix, rectToDraw, localRect)); 341 paint.getColor(), viewMatrix, rectToDraw, localRect));
329 if (batch) { 342 if (batch) {
330 this->drawBatch(&pipelineBuilder, batch); 343 this->drawBatch(&pipelineBuilder, batch);
331 } 344 }
332 } else { 345 } else {
333 this->getDrawTarget()->drawNonAARect(pipelineBuilder, 346 this->getDrawTarget()->drawNonAARect(pipelineBuilder,
334 paint.getColor(), 347 paint.getColor(),
335 viewMatrix, 348 viewMatrix,
336 rectToDraw, 349 rectToDraw,
337 localRect); 350 localRect);
338 } 351 }
339 } 352 }
340 353
341 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, 354 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip,
342 const GrPaint& paint, 355 const GrPaint& paint,
343 const SkMatrix& viewMatrix, 356 const SkMatrix& viewMatrix,
344 const SkRect& rectToDraw, 357 const SkRect& rectToDraw,
345 const SkMatrix& localMatrix) { 358 const SkMatrix& localMatrix) {
359 ASSERT_SINGLE_OWNER
346 RETURN_IF_ABANDONED 360 RETURN_IF_ABANDONED
347 SkDEBUGCODE(this->validate();) 361 SkDEBUGCODE(this->validate();)
348 362
349 AutoCheckFlush acf(fDrawingManager); 363 AutoCheckFlush acf(fDrawingManager);
350 364
351 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 365 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
352 366
353 if (should_apply_coverage_aa(paint, fRenderTarget) && 367 if (should_apply_coverage_aa(paint, fRenderTarget) &&
354 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { 368 view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
355 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::Create( 369 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::Create(
(...skipping 11 matching lines...) Expand all
367 void GrDrawContext::drawVertices(const GrClip& clip, 381 void GrDrawContext::drawVertices(const GrClip& clip,
368 const GrPaint& paint, 382 const GrPaint& paint,
369 const SkMatrix& viewMatrix, 383 const SkMatrix& viewMatrix,
370 GrPrimitiveType primitiveType, 384 GrPrimitiveType primitiveType,
371 int vertexCount, 385 int vertexCount,
372 const SkPoint positions[], 386 const SkPoint positions[],
373 const SkPoint texCoords[], 387 const SkPoint texCoords[],
374 const GrColor colors[], 388 const GrColor colors[],
375 const uint16_t indices[], 389 const uint16_t indices[],
376 int indexCount) { 390 int indexCount) {
391 ASSERT_SINGLE_OWNER
377 RETURN_IF_ABANDONED 392 RETURN_IF_ABANDONED
378 SkDEBUGCODE(this->validate();) 393 SkDEBUGCODE(this->validate();)
379 394
380 AutoCheckFlush acf(fDrawingManager); 395 AutoCheckFlush acf(fDrawingManager);
381 396
382 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 397 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
383 398
384 // TODO clients should give us bounds 399 // TODO clients should give us bounds
385 SkRect bounds; 400 SkRect bounds;
386 if (!bounds.setBoundsCheck(positions, vertexCount)) { 401 if (!bounds.setBoundsCheck(positions, vertexCount)) {
(...skipping 23 matching lines...) Expand all
410 425
411 /////////////////////////////////////////////////////////////////////////////// 426 ///////////////////////////////////////////////////////////////////////////////
412 427
413 void GrDrawContext::drawAtlas(const GrClip& clip, 428 void GrDrawContext::drawAtlas(const GrClip& clip,
414 const GrPaint& paint, 429 const GrPaint& paint,
415 const SkMatrix& viewMatrix, 430 const SkMatrix& viewMatrix,
416 int spriteCount, 431 int spriteCount,
417 const SkRSXform xform[], 432 const SkRSXform xform[],
418 const SkRect texRect[], 433 const SkRect texRect[],
419 const SkColor colors[]) { 434 const SkColor colors[]) {
435 ASSERT_SINGLE_OWNER
420 RETURN_IF_ABANDONED 436 RETURN_IF_ABANDONED
421 SkDEBUGCODE(this->validate();) 437 SkDEBUGCODE(this->validate();)
422 438
423 AutoCheckFlush acf(fDrawingManager); 439 AutoCheckFlush acf(fDrawingManager);
424 440
425 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 441 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
426 442
427 GrDrawAtlasBatch::Geometry geometry; 443 GrDrawAtlasBatch::Geometry geometry;
428 geometry.fColor = paint.getColor(); 444 geometry.fColor = paint.getColor();
429 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri x, spriteCount, 445 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri x, spriteCount,
430 xform, texRect, col ors)); 446 xform, texRect, col ors));
431 447
432 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 448 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
433 } 449 }
434 450
435 /////////////////////////////////////////////////////////////////////////////// 451 ///////////////////////////////////////////////////////////////////////////////
436 452
437 void GrDrawContext::drawRRect(const GrClip& clip, 453 void GrDrawContext::drawRRect(const GrClip& clip,
438 const GrPaint& paint, 454 const GrPaint& paint,
439 const SkMatrix& viewMatrix, 455 const SkMatrix& viewMatrix,
440 const SkRRect& rrect, 456 const SkRRect& rrect,
441 const GrStrokeInfo& strokeInfo) { 457 const GrStrokeInfo& strokeInfo) {
458 ASSERT_SINGLE_OWNER
442 RETURN_IF_ABANDONED 459 RETURN_IF_ABANDONED
443 SkDEBUGCODE(this->validate();) 460 SkDEBUGCODE(this->validate();)
444 461
445 if (rrect.isEmpty()) { 462 if (rrect.isEmpty()) {
446 return; 463 return;
447 } 464 }
448 465
449 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path in SkGpuDevice 466 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path in SkGpuDevice
450 467
451 AutoCheckFlush acf(fDrawingManager); 468 AutoCheckFlush acf(fDrawingManager);
(...skipping 16 matching lines...) Expand all
468 } 485 }
469 } 486 }
470 487
471 /////////////////////////////////////////////////////////////////////////////// 488 ///////////////////////////////////////////////////////////////////////////////
472 489
473 void GrDrawContext::drawDRRect(const GrClip& clip, 490 void GrDrawContext::drawDRRect(const GrClip& clip,
474 const GrPaint& paint, 491 const GrPaint& paint,
475 const SkMatrix& viewMatrix, 492 const SkMatrix& viewMatrix,
476 const SkRRect& outer, 493 const SkRRect& outer,
477 const SkRRect& inner) { 494 const SkRRect& inner) {
495 ASSERT_SINGLE_OWNER
478 RETURN_IF_ABANDONED 496 RETURN_IF_ABANDONED
479 SkDEBUGCODE(this->validate();) 497 SkDEBUGCODE(this->validate();)
480 498
481 if (outer.isEmpty()) { 499 if (outer.isEmpty()) {
482 return; 500 return;
483 } 501 }
484 502
485 AutoCheckFlush acf(fDrawingManager); 503 AutoCheckFlush acf(fDrawingManager);
486 504
487 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 505 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
(...skipping 17 matching lines...) Expand all
505 } 523 }
506 } 524 }
507 525
508 /////////////////////////////////////////////////////////////////////////////// 526 ///////////////////////////////////////////////////////////////////////////////
509 527
510 void GrDrawContext::drawOval(const GrClip& clip, 528 void GrDrawContext::drawOval(const GrClip& clip,
511 const GrPaint& paint, 529 const GrPaint& paint,
512 const SkMatrix& viewMatrix, 530 const SkMatrix& viewMatrix,
513 const SkRect& oval, 531 const SkRect& oval,
514 const GrStrokeInfo& strokeInfo) { 532 const GrStrokeInfo& strokeInfo) {
533 ASSERT_SINGLE_OWNER
515 RETURN_IF_ABANDONED 534 RETURN_IF_ABANDONED
516 SkDEBUGCODE(this->validate();) 535 SkDEBUGCODE(this->validate();)
517 536
518 if (oval.isEmpty()) { 537 if (oval.isEmpty()) {
519 return; 538 return;
520 } 539 }
521 540
522 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path in SkGpuDevice 541 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path in SkGpuDevice
523 542
524 AutoCheckFlush acf(fDrawingManager); 543 AutoCheckFlush acf(fDrawingManager);
(...skipping 16 matching lines...) Expand all
541 } 560 }
542 } 561 }
543 562
544 void GrDrawContext::drawImageNine(const GrClip& clip, 563 void GrDrawContext::drawImageNine(const GrClip& clip,
545 const GrPaint& paint, 564 const GrPaint& paint,
546 const SkMatrix& viewMatrix, 565 const SkMatrix& viewMatrix,
547 int imageWidth, 566 int imageWidth,
548 int imageHeight, 567 int imageHeight,
549 const SkIRect& center, 568 const SkIRect& center,
550 const SkRect& dst) { 569 const SkRect& dst) {
570 ASSERT_SINGLE_OWNER
551 RETURN_IF_ABANDONED 571 RETURN_IF_ABANDONED
552 SkDEBUGCODE(this->validate();) 572 SkDEBUGCODE(this->validate();)
553 573
554 AutoCheckFlush acf(fDrawingManager); 574 AutoCheckFlush acf(fDrawingManager);
555 575
556 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v iewMatrix, 576 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v iewMatrix,
557 imageWidth, imageHe ight, 577 imageWidth, imageHe ight,
558 center, dst)); 578 center, dst));
559 579
560 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 580 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 if (!SkScalarNearlyEqual(margin, temp)) { 627 if (!SkScalarNearlyEqual(margin, temp)) {
608 allEq = false; 628 allEq = false;
609 } 629 }
610 } 630 }
611 631
612 return allEq || allGoE1; 632 return allEq || allGoE1;
613 } 633 }
614 634
615 void GrDrawContext::drawBatch(const GrClip& clip, 635 void GrDrawContext::drawBatch(const GrClip& clip,
616 const GrPaint& paint, GrDrawBatch* batch) { 636 const GrPaint& paint, GrDrawBatch* batch) {
637 ASSERT_SINGLE_OWNER
617 RETURN_IF_ABANDONED 638 RETURN_IF_ABANDONED
618 SkDEBUGCODE(this->validate();) 639 SkDEBUGCODE(this->validate();)
619 640
620 AutoCheckFlush acf(fDrawingManager); 641 AutoCheckFlush acf(fDrawingManager);
621 642
622 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 643 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
623 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 644 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
624 } 645 }
625 646
626 void GrDrawContext::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, 647 void GrDrawContext::drawPathBatch(const GrPipelineBuilder& pipelineBuilder,
627 GrDrawPathBatchBase* batch) { 648 GrDrawPathBatchBase* batch) {
649 ASSERT_SINGLE_OWNER
628 RETURN_IF_ABANDONED 650 RETURN_IF_ABANDONED
629 SkDEBUGCODE(this->validate();) 651 SkDEBUGCODE(this->validate();)
630 652
631 AutoCheckFlush acf(fDrawingManager); 653 AutoCheckFlush acf(fDrawingManager);
632 654
633 this->getDrawTarget()->drawPathBatch(pipelineBuilder, batch); 655 this->getDrawTarget()->drawPathBatch(pipelineBuilder, batch);
634 } 656 }
635 657
636 void GrDrawContext::drawPath(const GrClip& clip, 658 void GrDrawContext::drawPath(const GrClip& clip,
637 const GrPaint& paint, 659 const GrPaint& paint,
638 const SkMatrix& viewMatrix, 660 const SkMatrix& viewMatrix,
639 const SkPath& path, 661 const SkPath& path,
640 const GrStrokeInfo& strokeInfo) { 662 const GrStrokeInfo& strokeInfo) {
663 ASSERT_SINGLE_OWNER
641 RETURN_IF_ABANDONED 664 RETURN_IF_ABANDONED
642 SkDEBUGCODE(this->validate();) 665 SkDEBUGCODE(this->validate();)
643 666
644 if (path.isEmpty()) { 667 if (path.isEmpty()) {
645 if (path.isInverseFillType()) { 668 if (path.isInverseFillType()) {
646 this->drawPaint(clip, paint, viewMatrix); 669 this->drawPaint(clip, paint, viewMatrix);
647 } 670 }
648 return; 671 return;
649 } 672 }
650 673
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 this->internalDrawPath(&pipelineBuilder, viewMatrix, color, 713 this->internalDrawPath(&pipelineBuilder, viewMatrix, color,
691 paint.isAntiAlias(), path, strokeInfo); 714 paint.isAntiAlias(), path, strokeInfo);
692 } 715 }
693 716
694 void GrDrawContext::internalDrawPath(GrPipelineBuilder* pipelineBuilder, 717 void GrDrawContext::internalDrawPath(GrPipelineBuilder* pipelineBuilder,
695 const SkMatrix& viewMatrix, 718 const SkMatrix& viewMatrix,
696 GrColor color, 719 GrColor color,
697 bool useAA, 720 bool useAA,
698 const SkPath& path, 721 const SkPath& path,
699 const GrStrokeInfo& strokeInfo) { 722 const GrStrokeInfo& strokeInfo) {
723 ASSERT_SINGLE_OWNER
700 RETURN_IF_ABANDONED 724 RETURN_IF_ABANDONED
701 SkASSERT(!path.isEmpty()); 725 SkASSERT(!path.isEmpty());
702 726
703 // An Assumption here is that path renderer would use some form of tweaking 727 // An Assumption here is that path renderer would use some form of tweaking
704 // the src color (either the input alpha or in the frag shader) to implement 728 // the src color (either the input alpha or in the frag shader) to implement
705 // aa. If we have some future driver-mojo path AA that can do the right 729 // aa. If we have some future driver-mojo path AA that can do the right
706 // thing WRT to the blend then we'll need some query on the PR. 730 // thing WRT to the blend then we'll need some query on the PR.
707 bool useCoverageAA = useAA && 731 bool useCoverageAA = useAA &&
708 !pipelineBuilder->getRenderTarget()->isUnifiedMultisampled(); 732 !pipelineBuilder->getRenderTarget()->isUnifiedMultisampled();
709 bool isStencilDisabled = pipelineBuilder->getStencil().isDisabled(); 733 bool isStencilDisabled = pipelineBuilder->getStencil().isDisabled();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 args.fPipelineBuilder = pipelineBuilder; 810 args.fPipelineBuilder = pipelineBuilder;
787 args.fColor = color; 811 args.fColor = color;
788 args.fViewMatrix = &viewMatrix; 812 args.fViewMatrix = &viewMatrix;
789 args.fPath = pathPtr; 813 args.fPath = pathPtr;
790 args.fStroke = strokeInfoPtr; 814 args.fStroke = strokeInfoPtr;
791 args.fAntiAlias = useCoverageAA; 815 args.fAntiAlias = useCoverageAA;
792 pr->drawPath(args); 816 pr->drawPath(args);
793 } 817 }
794 818
795 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) { 819 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) {
820 ASSERT_SINGLE_OWNER
796 RETURN_IF_ABANDONED 821 RETURN_IF_ABANDONED
797 SkDEBUGCODE(this->validate();) 822 SkDEBUGCODE(this->validate();)
798 823
799 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); 824 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch);
800 } 825 }
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698