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

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

Issue 1580023002: GrAuditTrail hooks in GrContext + GrDrawContext (Closed) Base URL: https://skia.googlesource.com/skia.git@audittrail-3-gatherframes
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') | src/gpu/GrDrawingManager.cpp » ('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 "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 #include "../private/GrAuditTrail.h"
30
29 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM anager->getContext()) 31 #define ASSERT_OWNED_RESOURCE(R) SkASSERT(!(R) || (R)->getContext() == fDrawingM anager->getContext())
30 #define ASSERT_SINGLE_OWNER \ 32 #define ASSERT_SINGLE_OWNER \
31 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);) 33 SkDEBUGCODE(GrSingleOwner::AutoEnforce debug_SingleOwner(fSingleOwner);)
32 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; } 34 #define RETURN_IF_ABANDONED if (fDrawingManager->abandoned()) { return; }
33 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fa lse; } 35 #define RETURN_FALSE_IF_ABANDONED if (fDrawingManager->abandoned()) { return fa lse; }
34 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nu llptr; } 36 #define RETURN_NULL_IF_ABANDONED if (fDrawingManager->abandoned()) { return nu llptr; }
35 37
36 class AutoCheckFlush { 38 class AutoCheckFlush {
37 public: 39 public:
38 AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingMa nager) { 40 AutoCheckFlush(GrDrawingManager* drawingManager) : fDrawingManager(drawingMa nager) {
39 SkASSERT(fDrawingManager); 41 SkASSERT(fDrawingManager);
40 } 42 }
41 ~AutoCheckFlush() { fDrawingManager->getContext()->flushIfNecessary(); } 43 ~AutoCheckFlush() { fDrawingManager->getContext()->flushIfNecessary(); }
42 44
43 private: 45 private:
44 GrDrawingManager* fDrawingManager; 46 GrDrawingManager* fDrawingManager;
45 }; 47 };
46 48
47 // In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-pr ogress 49 // In MDB mode the reffing of the 'getLastDrawTarget' call's result allows in-pr ogress
48 // drawTargets to be picked up and added to by drawContexts lower in the call 50 // drawTargets to be picked up and added to by drawContexts lower in the call
49 // stack. When this occurs with a closed drawTarget, a new one will be allocated 51 // stack. When this occurs with a closed drawTarget, a new one will be allocated
50 // when the drawContext attempts to use it (via getDrawTarget). 52 // when the drawContext attempts to use it (via getDrawTarget).
51 GrDrawContext::GrDrawContext(GrDrawingManager* drawingMgr, 53 GrDrawContext::GrDrawContext(GrDrawingManager* drawingMgr,
52 GrRenderTarget* rt, 54 GrRenderTarget* rt,
53 const SkSurfaceProps* surfaceProps, 55 const SkSurfaceProps* surfaceProps,
56 GrAuditTrail* auditTrail,
54 GrSingleOwner* singleOwner) 57 GrSingleOwner* singleOwner)
55 : fDrawingManager(drawingMgr) 58 : fDrawingManager(drawingMgr)
56 , fRenderTarget(rt) 59 , fRenderTarget(rt)
57 , fDrawTarget(SkSafeRef(rt->getLastDrawTarget())) 60 , fDrawTarget(SkSafeRef(rt->getLastDrawTarget()))
58 , fTextContext(nullptr) 61 , fTextContext(nullptr)
59 , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps)) 62 , fSurfaceProps(SkSurfacePropsCopyOrDefault(surfaceProps))
63 , fAuditTrail(auditTrail)
60 #ifdef SK_DEBUG 64 #ifdef SK_DEBUG
61 , fSingleOwner(singleOwner) 65 , fSingleOwner(singleOwner)
62 #endif 66 #endif
63 { 67 {
64 SkDEBUGCODE(this->validate();) 68 SkDEBUGCODE(this->validate();)
65 } 69 }
66 70
67 #ifdef SK_DEBUG 71 #ifdef SK_DEBUG
68 void GrDrawContext::validate() const { 72 void GrDrawContext::validate() const {
69 SkASSERT(fRenderTarget); 73 SkASSERT(fRenderTarget);
(...skipping 18 matching lines...) Expand all
88 fDrawTarget = fDrawingManager->newDrawTarget(fRenderTarget); 92 fDrawTarget = fDrawingManager->newDrawTarget(fRenderTarget);
89 } 93 }
90 94
91 return fDrawTarget; 95 return fDrawTarget;
92 } 96 }
93 97
94 void GrDrawContext::copySurface(GrSurface* src, const SkIRect& srcRect, const Sk IPoint& dstPoint) { 98 void GrDrawContext::copySurface(GrSurface* src, const SkIRect& srcRect, const Sk IPoint& dstPoint) {
95 ASSERT_SINGLE_OWNER 99 ASSERT_SINGLE_OWNER
96 RETURN_IF_ABANDONED 100 RETURN_IF_ABANDONED
97 SkDEBUGCODE(this->validate();) 101 SkDEBUGCODE(this->validate();)
102 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::copySurface");
98 103
99 this->getDrawTarget()->copySurface(fRenderTarget, src, srcRect, dstPoint); 104 this->getDrawTarget()->copySurface(fRenderTarget, src, srcRect, dstPoint);
100 } 105 }
101 106
102 void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint, 107 void GrDrawContext::drawText(const GrClip& clip, const GrPaint& grPaint,
103 const SkPaint& skPaint, 108 const SkPaint& skPaint,
104 const SkMatrix& viewMatrix, 109 const SkMatrix& viewMatrix,
105 const char text[], size_t byteLength, 110 const char text[], size_t byteLength,
106 SkScalar x, SkScalar y, const SkIRect& clipBounds) { 111 SkScalar x, SkScalar y, const SkIRect& clipBounds) {
107 ASSERT_SINGLE_OWNER 112 ASSERT_SINGLE_OWNER
108 RETURN_IF_ABANDONED 113 RETURN_IF_ABANDONED
109 SkDEBUGCODE(this->validate();) 114 SkDEBUGCODE(this->validate();)
115 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawText");
110 116
111 if (!fTextContext) { 117 if (!fTextContext) {
112 fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget ); 118 fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget );
113 } 119 }
114 120
115 fTextContext->drawText(this, clip, grPaint, skPaint, viewMatrix, 121 fTextContext->drawText(this, clip, grPaint, skPaint, viewMatrix,
116 text, byteLength, x, y, clipBounds); 122 text, byteLength, x, y, clipBounds);
117 } 123 }
118 124
119 void GrDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint, 125 void GrDrawContext::drawPosText(const GrClip& clip, const GrPaint& grPaint,
120 const SkPaint& skPaint, 126 const SkPaint& skPaint,
121 const SkMatrix& viewMatrix, 127 const SkMatrix& viewMatrix,
122 const char text[], size_t byteLength, 128 const char text[], size_t byteLength,
123 const SkScalar pos[], int scalarsPerPosition, 129 const SkScalar pos[], int scalarsPerPosition,
124 const SkPoint& offset, const SkIRect& clipBounds ) { 130 const SkPoint& offset, const SkIRect& clipBounds ) {
125 ASSERT_SINGLE_OWNER 131 ASSERT_SINGLE_OWNER
126 RETURN_IF_ABANDONED 132 RETURN_IF_ABANDONED
127 SkDEBUGCODE(this->validate();) 133 SkDEBUGCODE(this->validate();)
134 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPosText");
128 135
129 if (!fTextContext) { 136 if (!fTextContext) {
130 fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget ); 137 fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget );
131 } 138 }
132 139
133 fTextContext->drawPosText(this, clip, grPaint, skPaint, viewMatrix, text, by teLength, 140 fTextContext->drawPosText(this, clip, grPaint, skPaint, viewMatrix, text, by teLength,
134 pos, scalarsPerPosition, offset, clipBounds); 141 pos, scalarsPerPosition, offset, clipBounds);
135 142
136 } 143 }
137 144
138 void GrDrawContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint, 145 void GrDrawContext::drawTextBlob(const GrClip& clip, const SkPaint& skPaint,
139 const SkMatrix& viewMatrix, const SkTextBlob* b lob, 146 const SkMatrix& viewMatrix, const SkTextBlob* b lob,
140 SkScalar x, SkScalar y, 147 SkScalar x, SkScalar y,
141 SkDrawFilter* filter, const SkIRect& clipBounds ) { 148 SkDrawFilter* filter, const SkIRect& clipBounds ) {
142 ASSERT_SINGLE_OWNER 149 ASSERT_SINGLE_OWNER
143 RETURN_IF_ABANDONED 150 RETURN_IF_ABANDONED
144 SkDEBUGCODE(this->validate();) 151 SkDEBUGCODE(this->validate();)
152 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawTextBlob");
145 153
146 if (!fTextContext) { 154 if (!fTextContext) {
147 fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget ); 155 fTextContext = fDrawingManager->textContext(fSurfaceProps, fRenderTarget );
148 } 156 }
149 157
150 fTextContext->drawTextBlob(this, clip, skPaint, viewMatrix, blob, x, y, filt er, clipBounds); 158 fTextContext->drawTextBlob(this, clip, skPaint, viewMatrix, blob, x, y, filt er, clipBounds);
151 } 159 }
152 160
153 void GrDrawContext::discard() { 161 void GrDrawContext::discard() {
154 ASSERT_SINGLE_OWNER 162 ASSERT_SINGLE_OWNER
155 RETURN_IF_ABANDONED 163 RETURN_IF_ABANDONED
156 SkDEBUGCODE(this->validate();) 164 SkDEBUGCODE(this->validate();)
165 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::discard");
157 166
158 AutoCheckFlush acf(fDrawingManager); 167 AutoCheckFlush acf(fDrawingManager);
159 this->getDrawTarget()->discard(fRenderTarget); 168 this->getDrawTarget()->discard(fRenderTarget);
160 } 169 }
161 170
162 void GrDrawContext::clear(const SkIRect* rect, 171 void GrDrawContext::clear(const SkIRect* rect,
163 const GrColor color, 172 const GrColor color,
164 bool canIgnoreRect) { 173 bool canIgnoreRect) {
165 ASSERT_SINGLE_OWNER 174 ASSERT_SINGLE_OWNER
166 RETURN_IF_ABANDONED 175 RETURN_IF_ABANDONED
167 SkDEBUGCODE(this->validate();) 176 SkDEBUGCODE(this->validate();)
177 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::clear");
168 178
169 AutoCheckFlush acf(fDrawingManager); 179 AutoCheckFlush acf(fDrawingManager);
170 this->getDrawTarget()->clear(rect, color, canIgnoreRect, fRenderTarget); 180 this->getDrawTarget()->clear(rect, color, canIgnoreRect, fRenderTarget);
171 } 181 }
172 182
173 183
174 void GrDrawContext::drawPaint(const GrClip& clip, 184 void GrDrawContext::drawPaint(const GrClip& clip,
175 const GrPaint& origPaint, 185 const GrPaint& origPaint,
176 const SkMatrix& viewMatrix) { 186 const SkMatrix& viewMatrix) {
177 ASSERT_SINGLE_OWNER 187 ASSERT_SINGLE_OWNER
178 RETURN_IF_ABANDONED 188 RETURN_IF_ABANDONED
179 SkDEBUGCODE(this->validate();) 189 SkDEBUGCODE(this->validate();)
190 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPaint");
180 191
181 // set rect to be big enough to fill the space, but not super-huge, so we 192 // set rect to be big enough to fill the space, but not super-huge, so we
182 // don't overflow fixed-point implementations 193 // don't overflow fixed-point implementations
183 SkRect r; 194 SkRect r;
184 r.setLTRB(0, 0, 195 r.setLTRB(0, 0,
185 SkIntToScalar(fRenderTarget->width()), 196 SkIntToScalar(fRenderTarget->width()),
186 SkIntToScalar(fRenderTarget->height())); 197 SkIntToScalar(fRenderTarget->height()));
187 SkTCopyOnFirstWrite<GrPaint> paint(origPaint); 198 SkTCopyOnFirstWrite<GrPaint> paint(origPaint);
188 199
189 // by definition this fills the entire clip, no need for AA 200 // by definition this fills the entire clip, no need for AA
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 247 }
237 248
238 void GrDrawContext::drawRect(const GrClip& clip, 249 void GrDrawContext::drawRect(const GrClip& clip,
239 const GrPaint& paint, 250 const GrPaint& paint,
240 const SkMatrix& viewMatrix, 251 const SkMatrix& viewMatrix,
241 const SkRect& rect, 252 const SkRect& rect,
242 const GrStrokeInfo* strokeInfo) { 253 const GrStrokeInfo* strokeInfo) {
243 ASSERT_SINGLE_OWNER 254 ASSERT_SINGLE_OWNER
244 RETURN_IF_ABANDONED 255 RETURN_IF_ABANDONED
245 SkDEBUGCODE(this->validate();) 256 SkDEBUGCODE(this->validate();)
257 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRect");
246 258
247 // Dashing should've been devolved to a path in SkGpuDevice 259 // Dashing should've been devolved to a path in SkGpuDevice
248 SkASSERT(!strokeInfo || !strokeInfo->isDashed()); 260 SkASSERT(!strokeInfo || !strokeInfo->isDashed());
249 261
250 AutoCheckFlush acf(fDrawingManager); 262 AutoCheckFlush acf(fDrawingManager);
251 263
252 SkScalar width = nullptr == strokeInfo ? -1 : strokeInfo->getWidth(); 264 SkScalar width = nullptr == strokeInfo ? -1 : strokeInfo->getWidth();
253 265
254 // Check if this is a full RT draw and can be replaced with a clear. We don' t bother checking 266 // Check if this is a full RT draw and can be replaced with a clear. We don' t bother checking
255 // cases where the RT is fully inside a stroke. 267 // cases where the RT is fully inside a stroke.
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 } 348 }
337 349
338 void GrDrawContext::fillRectToRect(const GrClip& clip, 350 void GrDrawContext::fillRectToRect(const GrClip& clip,
339 const GrPaint& paint, 351 const GrPaint& paint,
340 const SkMatrix& viewMatrix, 352 const SkMatrix& viewMatrix,
341 const SkRect& rectToDraw, 353 const SkRect& rectToDraw,
342 const SkRect& localRect) { 354 const SkRect& localRect) {
343 ASSERT_SINGLE_OWNER 355 ASSERT_SINGLE_OWNER
344 RETURN_IF_ABANDONED 356 RETURN_IF_ABANDONED
345 SkDEBUGCODE(this->validate();) 357 SkDEBUGCODE(this->validate();)
358 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectToRect");
346 359
347 AutoCheckFlush acf(fDrawingManager); 360 AutoCheckFlush acf(fDrawingManager);
348 361
349 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 362 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
350 if (should_apply_coverage_aa(paint, fRenderTarget) && 363 if (should_apply_coverage_aa(paint, fRenderTarget) &&
351 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { 364 view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
352 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::CreateWithLocalRect( 365 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::CreateWithLocalRect(
353 paint.getColor(), viewMatrix, rectToDraw, localRect)); 366 paint.getColor(), viewMatrix, rectToDraw, localRect));
354 if (batch) { 367 if (batch) {
355 this->drawBatch(&pipelineBuilder, batch); 368 this->drawBatch(&pipelineBuilder, batch);
356 } 369 }
357 } else { 370 } else {
358 this->getDrawTarget()->drawNonAARect(pipelineBuilder, 371 this->getDrawTarget()->drawNonAARect(pipelineBuilder,
359 paint.getColor(), 372 paint.getColor(),
360 viewMatrix, 373 viewMatrix,
361 rectToDraw, 374 rectToDraw,
362 localRect); 375 localRect);
363 } 376 }
364 } 377 }
365 378
366 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip, 379 void GrDrawContext::fillRectWithLocalMatrix(const GrClip& clip,
367 const GrPaint& paint, 380 const GrPaint& paint,
368 const SkMatrix& viewMatrix, 381 const SkMatrix& viewMatrix,
369 const SkRect& rectToDraw, 382 const SkRect& rectToDraw,
370 const SkMatrix& localMatrix) { 383 const SkMatrix& localMatrix) {
371 ASSERT_SINGLE_OWNER 384 ASSERT_SINGLE_OWNER
372 RETURN_IF_ABANDONED 385 RETURN_IF_ABANDONED
373 SkDEBUGCODE(this->validate();) 386 SkDEBUGCODE(this->validate();)
387 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::fillRectWithLocalMatr ix");
374 388
375 AutoCheckFlush acf(fDrawingManager); 389 AutoCheckFlush acf(fDrawingManager);
376 390
377 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 391 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
378 392
379 if (should_apply_coverage_aa(paint, fRenderTarget) && 393 if (should_apply_coverage_aa(paint, fRenderTarget) &&
380 view_matrix_ok_for_aa_fill_rect(viewMatrix)) { 394 view_matrix_ok_for_aa_fill_rect(viewMatrix)) {
381 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::Create( 395 SkAutoTUnref<GrDrawBatch> batch(GrAAFillRectBatch::Create(
382 paint.getColor(), viewMatrix, localMatrix, rectToDraw)); 396 paint.getColor(), viewMatrix, localMatrix, rectToDraw));
383 this->drawBatch(&pipelineBuilder, batch); 397 this->drawBatch(&pipelineBuilder, batch);
(...skipping 12 matching lines...) Expand all
396 GrPrimitiveType primitiveType, 410 GrPrimitiveType primitiveType,
397 int vertexCount, 411 int vertexCount,
398 const SkPoint positions[], 412 const SkPoint positions[],
399 const SkPoint texCoords[], 413 const SkPoint texCoords[],
400 const GrColor colors[], 414 const GrColor colors[],
401 const uint16_t indices[], 415 const uint16_t indices[],
402 int indexCount) { 416 int indexCount) {
403 ASSERT_SINGLE_OWNER 417 ASSERT_SINGLE_OWNER
404 RETURN_IF_ABANDONED 418 RETURN_IF_ABANDONED
405 SkDEBUGCODE(this->validate();) 419 SkDEBUGCODE(this->validate();)
420 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawVertices");
406 421
407 AutoCheckFlush acf(fDrawingManager); 422 AutoCheckFlush acf(fDrawingManager);
408 423
409 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 424 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
410 425
411 // TODO clients should give us bounds 426 // TODO clients should give us bounds
412 SkRect bounds; 427 SkRect bounds;
413 if (!bounds.setBoundsCheck(positions, vertexCount)) { 428 if (!bounds.setBoundsCheck(positions, vertexCount)) {
414 SkDebugf("drawVertices call empty bounds\n"); 429 SkDebugf("drawVertices call empty bounds\n");
415 return; 430 return;
(...skipping 24 matching lines...) Expand all
440 void GrDrawContext::drawAtlas(const GrClip& clip, 455 void GrDrawContext::drawAtlas(const GrClip& clip,
441 const GrPaint& paint, 456 const GrPaint& paint,
442 const SkMatrix& viewMatrix, 457 const SkMatrix& viewMatrix,
443 int spriteCount, 458 int spriteCount,
444 const SkRSXform xform[], 459 const SkRSXform xform[],
445 const SkRect texRect[], 460 const SkRect texRect[],
446 const SkColor colors[]) { 461 const SkColor colors[]) {
447 ASSERT_SINGLE_OWNER 462 ASSERT_SINGLE_OWNER
448 RETURN_IF_ABANDONED 463 RETURN_IF_ABANDONED
449 SkDEBUGCODE(this->validate();) 464 SkDEBUGCODE(this->validate();)
465 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawAtlas");
450 466
451 AutoCheckFlush acf(fDrawingManager); 467 AutoCheckFlush acf(fDrawingManager);
452 468
453 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 469 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
454 470
455 GrDrawAtlasBatch::Geometry geometry; 471 GrDrawAtlasBatch::Geometry geometry;
456 geometry.fColor = paint.getColor(); 472 geometry.fColor = paint.getColor();
457 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri x, spriteCount, 473 SkAutoTUnref<GrDrawBatch> batch(GrDrawAtlasBatch::Create(geometry, viewMatri x, spriteCount,
458 xform, texRect, col ors)); 474 xform, texRect, col ors));
459 475
460 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 476 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
461 } 477 }
462 478
463 /////////////////////////////////////////////////////////////////////////////// 479 ///////////////////////////////////////////////////////////////////////////////
464 480
465 void GrDrawContext::drawRRect(const GrClip& clip, 481 void GrDrawContext::drawRRect(const GrClip& clip,
466 const GrPaint& paint, 482 const GrPaint& paint,
467 const SkMatrix& viewMatrix, 483 const SkMatrix& viewMatrix,
468 const SkRRect& rrect, 484 const SkRRect& rrect,
469 const GrStrokeInfo& strokeInfo) { 485 const GrStrokeInfo& strokeInfo) {
470 ASSERT_SINGLE_OWNER 486 ASSERT_SINGLE_OWNER
471 RETURN_IF_ABANDONED 487 RETURN_IF_ABANDONED
472 SkDEBUGCODE(this->validate();) 488 SkDEBUGCODE(this->validate();)
489 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawRRect");
473 490
474 if (rrect.isEmpty()) { 491 if (rrect.isEmpty()) {
475 return; 492 return;
476 } 493 }
477 494
478 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path in SkGpuDevice 495 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path in SkGpuDevice
479 496
480 AutoCheckFlush acf(fDrawingManager); 497 AutoCheckFlush acf(fDrawingManager);
481 498
482 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 499 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
(...skipping 17 matching lines...) Expand all
500 /////////////////////////////////////////////////////////////////////////////// 517 ///////////////////////////////////////////////////////////////////////////////
501 518
502 void GrDrawContext::drawDRRect(const GrClip& clip, 519 void GrDrawContext::drawDRRect(const GrClip& clip,
503 const GrPaint& paint, 520 const GrPaint& paint,
504 const SkMatrix& viewMatrix, 521 const SkMatrix& viewMatrix,
505 const SkRRect& outer, 522 const SkRRect& outer,
506 const SkRRect& inner) { 523 const SkRRect& inner) {
507 ASSERT_SINGLE_OWNER 524 ASSERT_SINGLE_OWNER
508 RETURN_IF_ABANDONED 525 RETURN_IF_ABANDONED
509 SkDEBUGCODE(this->validate();) 526 SkDEBUGCODE(this->validate();)
527 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawDRRect");
510 528
511 if (outer.isEmpty()) { 529 if (outer.isEmpty()) {
512 return; 530 return;
513 } 531 }
514 532
515 AutoCheckFlush acf(fDrawingManager); 533 AutoCheckFlush acf(fDrawingManager);
516 534
517 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 535 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
518 GrColor color = paint.getColor(); 536 GrColor color = paint.getColor();
519 if (!GrOvalRenderer::DrawDRRect(this->getDrawTarget(), 537 if (!GrOvalRenderer::DrawDRRect(this->getDrawTarget(),
(...skipping 18 matching lines...) Expand all
538 /////////////////////////////////////////////////////////////////////////////// 556 ///////////////////////////////////////////////////////////////////////////////
539 557
540 void GrDrawContext::drawOval(const GrClip& clip, 558 void GrDrawContext::drawOval(const GrClip& clip,
541 const GrPaint& paint, 559 const GrPaint& paint,
542 const SkMatrix& viewMatrix, 560 const SkMatrix& viewMatrix,
543 const SkRect& oval, 561 const SkRect& oval,
544 const GrStrokeInfo& strokeInfo) { 562 const GrStrokeInfo& strokeInfo) {
545 ASSERT_SINGLE_OWNER 563 ASSERT_SINGLE_OWNER
546 RETURN_IF_ABANDONED 564 RETURN_IF_ABANDONED
547 SkDEBUGCODE(this->validate();) 565 SkDEBUGCODE(this->validate();)
566 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawOval");
548 567
549 if (oval.isEmpty()) { 568 if (oval.isEmpty()) {
550 return; 569 return;
551 } 570 }
552 571
553 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path in SkGpuDevice 572 SkASSERT(!strokeInfo.isDashed()); // this should've been devolved to a path in SkGpuDevice
554 573
555 AutoCheckFlush acf(fDrawingManager); 574 AutoCheckFlush acf(fDrawingManager);
556 575
557 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 576 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
(...skipping 17 matching lines...) Expand all
575 void GrDrawContext::drawImageNine(const GrClip& clip, 594 void GrDrawContext::drawImageNine(const GrClip& clip,
576 const GrPaint& paint, 595 const GrPaint& paint,
577 const SkMatrix& viewMatrix, 596 const SkMatrix& viewMatrix,
578 int imageWidth, 597 int imageWidth,
579 int imageHeight, 598 int imageHeight,
580 const SkIRect& center, 599 const SkIRect& center,
581 const SkRect& dst) { 600 const SkRect& dst) {
582 ASSERT_SINGLE_OWNER 601 ASSERT_SINGLE_OWNER
583 RETURN_IF_ABANDONED 602 RETURN_IF_ABANDONED
584 SkDEBUGCODE(this->validate();) 603 SkDEBUGCODE(this->validate();)
604 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawImageNine");
585 605
586 AutoCheckFlush acf(fDrawingManager); 606 AutoCheckFlush acf(fDrawingManager);
587 607
588 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v iewMatrix, 608 SkAutoTUnref<GrDrawBatch> batch(GrNinePatch::CreateNonAA(paint.getColor(), v iewMatrix,
589 imageWidth, imageHe ight, 609 imageWidth, imageHe ight,
590 center, dst)); 610 center, dst));
591 611
592 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 612 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
593 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 613 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
594 } 614 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 } 662 }
643 663
644 return allEq || allGoE1; 664 return allEq || allGoE1;
645 } 665 }
646 666
647 void GrDrawContext::drawBatch(const GrClip& clip, 667 void GrDrawContext::drawBatch(const GrClip& clip,
648 const GrPaint& paint, GrDrawBatch* batch) { 668 const GrPaint& paint, GrDrawBatch* batch) {
649 ASSERT_SINGLE_OWNER 669 ASSERT_SINGLE_OWNER
650 RETURN_IF_ABANDONED 670 RETURN_IF_ABANDONED
651 SkDEBUGCODE(this->validate();) 671 SkDEBUGCODE(this->validate();)
672 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch");
652 673
653 AutoCheckFlush acf(fDrawingManager); 674 AutoCheckFlush acf(fDrawingManager);
654 675
655 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip); 676 GrPipelineBuilder pipelineBuilder(paint, fRenderTarget, clip);
656 this->getDrawTarget()->drawBatch(pipelineBuilder, batch); 677 this->getDrawTarget()->drawBatch(pipelineBuilder, batch);
657 } 678 }
658 679
659 void GrDrawContext::drawPathBatch(const GrPipelineBuilder& pipelineBuilder, 680 void GrDrawContext::drawPathBatch(const GrPipelineBuilder& pipelineBuilder,
660 GrDrawPathBatchBase* batch) { 681 GrDrawPathBatchBase* batch) {
661 ASSERT_SINGLE_OWNER 682 ASSERT_SINGLE_OWNER
662 RETURN_IF_ABANDONED 683 RETURN_IF_ABANDONED
663 SkDEBUGCODE(this->validate();) 684 SkDEBUGCODE(this->validate();)
685 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPathBatch");
664 686
665 AutoCheckFlush acf(fDrawingManager); 687 AutoCheckFlush acf(fDrawingManager);
666 688
667 this->getDrawTarget()->drawPathBatch(pipelineBuilder, batch); 689 this->getDrawTarget()->drawPathBatch(pipelineBuilder, batch);
668 } 690 }
669 691
670 void GrDrawContext::drawPath(const GrClip& clip, 692 void GrDrawContext::drawPath(const GrClip& clip,
671 const GrPaint& paint, 693 const GrPaint& paint,
672 const SkMatrix& viewMatrix, 694 const SkMatrix& viewMatrix,
673 const SkPath& path, 695 const SkPath& path,
674 const GrStrokeInfo& strokeInfo) { 696 const GrStrokeInfo& strokeInfo) {
675 ASSERT_SINGLE_OWNER 697 ASSERT_SINGLE_OWNER
676 RETURN_IF_ABANDONED 698 RETURN_IF_ABANDONED
677 SkDEBUGCODE(this->validate();) 699 SkDEBUGCODE(this->validate();)
700 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawPath");
678 701
679 if (path.isEmpty()) { 702 if (path.isEmpty()) {
680 if (path.isInverseFillType()) { 703 if (path.isInverseFillType()) {
681 this->drawPaint(clip, paint, viewMatrix); 704 this->drawPaint(clip, paint, viewMatrix);
682 } 705 }
683 return; 706 return;
684 } 707 }
685 708
686 GrColor color = paint.getColor(); 709 GrColor color = paint.getColor();
687 710
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
825 args.fPath = pathPtr; 848 args.fPath = pathPtr;
826 args.fStroke = strokeInfoPtr; 849 args.fStroke = strokeInfoPtr;
827 args.fAntiAlias = useCoverageAA; 850 args.fAntiAlias = useCoverageAA;
828 pr->drawPath(args); 851 pr->drawPath(args);
829 } 852 }
830 853
831 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) { 854 void GrDrawContext::drawBatch(GrPipelineBuilder* pipelineBuilder, GrDrawBatch* b atch) {
832 ASSERT_SINGLE_OWNER 855 ASSERT_SINGLE_OWNER
833 RETURN_IF_ABANDONED 856 RETURN_IF_ABANDONED
834 SkDEBUGCODE(this->validate();) 857 SkDEBUGCODE(this->validate();)
858 GR_AUDIT_TRAIL_AUTO_FRAME(fAuditTrail, "GrDrawContext::drawBatch");
835 859
836 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch); 860 this->getDrawTarget()->drawBatch(*pipelineBuilder, batch);
837 } 861 }
OLDNEW
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | src/gpu/GrDrawingManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698