OLD | NEW |
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 |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 * @param offset offset from the start of the buffer | 293 * @param offset offset from the start of the buffer |
294 * @param rowBytes number of bytes between consecutive rows. Zero | 294 * @param rowBytes number of bytes between consecutive rows. Zero |
295 * means rows are tightly packed. | 295 * means rows are tightly packed. |
296 */ | 296 */ |
297 bool transferPixels(GrSurface* surface, | 297 bool transferPixels(GrSurface* surface, |
298 int left, int top, int width, int height, | 298 int left, int top, int width, int height, |
299 GrPixelConfig config, GrBuffer* transferBuffer, | 299 GrPixelConfig config, GrBuffer* transferBuffer, |
300 size_t offset, size_t rowBytes); | 300 size_t offset, size_t rowBytes); |
301 | 301 |
302 /** | 302 /** |
303 * Clear the passed in render target. Ignores the draw state and clip. | |
304 */ | |
305 void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget)
; | |
306 | |
307 | |
308 void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget*
renderTarget); | |
309 | |
310 /** | |
311 * Discards the contents render target. nullptr indicates that the current r
ender target should | |
312 * be discarded. | |
313 **/ | |
314 virtual void discard(GrRenderTarget* = nullptr) = 0; | |
315 | |
316 /** | |
317 * This is can be called before allocating a texture to be a dst for copySur
face. It will | 303 * This is can be called before allocating a texture to be a dst for copySur
face. It will |
318 * populate the origin, config, and flags fields of the desc such that copyS
urface can | 304 * populate the origin, config, and flags fields of the desc such that copyS
urface can |
319 * efficiently succeed. It should only succeed if it can allow copySurface t
o perform a copy | 305 * efficiently succeed. It should only succeed if it can allow copySurface t
o perform a copy |
320 * that would be more effecient than drawing the src to a dst render target. | 306 * that would be more effecient than drawing the src to a dst render target. |
321 */ | 307 */ |
322 virtual bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* des
c) const = 0; | 308 virtual bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* des
c) const = 0; |
323 | 309 |
324 // After the client interacts directly with the 3D context state the GrGpu | 310 // After the client interacts directly with the 3D context state the GrGpu |
325 // must resync its internal state and assumptions about 3D context state. | 311 // must resync its internal state and assumptions about 3D context state. |
326 // Each time this occurs the GrGpu bumps a timestamp. | 312 // Each time this occurs the GrGpu bumps a timestamp. |
(...skipping 29 matching lines...) Expand all Loading... |
356 SkAutoTDeleteArray<const SkPoint> fSampleLocations; | 342 SkAutoTDeleteArray<const SkPoint> fSampleLocations; |
357 }; | 343 }; |
358 | 344 |
359 // Finds a render target's multisample specs. The stencil settings are only
needed to flush the | 345 // Finds a render target's multisample specs. The stencil settings are only
needed to flush the |
360 // draw state prior to querying multisample information; they should not hav
e any effect on the | 346 // draw state prior to querying multisample information; they should not hav
e any effect on the |
361 // multisample information itself. | 347 // multisample information itself. |
362 const MultisampleSpecs& getMultisampleSpecs(GrRenderTarget*, const GrStencil
Settings&); | 348 const MultisampleSpecs& getMultisampleSpecs(GrRenderTarget*, const GrStencil
Settings&); |
363 | 349 |
364 // Creates a GrGpuCommandBuffer in which the GrDrawTarget can send draw comm
ands to instead of | 350 // Creates a GrGpuCommandBuffer in which the GrDrawTarget can send draw comm
ands to instead of |
365 // directly to the Gpu object. | 351 // directly to the Gpu object. |
366 virtual GrGpuCommandBuffer* createCommandBuffer(const GrRenderTarget& target
, | 352 virtual GrGpuCommandBuffer* createCommandBuffer( |
367 GrGpuCommandBuffer::LoadAndS
toreOp colorOp, | 353 GrRenderTarget* target, |
368 GrColor colorClear, | 354 const GrGpuCommandBuffer::LoadAndStoreInfo& colorInfo, |
369 GrGpuCommandBuffer::LoadAndS
toreOp stencilOp, | 355 const GrGpuCommandBuffer::LoadAndStoreInfo& stencilInfo) = 0; |
370 GrColor stencilClear) = 0; | |
371 | |
372 // We pass in an array of meshCount GrMesh to the draw. The backend should l
oop over each | |
373 // GrMesh object and emit a draw for it. Each draw will use the same GrPipel
ine and | |
374 // GrPrimitiveProcessor. This may fail if the draw would exceed any resource
limits (e.g. | |
375 // number of vertex attributes is too large). | |
376 bool draw(const GrPipeline&, | |
377 const GrPrimitiveProcessor&, | |
378 const GrMesh*, | |
379 int meshCount); | |
380 | 356 |
381 // Called by drawtarget when flushing. | 357 // Called by drawtarget when flushing. |
382 // Provides a hook for post-flush actions (e.g. PLS reset and Vulkan command
buffer submits). | 358 // Provides a hook for post-flush actions (e.g. PLS reset and Vulkan command
buffer submits). |
383 virtual void finishDrawTarget() {} | 359 virtual void finishDrawTarget() {} |
384 | 360 |
385 /////////////////////////////////////////////////////////////////////////// | 361 /////////////////////////////////////////////////////////////////////////// |
386 // Debugging and Stats | 362 // Debugging and Stats |
387 | 363 |
388 class Stats { | 364 class Stats { |
389 public: | 365 public: |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 } | 462 } |
487 return this->onMakeCopyForTextureParams(texture, params, copyParams); | 463 return this->onMakeCopyForTextureParams(texture, params, copyParams); |
488 } | 464 } |
489 | 465 |
490 // This is only to be used in GL-specific tests. | 466 // This is only to be used in GL-specific tests. |
491 virtual const GrGLContext* glContextForTesting() const { return nullptr; } | 467 virtual const GrGLContext* glContextForTesting() const { return nullptr; } |
492 | 468 |
493 // This is only to be used by testing code | 469 // This is only to be used by testing code |
494 virtual void resetShaderCacheForTesting() const {} | 470 virtual void resetShaderCacheForTesting() const {} |
495 | 471 |
| 472 void handleDirtyContext() { |
| 473 if (fResetBits) { |
| 474 this->resetContext(); |
| 475 } |
| 476 } |
| 477 |
496 protected: | 478 protected: |
497 static void ElevateDrawPreference(GrGpu::DrawPreference* preference, | 479 static void ElevateDrawPreference(GrGpu::DrawPreference* preference, |
498 GrGpu::DrawPreference elevation) { | 480 GrGpu::DrawPreference elevation) { |
499 GR_STATIC_ASSERT(GrGpu::kCallerPrefersDraw_DrawPreference > GrGpu::kNoDr
aw_DrawPreference); | 481 GR_STATIC_ASSERT(GrGpu::kCallerPrefersDraw_DrawPreference > GrGpu::kNoDr
aw_DrawPreference); |
500 GR_STATIC_ASSERT(GrGpu::kGpuPrefersDraw_DrawPreference > | 482 GR_STATIC_ASSERT(GrGpu::kGpuPrefersDraw_DrawPreference > |
501 GrGpu::kCallerPrefersDraw_DrawPreference); | 483 GrGpu::kCallerPrefersDraw_DrawPreference); |
502 GR_STATIC_ASSERT(GrGpu::kRequireDraw_DrawPreference > | 484 GR_STATIC_ASSERT(GrGpu::kRequireDraw_DrawPreference > |
503 GrGpu::kGpuPrefersDraw_DrawPreference); | 485 GrGpu::kGpuPrefersDraw_DrawPreference); |
504 *preference = SkTMax(*preference, elevation); | 486 *preference = SkTMax(*preference, elevation); |
505 } | 487 } |
506 | 488 |
507 void handleDirtyContext() { | |
508 if (fResetBits) { | |
509 this->resetContext(); | |
510 } | |
511 } | |
512 | |
513 // Handles cases where a surface will be updated without a call to flushRend
erTarget | 489 // Handles cases where a surface will be updated without a call to flushRend
erTarget |
514 void didWriteToSurface(GrSurface* surface, const SkIRect* bounds, uint32_t m
ipLevels = 1) const; | 490 void didWriteToSurface(GrSurface* surface, const SkIRect* bounds, uint32_t m
ipLevels = 1) const; |
515 | 491 |
516 Stats fStats; | 492 Stats fStats; |
517 SkAutoTDelete<GrPathRendering> fPathRendering; | 493 SkAutoTDelete<GrPathRendering> fPathRendering; |
518 // Subclass must initialize this in its constructor. | 494 // Subclass must initialize this in its constructor. |
519 SkAutoTUnref<const GrCaps> fCaps; | 495 SkAutoTUnref<const GrCaps> fCaps; |
520 | 496 |
521 private: | 497 private: |
522 // called when the 3D context state is unknown. Subclass should emit any | 498 // called when the 3D context state is unknown. Subclass should emit any |
(...skipping 13 matching lines...) Expand all Loading... |
536 SkBudgeted budgeted, | 512 SkBudgeted budgeted, |
537 const SkTArray<GrMipLevel>& tex
els) = 0; | 513 const SkTArray<GrMipLevel>& tex
els) = 0; |
538 | 514 |
539 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO
wnership) = 0; | 515 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapO
wnership) = 0; |
540 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&, | 516 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTarge
tDesc&, |
541 GrWrapOwnership) = 0; | 517 GrWrapOwnership) = 0; |
542 virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTe
xtureDesc&) = 0; | 518 virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTe
xtureDesc&) = 0; |
543 virtual GrBuffer* onCreateBuffer(size_t size, GrBufferType intendedType, GrA
ccessPattern, | 519 virtual GrBuffer* onCreateBuffer(size_t size, GrBufferType intendedType, GrA
ccessPattern, |
544 const void* data) = 0; | 520 const void* data) = 0; |
545 | 521 |
546 // overridden by backend-specific derived class to perform the clear. | |
547 virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) =
0; | |
548 | |
549 // Overridden by backend specific classes to perform a clear of the stencil
clip bits. This is | |
550 // ONLY used by the the clip target | |
551 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool i
nsideClip) = 0; | |
552 | |
553 // overridden by backend-specific derived class to perform the draw call. | |
554 virtual void onDraw(const GrPipeline&, | |
555 const GrPrimitiveProcessor&, | |
556 const GrMesh*, | |
557 int meshCount) = 0; | |
558 | |
559 virtual bool onMakeCopyForTextureParams(GrTexture* texture, const GrTextureP
arams&, | 522 virtual bool onMakeCopyForTextureParams(GrTexture* texture, const GrTextureP
arams&, |
560 GrTextureProducer::CopyParams*) cons
t { return false; } | 523 GrTextureProducer::CopyParams*) cons
t { return false; } |
561 | 524 |
562 virtual bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int r
eadHeight, | 525 virtual bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int r
eadHeight, |
563 size_t rowBytes, GrPixelConfig readConfig,
DrawPreference*, | 526 size_t rowBytes, GrPixelConfig readConfig,
DrawPreference*, |
564 ReadPixelTempDrawInfo*) = 0; | 527 ReadPixelTempDrawInfo*) = 0; |
565 virtual bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int heig
ht, | 528 virtual bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int heig
ht, |
566 GrPixelConfig srcConfig, DrawPreference*, | 529 GrPixelConfig srcConfig, DrawPreference*, |
567 WritePixelTempDrawInfo*) = 0; | 530 WritePixelTempDrawInfo*) = 0; |
568 | 531 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 SkTArray<const MultisampleSpecs*, true> fMultisa
mpleSpecsMap; | 575 SkTArray<const MultisampleSpecs*, true> fMultisa
mpleSpecsMap; |
613 GrTAllocator<MultisampleSpecs> fMultisa
mpleSpecsAllocator; | 576 GrTAllocator<MultisampleSpecs> fMultisa
mpleSpecsAllocator; |
614 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 577 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
615 GrContext* fContext
; | 578 GrContext* fContext
; |
616 | 579 |
617 friend class GrPathRendering; | 580 friend class GrPathRendering; |
618 typedef SkRefCnt INHERITED; | 581 typedef SkRefCnt INHERITED; |
619 }; | 582 }; |
620 | 583 |
621 #endif | 584 #endif |
OLD | NEW |