OLD | NEW |
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 #ifndef GrDrawContext_DEFINED | 8 #ifndef GrDrawContext_DEFINED |
9 #define GrDrawContext_DEFINED | 9 #define GrDrawContext_DEFINED |
10 | 10 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
251 const SkRect& dst); | 251 const SkRect& dst); |
252 | 252 |
253 /** | 253 /** |
254 * Draws a batch | 254 * Draws a batch |
255 * | 255 * |
256 * @param paint describes how to color pixels. | 256 * @param paint describes how to color pixels. |
257 * @param batch the batch to draw | 257 * @param batch the batch to draw |
258 */ | 258 */ |
259 void drawBatch(const GrClip&, const GrPaint&, GrDrawBatch*); | 259 void drawBatch(const GrClip&, const GrPaint&, GrDrawBatch*); |
260 | 260 |
| 261 bool isStencilBufferMultisampled() const { |
| 262 return fRenderTarget->isStencilBufferMultisampled(); |
| 263 } |
261 bool hasMixedSamples() const { return fRenderTarget->hasMixedSamples(); } | 264 bool hasMixedSamples() const { return fRenderTarget->hasMixedSamples(); } |
262 | 265 |
263 const GrSurfaceDesc& desc() const { return fRenderTarget->desc(); } | 266 const GrSurfaceDesc& desc() const { return fRenderTarget->desc(); } |
264 int width() const { return fRenderTarget->width(); } | 267 int width() const { return fRenderTarget->width(); } |
265 int height() const { return fRenderTarget->height(); } | 268 int height() const { return fRenderTarget->height(); } |
266 GrPixelConfig config() const { return fRenderTarget->config(); } | 269 GrPixelConfig config() const { return fRenderTarget->config(); } |
267 bool isUnifiedMultisampled() const { return fRenderTarget->isUnifiedMultisam
pled(); } | 270 bool isUnifiedMultisampled() const { return fRenderTarget->isUnifiedMultisam
pled(); } |
268 int numColorSamples() const { return fRenderTarget->numColorSamples(); } | 271 int numColorSamples() const { return fRenderTarget->numColorSamples(); } |
269 bool isGammaCorrect() const { return fSurfaceProps.isGammaCorrect(); } | 272 bool isGammaCorrect() const { return fSurfaceProps.isGammaCorrect(); } |
270 const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } | 273 const SkSurfaceProps& surfaceProps() const { return fSurfaceProps; } |
271 | 274 |
272 bool wasAbandoned() const; | 275 bool wasAbandoned() const; |
273 | 276 |
274 GrRenderTarget* accessRenderTarget() { return fRenderTarget.get(); } | 277 GrRenderTarget* accessRenderTarget() { return fRenderTarget.get(); } |
275 | 278 |
276 sk_sp<GrRenderTarget> renderTarget() { return fRenderTarget; } | 279 sk_sp<GrRenderTarget> renderTarget() { return fRenderTarget; } |
277 | 280 |
278 sk_sp<GrTexture> asTexture() { return sk_ref_sp(fRenderTarget->asTexture());
} | 281 sk_sp<GrTexture> asTexture() { return sk_ref_sp(fRenderTarget->asTexture());
} |
279 | 282 |
280 // Provides access to functions that aren't part of the public API. | 283 // Provides access to functions that aren't part of the public API. |
281 GrDrawContextPriv drawContextPriv(); | 284 GrDrawContextPriv drawContextPriv(); |
282 const GrDrawContextPriv drawContextPriv() const; | 285 const GrDrawContextPriv drawContextPriv() const; |
283 | 286 |
| 287 GrAuditTrail* auditTrail() { return fAuditTrail; } |
| 288 |
284 protected: | 289 protected: |
285 GrDrawContext(GrContext*, GrDrawingManager*, sk_sp<GrRenderTarget>, | 290 GrDrawContext(GrContext*, GrDrawingManager*, sk_sp<GrRenderTarget>, |
286 const SkSurfaceProps* surfaceProps, GrAuditTrail*, GrSingleOwn
er*); | 291 const SkSurfaceProps* surfaceProps, GrAuditTrail*, GrSingleOwn
er*); |
287 | 292 |
288 GrDrawingManager* drawingManager() { return fDrawingManager; } | 293 GrDrawingManager* drawingManager() { return fDrawingManager; } |
289 GrAuditTrail* auditTrail() { return fAuditTrail; } | |
290 | 294 |
291 SkDEBUGCODE(GrSingleOwner* singleOwner() { return fSingleOwner; }) | 295 SkDEBUGCODE(GrSingleOwner* singleOwner() { return fSingleOwner; }) |
292 SkDEBUGCODE(void validate() const;) | 296 SkDEBUGCODE(void validate() const;) |
293 | 297 |
294 private: | 298 private: |
295 friend class GrAtlasTextBlob; // for access to drawBatch | 299 friend class GrAtlasTextBlob; // for access to drawBatch |
296 friend class GrStencilAndCoverTextContext; // for access to drawBatch | 300 friend class GrStencilAndCoverTextContext; // for access to drawBatch |
297 friend class GrDrawingManager; // for ctor | 301 friend class GrDrawingManager; // for ctor |
298 friend class GrDrawContextPriv; | 302 friend class GrDrawContextPriv; |
299 friend class GrTestTarget; // for access to getDrawTarget | 303 friend class GrTestTarget; // for access to getDrawTarget |
| 304 friend class GrSWMaskHelper; // for access to drawBatch |
| 305 friend class GrClipMaskManager; // for access to drawBatch |
| 306 |
| 307 // All the path renderers currently make their own batches |
| 308 friend class GrSoftwarePathRenderer; // for access to drawBatch |
| 309 friend class GrAAConvexPathRenderer; // for access to drawBatch |
| 310 friend class GrDashLinePathRenderer; // for access to drawBatch |
| 311 friend class GrAAHairLinePathRenderer; // for access to drawBatch |
| 312 friend class GrAALinearizingConvexPathRenderer; // for access to drawBatch |
| 313 friend class GrAADistanceFieldPathRenderer; // for access to drawBatch |
| 314 friend class GrDefaultPathRenderer; // for access to drawBatch |
| 315 friend class GrPLSPathRenderer; // for access to drawBatch |
| 316 friend class GrMSAAPathRenderer; // for access to drawBatch |
| 317 friend class GrStencilAndCoverPathRenderer; // for access to drawBatch |
| 318 friend class GrTessellatingPathRenderer; // for access to drawBatch |
300 | 319 |
301 bool drawFilledDRRect(const GrClip& clip, | 320 bool drawFilledDRRect(const GrClip& clip, |
302 const GrPaint& paint, | 321 const GrPaint& paint, |
303 const SkMatrix& viewMatrix, | 322 const SkMatrix& viewMatrix, |
304 const SkRRect& origOuter, | 323 const SkRRect& origOuter, |
305 const SkRRect& origInner); | 324 const SkRRect& origInner); |
306 | 325 |
307 GrDrawBatch* getFillRectBatch(const GrPaint& paint, | 326 GrDrawBatch* getFillRectBatch(const GrPaint& paint, |
308 const SkMatrix& viewMatrix, | 327 const SkMatrix& viewMatrix, |
309 const SkRect& rect); | 328 const SkRect& rect); |
310 | 329 |
311 void internalDrawPath(const GrClip& clip, | 330 void internalDrawPath(const GrClip& clip, |
312 const GrPaint& paint, | 331 const GrPaint& paint, |
313 const SkMatrix& viewMatrix, | 332 const SkMatrix& viewMatrix, |
314 const SkPath& path, | 333 const SkPath& path, |
315 const GrStyle& style); | 334 const GrStyle& style); |
316 | 335 |
317 // This entry point allows the GrTextContext-derived classes to add their ba
tches to | 336 // This entry point allows the GrTextContext-derived classes to add their ba
tches to |
318 // the drawTarget. | 337 // the drawTarget. |
319 void drawBatch(GrPipelineBuilder* pipelineBuilder, const GrClip&, GrDrawBatc
h* batch); | 338 void drawBatch(const GrPipelineBuilder& pipelineBuilder, const GrClip&, GrDr
awBatch* batch); |
320 | 339 |
321 GrDrawTarget* getDrawTarget(); | 340 GrDrawTarget* getDrawTarget(); |
322 | 341 |
323 GrDrawingManager* fDrawingManager; | 342 GrDrawingManager* fDrawingManager; |
324 sk_sp<GrRenderTarget> fRenderTarget; | 343 sk_sp<GrRenderTarget> fRenderTarget; |
325 | 344 |
326 // In MDB-mode the drawTarget can be closed by some other drawContext that h
as picked | 345 // In MDB-mode the drawTarget can be closed by some other drawContext that h
as picked |
327 // it up. For this reason, the drawTarget should only ever be accessed via '
getDrawTarget'. | 346 // it up. For this reason, the drawTarget should only ever be accessed via '
getDrawTarget'. |
328 GrDrawTarget* fDrawTarget; | 347 GrDrawTarget* fDrawTarget; |
329 SkAutoTDelete<GrAtlasTextContext> fAtlasTextContext; | 348 SkAutoTDelete<GrAtlasTextContext> fAtlasTextContext; |
330 GrContext* fContext; | 349 GrContext* fContext; |
331 | 350 |
332 SkSurfaceProps fSurfaceProps; | 351 SkSurfaceProps fSurfaceProps; |
333 GrAuditTrail* fAuditTrail; | 352 GrAuditTrail* fAuditTrail; |
334 | 353 |
335 // In debug builds we guard against improper thread handling | 354 // In debug builds we guard against improper thread handling |
336 SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;) | 355 SkDEBUGCODE(mutable GrSingleOwner* fSingleOwner;) |
337 }; | 356 }; |
338 | 357 |
339 #endif | 358 #endif |
OLD | NEW |