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

Side by Side Diff: src/gpu/GrGpu.h

Issue 705593002: Refactor DrawTarget and GPU to be independent (Closed) Base URL: https://skia.googlesource.com/skia.git@early_clip
Patch Set: rebase on master Created 6 years, 1 month 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/GrDrawTarget.h ('k') | src/gpu/GrGpu.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 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 GrGpu_DEFINED 8 #ifndef GrGpu_DEFINED
9 #define GrGpu_DEFINED 9 #define GrGpu_DEFINED
10 10
11 #include "GrDrawTarget.h" 11 #include "GrDrawTarget.h"
12 #include "GrPathRendering.h" 12 #include "GrPathRendering.h"
13 #include "GrProgramDesc.h" 13 #include "GrProgramDesc.h"
14 #include "SkPath.h" 14 #include "SkPath.h"
15 15
16 class GrContext; 16 class GrContext;
17 class GrIndexBufferAllocPool; 17 class GrIndexBufferAllocPool;
18 class GrPath; 18 class GrPath;
19 class GrPathRange; 19 class GrPathRange;
20 class GrPathRenderer; 20 class GrPathRenderer;
21 class GrPathRendererChain; 21 class GrPathRendererChain;
22 class GrStencilBuffer; 22 class GrStencilBuffer;
23 class GrVertexBufferAllocPool; 23 class GrVertexBufferAllocPool;
24 24
25 class GrGpu : public GrClipTarget { 25 class GrGpu : public SkRefCnt {
26 public: 26 public:
27 27
28 /** 28 /**
29 * Additional blend coefficients for dual source blending, not exposed 29 * Additional blend coefficients for dual source blending, not exposed
30 * through GrPaint/GrContext. 30 * through GrPaint/GrContext.
31 */ 31 */
32 enum ExtendedBlendCoeffs { 32 enum ExtendedBlendCoeffs {
33 // source 2 refers to second output color when 33 // source 2 refers to second output color when
34 // using dual source blending. 34 // using dual source blending.
35 kS2C_GrBlendCoeff = kPublicGrBlendCoeffCount, 35 kS2C_GrBlendCoeff = kPublicGrBlendCoeffCount,
36 kIS2C_GrBlendCoeff, 36 kIS2C_GrBlendCoeff,
37 kS2A_GrBlendCoeff, 37 kS2A_GrBlendCoeff,
38 kIS2A_GrBlendCoeff, 38 kIS2A_GrBlendCoeff,
39 39
40 kTotalGrBlendCoeffCount 40 kTotalGrBlendCoeffCount
41 }; 41 };
42 42
43 /** 43 /**
44 * Create an instance of GrGpu that matches the specified backend. If the re quested backend is 44 * Create an instance of GrGpu that matches the specified backend. If the re quested backend is
45 * not supported (at compile-time or run-time) this returns NULL. The contex t will not be 45 * not supported (at compile-time or run-time) this returns NULL. The contex t will not be
46 * fully constructed and should not be used by GrGpu until after this functi on returns. 46 * fully constructed and should not be used by GrGpu until after this functi on returns.
47 */ 47 */
48 static GrGpu* Create(GrBackend, GrBackendContext, GrContext* context); 48 static GrGpu* Create(GrBackend, GrBackendContext, GrContext* context);
49 49
50 //////////////////////////////////////////////////////////////////////////// 50 ////////////////////////////////////////////////////////////////////////////
51 51
52 GrGpu(GrContext* context); 52 GrGpu(GrContext* context);
53 virtual ~GrGpu(); 53 virtual ~GrGpu();
54 54
55 GrContext* getContext() { return this->INHERITED::getContext(); } 55 GrContext* getContext() { return fContext; }
56 const GrContext* getContext() const { return this->INHERITED::getContext(); } 56 const GrContext* getContext() const { return fContext; }
57
58 /**
59 * Gets the capabilities of the draw target.
60 */
61 const GrDrawTargetCaps* caps() const { return fCaps.get(); }
62
63 /**
64 * Sets the draw state object for the gpu. Note that this does not
65 * make a copy. The GrGpu will take a reference to passed object.
66 * Passing NULL will cause the GrGpu to use its own internal draw
67 * state object rather than an externally provided one.
68 */
69 void setDrawState(GrDrawState* drawState);
70
71 /**
72 * Read-only access to the GrGpu current draw state.
73 */
74 const GrDrawState& getDrawState() const { return *fDrawState; }
75
76 /**
77 * Read-write access to the GrGpu current draw state. Note that
78 * this doesn't ref.
79 */
80 GrDrawState* drawState() { return fDrawState; }
57 81
58 GrPathRendering* pathRendering() { 82 GrPathRendering* pathRendering() {
59 return fPathRendering.get(); 83 return fPathRendering.get();
60 } 84 }
61 85
62 // Called by GrContext when the underlying backend context has been destroye d. 86 // Called by GrContext when the underlying backend context has been destroye d.
63 // GrGpu should use this to ensure that no backend API calls will be made fr om 87 // GrGpu should use this to ensure that no backend API calls will be made fr om
64 // here onward, including in its destructor. Subclasses should call 88 // here onward, including in its destructor. Subclasses should call
65 // INHERITED::contextAbandoned() if they override this. 89 // INHERITED::contextAbandoned() if they override this.
66 virtual void contextAbandoned(); 90 virtual void contextAbandoned();
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 * @param config the pixel config of the source buffer 282 * @param config the pixel config of the source buffer
259 * @param buffer memory to read pixels from 283 * @param buffer memory to read pixels from
260 * @param rowBytes number of bytes between consecutive rows. Zero 284 * @param rowBytes number of bytes between consecutive rows. Zero
261 * means rows are tightly packed. 285 * means rows are tightly packed.
262 */ 286 */
263 bool writeTexturePixels(GrTexture* texture, 287 bool writeTexturePixels(GrTexture* texture,
264 int left, int top, int width, int height, 288 int left, int top, int width, int height,
265 GrPixelConfig config, const void* buffer, 289 GrPixelConfig config, const void* buffer,
266 size_t rowBytes); 290 size_t rowBytes);
267 291
268 // GrDrawTarget overrides 292 /**
269 virtual void clearStencilClip(const SkIRect& rect, 293 * Clear the passed in render target. Ignores the draw state and clip. Clear s the whole thing if
270 bool insideClip, 294 * rect is NULL, otherwise just the rect. If canIgnoreRect is set then the e ntire render target
271 GrRenderTarget* renderTarget = NULL) SK_OVERRI DE; 295 * can be optionally cleared.
296 */
297 void clear(const SkIRect* rect,
298 GrColor color,
299 bool canIgnoreRect,
300 GrRenderTarget* renderTarget);
301
302
303 void clearStencilClip(const SkIRect& rect,
304 bool insideClip,
305 GrRenderTarget* renderTarget = NULL);
306
307 /**
308 * Discards the contents render target. NULL indicates that the current rend er target should
309 * be discarded.
310 **/
311 virtual void discard(GrRenderTarget* = NULL) = 0;
312
313 /**
314 * This is can be called before allocating a texture to be a dst for copySur face. It will
315 * populate the origin, config, and flags fields of the desc such that copyS urface is more
316 * likely to succeed and be efficient.
317 */
318 virtual void initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* des c);
272 319
273 // After the client interacts directly with the 3D context state the GrGpu 320 // After the client interacts directly with the 3D context state the GrGpu
274 // must resync its internal state and assumptions about 3D context state. 321 // must resync its internal state and assumptions about 3D context state.
275 // Each time this occurs the GrGpu bumps a timestamp. 322 // Each time this occurs the GrGpu bumps a timestamp.
276 // state of the 3D context 323 // state of the 3D context
277 // At 10 resets / frame and 60fps a 64bit timestamp will overflow in about 324 // At 10 resets / frame and 60fps a 64bit timestamp will overflow in about
278 // a billion years. 325 // a billion years.
279 typedef uint64_t ResetTimestamp; 326 typedef uint64_t ResetTimestamp;
280 327
281 // This timestamp is always older than the current timestamp 328 // This timestamp is always older than the current timestamp
(...skipping 19 matching lines...) Expand all
301 } 348 }
302 349
303 GrContext::GPUStats* gpuStats() { return &fGPUStats; } 350 GrContext::GPUStats* gpuStats() { return &fGPUStats; }
304 351
305 virtual void buildProgramDesc(const GrOptDrawState&, 352 virtual void buildProgramDesc(const GrOptDrawState&,
306 const GrProgramDesc::DescInfo&, 353 const GrProgramDesc::DescInfo&,
307 GrGpu::DrawType, 354 GrGpu::DrawType,
308 const GrDeviceCoordTexture* dstCopy, 355 const GrDeviceCoordTexture* dstCopy,
309 GrProgramDesc*) = 0; 356 GrProgramDesc*) = 0;
310 357
358 /**
359 * Called at start and end of gpu trace marking
360 * GR_CREATE_GPU_TRACE_MARKER(marker_str, target) will automatically call th ese at the start
361 * and end of a code block respectively
362 */
363 void addGpuTraceMarker(const GrGpuTraceMarker* marker);
364 void removeGpuTraceMarker(const GrGpuTraceMarker* marker);
365
366 /**
367 * Takes the current active set of markers and stores them for later use. An y current marker
368 * in the active set is removed from the active set and the targets remove f unction is called.
369 * These functions do not work as a stack so you cannot call save a second t ime before calling
370 * restore. Also, it is assumed that when restore is called the current acti ve set of markers
371 * is empty. When the stored markers are added back into the active set, the targets add marker
372 * is called.
373 */
374 void saveActiveTraceMarkers();
375 void restoreActiveTraceMarkers();
376
377 /**
378 * Query to find out if the vertex or index source is reserved.
379 */
380 bool hasReservedVerticesOrIndices() const {
381 return GrDrawTarget::kReserved_GeometrySrcType == this->getGeomSrc().fVe rtexSrc ||
382 GrDrawTarget::kReserved_GeometrySrcType == this->getGeomSrc().fIn dexSrc;
383 }
384
385 // Called to determine whether an onCopySurface call would succeed or not. T his is useful for
386 // proxy subclasses to test whether the copy would succeed without executing it yet. Derived
387 // classes must keep this consistent with their implementation of onCopySurf ace(). The inputs
388 // are the same as onCopySurface(), i.e. srcRect and dstPoint are clipped to be inside the src
389 // and dst bounds.
390 virtual bool canCopySurface(GrSurface* dst,
391 GrSurface* src,
392 const SkIRect& srcRect,
393 const SkIPoint& dstPoint) = 0;
394
395 // This method is called by copySurface The srcRect is guaranteed to be ent irely within the
396 // src bounds. Likewise, the dst rect implied by dstPoint and srcRect's widt h and height falls
397 // entirely within the dst. The default implementation will draw a rect from the src to the
398 // dst if the src is a texture and the dst is a render target and fail other wise.
399 virtual bool copySurface(GrSurface* dst,
400 GrSurface* src,
401 const SkIRect& srcRect,
402 const SkIPoint& dstPoint) = 0;
403
404 /**
405 * Sets source of vertex data for the next draw. Data does not have to be
406 * in the buffer until drawIndexed, drawNonIndexed, or drawIndexedInstances.
407 *
408 * @param buffer vertex buffer containing vertex data. Must be
409 * unlocked before draw call. Vertex size is queried
410 * from current GrDrawState.
411 */
412 void setVertexSourceToBuffer(const GrVertexBuffer* buffer);
413
414 /**
415 * Sets source of index data for the next indexed draw. Data does not have
416 * to be in the buffer until drawIndexed.
417 *
418 * @param buffer index buffer containing indices. Must be unlocked
419 * before indexed draw call.
420 */
421 void setIndexSourceToBuffer(const GrIndexBuffer* buffer);
422
423 /**
424 * Resets vertex source. Drawing from reset vertices is illegal. Set vertex
425 * source to reserved, array, or buffer before next draw. May be able to fre e
426 * up temporary storage allocated by setVertexSourceToArray or
427 * reserveVertexSpace.
428 */
429 void resetVertexSource();
430
431 /**
432 * Resets index source. Indexed Drawing from reset indices is illegal. Set
433 * index source to reserved, array, or buffer before next indexed draw. May
434 * be able to free up temporary storage allocated by setIndexSourceToArray
435 * or reserveIndexSpace.
436 */
437 void resetIndexSource();
438
439 /**
440 * Pushes and resets the vertex/index sources. Any reserved vertex / index
441 * data is finalized (i.e. cannot be updated after the matching pop but can
442 * be drawn from). Must be balanced by a pop.
443 */
444 void pushGeometrySource();
445
446 /**
447 * Pops the vertex / index sources from the matching push.
448 */
449 void popGeometrySource();
450
311 protected: 451 protected:
312 DrawType PrimTypeToDrawType(GrPrimitiveType type) { 452 DrawType PrimTypeToDrawType(GrPrimitiveType type) {
313 switch (type) { 453 switch (type) {
314 case kTriangles_GrPrimitiveType: 454 case kTriangles_GrPrimitiveType:
315 case kTriangleStrip_GrPrimitiveType: 455 case kTriangleStrip_GrPrimitiveType:
316 case kTriangleFan_GrPrimitiveType: 456 case kTriangleFan_GrPrimitiveType:
317 return kDrawTriangles_DrawType; 457 return kDrawTriangles_DrawType;
318 case kPoints_GrPrimitiveType: 458 case kPoints_GrPrimitiveType:
319 return kDrawPoints_DrawType; 459 return kDrawPoints_DrawType;
320 case kLines_GrPrimitiveType: 460 case kLines_GrPrimitiveType:
321 case kLineStrip_GrPrimitiveType: 461 case kLineStrip_GrPrimitiveType:
322 return kDrawLines_DrawType; 462 return kDrawLines_DrawType;
323 default: 463 default:
324 SkFAIL("Unexpected primitive type"); 464 SkFAIL("Unexpected primitive type");
325 return kDrawTriangles_DrawType; 465 return kDrawTriangles_DrawType;
326 } 466 }
327 } 467 }
328 468
329 // Functions used to map clip-respecting stencil tests into normal 469 // Functions used to map clip-respecting stencil tests into normal
330 // stencil funcs supported by GPUs. 470 // stencil funcs supported by GPUs.
331 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, 471 static GrStencilFunc ConvertStencilFunc(bool stencilInClip,
332 GrStencilFunc func); 472 GrStencilFunc func);
333 static void ConvertStencilFuncAndMask(GrStencilFunc func, 473 static void ConvertStencilFuncAndMask(GrStencilFunc func,
334 bool clipInStencil, 474 bool clipInStencil,
335 unsigned int clipBit, 475 unsigned int clipBit,
336 unsigned int userBits, 476 unsigned int userBits,
337 unsigned int* ref, 477 unsigned int* ref,
338 unsigned int* mask); 478 unsigned int* mask);
339 479
480 // subclasses must call this in their destructors to ensure all vertex
481 // and index sources have been released (including those held by
482 // pushGeometrySource())
483 void releaseGeometry();
484
485 // accessors for derived classes
486 const GrDrawTarget::GeometrySrcState& getGeomSrc() const { return fGeoSrcSta teStack.back(); }
487
488 // it is preferable to call this rather than getGeomSrc()->fVertexSize becau se of the assert.
489 size_t getVertexSize() const {
490 // the vertex layout is only valid if a vertex source has been specified .
491 SkASSERT(this->getGeomSrc().fVertexSrc != GrDrawTarget::kNone_GeometrySr cType);
492 return this->getGeomSrc().fVertexSize;
493 }
494
495 const GrTraceMarkerSet& getActiveTraceMarkers() { return fActiveTraceMarkers ; }
496
340 GrContext::GPUStats fGPUStats; 497 GrContext::GPUStats fGPUStats;
341 498
342 struct GeometryPoolState { 499 struct GeometryPoolState {
343 const GrVertexBuffer* fPoolVertexBuffer; 500 const GrVertexBuffer* fPoolVertexBuffer;
344 int fPoolStartVertex; 501 int fPoolStartVertex;
345 502
346 const GrIndexBuffer* fPoolIndexBuffer; 503 const GrIndexBuffer* fPoolIndexBuffer;
347 int fPoolStartIndex; 504 int fPoolStartIndex;
348 }; 505 };
349 const GeometryPoolState& getGeomPoolState() { 506 const GeometryPoolState& getGeomPoolState() {
350 return fGeomPoolStateStack.back(); 507 return fGeomPoolStateStack.back();
351 } 508 }
352 509
353 // Helpers for setting up geometry state 510 // Helpers for setting up geometry state
354 void finalizeReservedVertices(); 511 void finalizeReservedVertices();
355 void finalizeReservedIndices(); 512 void finalizeReservedIndices();
356 513
357 SkAutoTDelete<GrPathRendering> fPathRendering; 514 SkAutoTDelete<GrPathRendering> fPathRendering;
358 515
516 // Subclass must initialize this in its constructor.
517 SkAutoTUnref<const GrDrawTargetCaps> fCaps;
518
359 private: 519 private:
360 // GrDrawTarget overrides 520 // GrDrawTarget overrides
361 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices) SK_OVERRIDE; 521 virtual bool onReserveVertexSpace(size_t vertexSize, int vertexCount, void** vertices);
362 virtual bool onReserveIndexSpace(int indexCount, void** indices) SK_OVERRIDE ; 522 virtual bool onReserveIndexSpace(int indexCount, void** indices);
363 virtual void releaseReservedVertexSpace() SK_OVERRIDE; 523 virtual void releaseReservedVertexSpace();
364 virtual void releaseReservedIndexSpace() SK_OVERRIDE; 524 virtual void releaseReservedIndexSpace();
365 virtual void geometrySourceWillPush() SK_OVERRIDE; 525 virtual void geometrySourceWillPush();
366 virtual void geometrySourceWillPop(const GeometrySrcState& restoredState) SK _OVERRIDE; 526 virtual void geometrySourceWillPop(const GrDrawTarget::GeometrySrcState& res toredState);
367 virtual void onClear(const SkIRect* rect, GrColor color, bool canIgnoreRect,
368 GrRenderTarget* renderTarget) SK_OVERRIDE;
369 527
370 // called when the 3D context state is unknown. Subclass should emit any 528 // called when the 3D context state is unknown. Subclass should emit any
371 // assumed 3D context state and dirty any state cache. 529 // assumed 3D context state and dirty any state cache.
372 virtual void onResetContext(uint32_t resetBits) = 0; 530 virtual void onResetContext(uint32_t resetBits) = 0;
373 531
374 // overridden by backend-specific derived class to create objects. 532 // overridden by backend-specific derived class to create objects.
375 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc, 533 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc,
376 const void* srcData, 534 const void* srcData,
377 size_t rowBytes) = 0; 535 size_t rowBytes) = 0;
378 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, 536 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc,
379 const void* srcData) = 0; 537 const void* srcData) = 0;
380 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0; 538 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&) = 0;
381 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge tDesc&) = 0; 539 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge tDesc&) = 0;
382 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; 540 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0;
383 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; 541 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0;
384 542
385 // overridden by backend-specific derived class to perform the clear. 543 // overridden by backend-specific derived class to perform the clear.
386 virtual void onGpuClear(GrRenderTarget*, const SkIRect* rect, GrColor color, 544 virtual void onGpuClear(GrRenderTarget*, const SkIRect* rect, GrColor color,
387 bool canIgnoreRect) = 0; 545 bool canIgnoreRect) = 0;
388 546
389 547
390 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is 548 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is
391 // ONLY used by the the clip target 549 // ONLY used by the the clip target
392 virtual void onClearStencilClip(GrRenderTarget*, 550 virtual void onClearStencilClip(GrRenderTarget*,
393 const SkIRect& rect, 551 const SkIRect& rect,
394 bool insideClip) = 0; 552 bool insideClip) = 0;
395 553
396 // overridden by backend-specific derived class to perform the draw call. 554 // overridden by backend-specific derived class to perform the draw call.
397 virtual void onGpuDraw(const DrawInfo&) = 0; 555 virtual void onGpuDraw(const GrDrawTarget::DrawInfo&) = 0;
398 556
399 // overridden by backend-specific derived class to perform the read pixels. 557 // overridden by backend-specific derived class to perform the read pixels.
400 virtual bool onReadPixels(GrRenderTarget* target, 558 virtual bool onReadPixels(GrRenderTarget* target,
401 int left, int top, int width, int height, 559 int left, int top, int width, int height,
402 GrPixelConfig, 560 GrPixelConfig,
403 void* buffer, 561 void* buffer,
404 size_t rowBytes) = 0; 562 size_t rowBytes) = 0;
405 563
406 // overridden by backend-specific derived class to perform the texture updat e 564 // overridden by backend-specific derived class to perform the texture updat e
407 virtual bool onWriteTexturePixels(GrTexture* texture, 565 virtual bool onWriteTexturePixels(GrTexture* texture,
(...skipping 20 matching lines...) Expand all
428 const GrClipMaskManager::ScissorState&, 586 const GrClipMaskManager::ScissorState&,
429 const GrDeviceCoordTexture* dstCopy) = 0; 587 const GrDeviceCoordTexture* dstCopy) = 0;
430 588
431 // clears target's entire stencil buffer to 0 589 // clears target's entire stencil buffer to 0
432 virtual void clearStencil(GrRenderTarget* target) = 0; 590 virtual void clearStencil(GrRenderTarget* target) = 0;
433 591
434 // Given a rt, find or create a stencil buffer and attach it 592 // Given a rt, find or create a stencil buffer and attach it
435 bool attachStencilBufferToRenderTarget(GrRenderTarget* target); 593 bool attachStencilBufferToRenderTarget(GrRenderTarget* target);
436 594
437 // GrDrawTarget overrides 595 // GrDrawTarget overrides
438 virtual void onDraw(const DrawInfo&, const GrClipMaskManager::ScissorState&) SK_OVERRIDE; 596 virtual void onDraw(const GrDrawTarget::DrawInfo&,
597 const GrClipMaskManager::ScissorState&);
439 virtual void onStencilPath(const GrPath*, 598 virtual void onStencilPath(const GrPath*,
440 const GrClipMaskManager::ScissorState&, 599 const GrClipMaskManager::ScissorState&,
441 const GrStencilSettings&) SK_OVERRIDE; 600 const GrStencilSettings&);
442 virtual void onDrawPath(const GrPath*, 601 virtual void onDrawPath(const GrPath*,
443 const GrClipMaskManager::ScissorState&, 602 const GrClipMaskManager::ScissorState&,
444 const GrStencilSettings&, 603 const GrStencilSettings&,
445 const GrDeviceCoordTexture* dstCopy) SK_OVERRIDE; 604 const GrDeviceCoordTexture* dstCopy);
446 virtual void onDrawPaths(const GrPathRange*, 605 virtual void onDrawPaths(const GrPathRange*,
447 const uint32_t indices[], 606 const uint32_t indices[],
448 int count, 607 int count,
449 const float transforms[], 608 const float transforms[],
450 PathTransformType, 609 GrDrawTarget::PathTransformType,
451 const GrClipMaskManager::ScissorState&, 610 const GrClipMaskManager::ScissorState&,
452 const GrStencilSettings&, 611 const GrStencilSettings&,
453 const GrDeviceCoordTexture*) SK_OVERRIDE; 612 const GrDeviceCoordTexture*);
613
614 virtual void didAddGpuTraceMarker() = 0;
615 virtual void didRemoveGpuTraceMarker() = 0;
616
454 617
455 // readies the pools to provide vertex/index data. 618 // readies the pools to provide vertex/index data.
456 void prepareVertexPool(); 619 void prepareVertexPool();
457 void prepareIndexPool(); 620 void prepareIndexPool();
458 621
459 void resetContext() { 622 void resetContext() {
460 this->onResetContext(fResetBits); 623 this->onResetContext(fResetBits);
461 fResetBits = 0; 624 fResetBits = 0;
462 ++fResetTimestamp; 625 ++fResetTimestamp;
463 } 626 }
464 627
465 void handleDirtyContext() { 628 void handleDirtyContext() {
466 if (fResetBits) { 629 if (fResetBits) {
467 this->resetContext(); 630 this->resetContext();
468 } 631 }
469 } 632 }
470 633
634 // called when setting a new vert/idx source to unref prev vb/ib
635 void releasePreviousVertexSource();
636 void releasePreviousIndexSource();
637
638 enum {
639 kPreallocGeoSrcStateStackCnt = 4,
640 };
641 SkSTArray<kPreallocGeoSrcStateStackCnt, GrDrawTarget::GeometrySrcState, true > fGeoSrcStateStack;
642
471 enum { 643 enum {
472 kPreallocGeomPoolStateStackCnt = 4, 644 kPreallocGeomPoolStateStackCnt = 4,
473 }; 645 };
474 SkSTArray<kPreallocGeomPoolStateStackCnt, GeometryPoolState, true> fGeomPoo lStateStack; 646 SkSTArray<kPreallocGeomPoolStateStackCnt, GeometryPoolState, true> fGeomPoo lStateStack;
475 ResetTimestamp fResetTi mestamp; 647 ResetTimestamp fResetTi mestamp;
476 uint32_t fResetBi ts; 648 uint32_t fResetBi ts;
477 GrVertexBufferAllocPool* fVertexP ool; 649 GrVertexBufferAllocPool* fVertexP ool;
478 GrIndexBufferAllocPool* fIndexPo ol; 650 GrIndexBufferAllocPool* fIndexPo ol;
479 // counts number of uses of vertex/index pool in the geometry stack 651 // counts number of uses of vertex/index pool in the geometry stack
480 int fVertexP oolUseCnt; 652 int fVertexP oolUseCnt;
481 int fIndexPo olUseCnt; 653 int fIndexPo olUseCnt;
482 // these are mutable so they can be created on-demand 654 // these are mutable so they can be created on-demand
483 mutable GrIndexBuffer* fQuadInd exBuffer; 655 mutable GrIndexBuffer* fQuadInd exBuffer;
656 GrDrawState fDefaultDraw State;
657 GrDrawState* fDrawSta te;
658 // To keep track that we always have at least as many debug marker adds as r emoves
659 int fGpuTrac eMarkerCount;
660 GrTraceMarkerSet fActiveT raceMarkers;
661 GrTraceMarkerSet fStoredT raceMarkers;
662 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu.
663 GrContext* fContext ;
484 664
485 typedef GrClipTarget INHERITED; 665 // TODO fix this
666 friend class GrInOrderDrawBuffer;
667
668 typedef SkRefCnt INHERITED;
486 }; 669 };
487 670
488 #endif 671 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrDrawTarget.h ('k') | src/gpu/GrGpu.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698