1 /* 2 * Copyright 2011 Google Inc. 3 * 4 * Use of this source code is governed by a BSD-style license that can be 5 * found in the LICENSE file. 6 */ 7 8 #ifndef GrGpu_DEFINED 9 #define GrGpu_DEFINED 10 11 #include "GrCaps.h" 12 #include "GrGpuCommandBuffer.h" 13 #include "GrProgramDesc.h" 14 #include "GrSamplePatternDictionary.h" 15 #include "GrSwizzle.h" 16 #include "GrAllocator.h" 17 #include "GrTextureProducer.h" 18 #include "GrTypes.h" 19 #include "GrXferProcessor.h" 20 #include "SkPath.h" 21 #include "SkSurface.h" 22 #include "SkTArray.h" 23 #include <map> 24 25 class GrBackendRenderTarget; 26 class GrBackendSemaphore; 27 class GrGpuBuffer; 28 class GrContext; 29 struct GrContextOptions; 30 class GrGLContext; 31 class GrMesh; 32 class GrPath; 33 class GrPathRenderer; 34 class GrPathRendererChain; 35 class GrPathRendering; 36 class GrPipeline; 37 class GrPrimitiveProcessor; 38 class GrRenderTarget; 39 class GrSemaphore; 40 class GrStencilAttachment; 41 class GrStencilSettings; 42 class GrSurface; 43 class GrTexture; 44 class SkJSONWriter; 45 46 class GrGpu : public SkRefCnt { 47 public: 48 GrGpu(GrContext* context); 49 ~GrGpu() override; 50 getContext()51 GrContext* getContext() { return fContext; } getContext()52 const GrContext* getContext() const { return fContext; } 53 54 /** 55 * Gets the capabilities of the draw target. 56 */ caps()57 const GrCaps* caps() const { return fCaps.get(); } refCaps()58 sk_sp<const GrCaps> refCaps() const { return fCaps; } 59 pathRendering()60 GrPathRendering* pathRendering() { return fPathRendering.get(); } 61 62 enum class DisconnectType { 63 // No cleanup should be attempted, immediately cease making backend API calls 64 kAbandon, 65 // Free allocated resources (not known by GrResourceCache) before returning and 66 // ensure no backend backend 3D API calls will be made after disconnect() returns. 67 kCleanup, 68 }; 69 70 // Called by GrContext when the underlying backend context is already or will be destroyed 71 // before GrContext. 72 virtual void disconnect(DisconnectType); 73 74 /** 75 * The GrGpu object normally assumes that no outsider is setting state 76 * within the underlying 3D API's context/device/whatever. This call informs 77 * the GrGpu that the state was modified and it shouldn't make assumptions 78 * about the state. 79 */ 80 void markContextDirty(uint32_t state = kAll_GrBackendState) { fResetBits |= state; } 81 82 /** 83 * Creates a texture object. If kRenderTarget_GrSurfaceFlag the texture can 84 * be used as a render target by calling GrTexture::asRenderTarget(). Not all 85 * pixel configs can be used as render targets. Support for configs as textures 86 * or render targets can be checked using GrCaps. 87 * 88 * @param desc describes the texture to be created. 89 * @param budgeted does this texture count against the resource cache budget? 90 * @param texels array of mipmap levels containing texel data to load. 91 * Each level begins with full-size palette data for paletted textures. 92 * It contains width*height texels. If there is only one 93 * element and it contains nullptr fPixels, texture data is 94 * uninitialized. 95 * @param mipLevelCount the number of levels in 'texels' 96 * @return The texture object if successful, otherwise nullptr. 97 */ 98 sk_sp<GrTexture> createTexture(const GrSurfaceDesc&, SkBudgeted, const GrMipLevel texels[], 99 int mipLevelCount); 100 101 /** 102 * Simplified createTexture() interface for when there is no initial texel data to upload. 103 */ 104 sk_sp<GrTexture> createTexture(const GrSurfaceDesc& desc, SkBudgeted); 105 106 /** 107 * Implements GrResourceProvider::wrapBackendTexture 108 */ 109 sk_sp<GrTexture> wrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, GrWrapCacheable, 110 GrIOType); 111 112 /** 113 * Implements GrResourceProvider::wrapRenderableBackendTexture 114 */ 115 sk_sp<GrTexture> wrapRenderableBackendTexture(const GrBackendTexture&, int sampleCnt, 116 GrWrapOwnership, GrWrapCacheable); 117 118 /** 119 * Implements GrResourceProvider::wrapBackendRenderTarget 120 */ 121 sk_sp<GrRenderTarget> wrapBackendRenderTarget(const GrBackendRenderTarget&); 122 123 /** 124 * Implements GrResourceProvider::wrapBackendTextureAsRenderTarget 125 */ 126 sk_sp<GrRenderTarget> wrapBackendTextureAsRenderTarget(const GrBackendTexture&, 127 int sampleCnt); 128 129 /** 130 * Implements GrResourceProvider::wrapVulkanSecondaryCBAsRenderTarget 131 */ 132 sk_sp<GrRenderTarget> wrapVulkanSecondaryCBAsRenderTarget(const SkImageInfo&, 133 const GrVkDrawableInfo&); 134 135 /** 136 * Creates a buffer in GPU memory. For a client-side buffer use GrBuffer::CreateCPUBacked. 137 * 138 * @param size size of buffer to create. 139 * @param intendedType hint to the graphics subsystem about what the buffer will be used for. 140 * @param accessPattern hint to the graphics subsystem about how the data will be accessed. 141 * @param data optional data with which to initialize the buffer. 142 * 143 * @return the buffer if successful, otherwise nullptr. 144 */ 145 sk_sp<GrGpuBuffer> createBuffer(size_t size, GrGpuBufferType intendedType, 146 GrAccessPattern accessPattern, const void* data = nullptr); 147 148 /** 149 * Resolves MSAA. 150 */ 151 void resolveRenderTarget(GrRenderTarget*); 152 153 /** 154 * Uses the base of the texture to recompute the contents of the other levels. 155 */ 156 bool regenerateMipMapLevels(GrTexture*); 157 158 /** 159 * If the backend API has stateful texture bindings, this resets them back to defaults. 160 */ 161 void resetTextureBindings(); 162 163 /** 164 * Reads a rectangle of pixels from a render target. No sRGB/linear conversions are performed. 165 * 166 * @param surface The surface to read from 167 * @param left left edge of the rectangle to read (inclusive) 168 * @param top top edge of the rectangle to read (inclusive) 169 * @param width width of rectangle to read in pixels. 170 * @param height height of rectangle to read in pixels. 171 * @param dstColorType the color type of the destination buffer. 172 * @param buffer memory to read the rectangle into. 173 * @param rowBytes the number of bytes between consecutive rows. Zero 174 * means rows are tightly packed. 175 * @param invertY buffer should be populated bottom-to-top as opposed 176 * to top-to-bottom (skia's usual order) 177 * 178 * @return true if the read succeeded, false if not. The read can fail 179 * because of a unsupported pixel config or because no render 180 * target is currently set. 181 */ 182 bool readPixels(GrSurface* surface, int left, int top, int width, int height, 183 GrColorType dstColorType, void* buffer, size_t rowBytes); 184 185 /** 186 * Updates the pixels in a rectangle of a surface. No sRGB/linear conversions are performed. 187 * 188 * @param surface The surface to write to. 189 * @param left left edge of the rectangle to write (inclusive) 190 * @param top top edge of the rectangle to write (inclusive) 191 * @param width width of rectangle to write in pixels. 192 * @param height height of rectangle to write in pixels. 193 * @param srcColorType the color type of the source buffer. 194 * @param texels array of mipmap levels containing texture data 195 * @param mipLevelCount number of levels in 'texels' 196 */ 197 bool writePixels(GrSurface* surface, int left, int top, int width, int height, 198 GrColorType srcColorType, const GrMipLevel texels[], int mipLevelCount); 199 200 /** 201 * Helper for the case of a single level. 202 */ writePixels(GrSurface * surface,int left,int top,int width,int height,GrColorType srcColorType,const void * buffer,size_t rowBytes)203 bool writePixels(GrSurface* surface, int left, int top, int width, int height, 204 GrColorType srcColorType, const void* buffer, size_t rowBytes) { 205 GrMipLevel mipLevel = {buffer, rowBytes}; 206 return this->writePixels(surface, left, top, width, height, srcColorType, &mipLevel, 1); 207 } 208 209 /** 210 * Updates the pixels in a rectangle of a texture using a buffer 211 * 212 * There are a couple of assumptions here. First, we only update the top miplevel. 213 * And second, that any y flip needed has already been done in the buffer. 214 * 215 * @param texture The texture to write to. 216 * @param left left edge of the rectangle to write (inclusive) 217 * @param top top edge of the rectangle to write (inclusive) 218 * @param width width of rectangle to write in pixels. 219 * @param height height of rectangle to write in pixels. 220 * @param bufferColorType the color type of the transfer buffer's pixel data 221 * @param transferBuffer GrBuffer to read pixels from (type must be "kXferCpuToGpu") 222 * @param offset offset from the start of the buffer 223 * @param rowBytes number of bytes between consecutive rows in the buffer. Zero 224 * means rows are tightly packed. 225 */ 226 bool transferPixels(GrTexture* texture, int left, int top, int width, int height, 227 GrColorType bufferColorType, GrGpuBuffer* transferBuffer, size_t offset, 228 size_t rowBytes); 229 230 // After the client interacts directly with the 3D context state the GrGpu 231 // must resync its internal state and assumptions about 3D context state. 232 // Each time this occurs the GrGpu bumps a timestamp. 233 // state of the 3D context 234 // At 10 resets / frame and 60fps a 64bit timestamp will overflow in about 235 // a billion years. 236 typedef uint64_t ResetTimestamp; 237 238 // This timestamp is always older than the current timestamp 239 static const ResetTimestamp kExpiredTimestamp = 0; 240 // Returns a timestamp based on the number of times the context was reset. 241 // This timestamp can be used to lazily detect when cached 3D context state 242 // is dirty. getResetTimestamp()243 ResetTimestamp getResetTimestamp() const { return fResetTimestamp; } 244 245 // Called to perform a surface to surface copy. Fallbacks to issuing a draw from the src to dst 246 // take place at the GrOpList level and this function implement faster copy paths. The rect 247 // and point are pre-clipped. The src rect and implied dst rect are guaranteed to be within the 248 // src/dst bounds and non-empty. If canDiscardOutsideDstRect is set to true then we don't need 249 // to preserve any data on the dst surface outside of the copy. 250 bool copySurface(GrSurface* dst, GrSurfaceOrigin dstOrigin, 251 GrSurface* src, GrSurfaceOrigin srcOrigin, 252 const SkIRect& srcRect, 253 const SkIPoint& dstPoint, 254 bool canDiscardOutsideDstRect = false); 255 256 // Queries the per-pixel HW sample locations for the given render target, and then finds or 257 // assigns a key that uniquely identifies the sample pattern. The actual sample locations can be 258 // retrieved with retrieveSampleLocations(). 259 // 260 // NOTE: The pipeline argument is required in order for us to flush draw state prior to querying 261 // multisample info. The pipeline itself is not expected to affect sample locations. 262 int findOrAssignSamplePatternKey(GrRenderTarget*, const GrPipeline&); 263 264 // Retrieves the per-pixel HW sample locations for the given sample pattern key, and, as a 265 // by-product, the actual number of samples in use. (This may differ from the number of samples 266 // requested by the render target.) Sample locations are returned as 0..1 offsets relative to 267 // the top-left corner of the pixel. retrieveSampleLocations(int samplePatternKey)268 const SkTArray<SkPoint>& retrieveSampleLocations(int samplePatternKey) const { 269 return fSamplePatternDictionary.retrieveSampleLocations(samplePatternKey); 270 } 271 272 // Returns a GrGpuRTCommandBuffer which GrOpLists send draw commands to instead of directly 273 // to the Gpu object. The 'bounds' rect is the content rect of the destination. 274 virtual GrGpuRTCommandBuffer* getCommandBuffer( 275 GrRenderTarget*, GrSurfaceOrigin, const SkRect& bounds, 276 const GrGpuRTCommandBuffer::LoadAndStoreInfo&, 277 const GrGpuRTCommandBuffer::StencilLoadAndStoreInfo&) = 0; 278 279 // Returns a GrGpuTextureCommandBuffer which GrOpLists send texture commands to instead of 280 // directly to the Gpu object. 281 virtual GrGpuTextureCommandBuffer* getCommandBuffer(GrTexture*, GrSurfaceOrigin) = 0; 282 283 // Called by GrDrawingManager when flushing. 284 // Provides a hook for post-flush actions (e.g. Vulkan command buffer submits). This will also 285 // insert any numSemaphore semaphores on the gpu and set the backendSemaphores to match the 286 // inserted semaphores. 287 GrSemaphoresSubmitted finishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access, 288 GrFlushFlags flags, int numSemaphores, 289 GrBackendSemaphore backendSemaphores[], 290 GrGpuFinishedProc finishedProc, 291 GrGpuFinishedContext finishedContext); 292 293 virtual void submit(GrGpuCommandBuffer*) = 0; 294 295 virtual GrFence SK_WARN_UNUSED_RESULT insertFence() = 0; 296 virtual bool waitFence(GrFence, uint64_t timeout = 1000) = 0; 297 virtual void deleteFence(GrFence) const = 0; 298 299 virtual sk_sp<GrSemaphore> SK_WARN_UNUSED_RESULT makeSemaphore(bool isOwned = true) = 0; 300 virtual sk_sp<GrSemaphore> wrapBackendSemaphore(const GrBackendSemaphore& semaphore, 301 GrResourceProvider::SemaphoreWrapType wrapType, 302 GrWrapOwnership ownership) = 0; 303 virtual void insertSemaphore(sk_sp<GrSemaphore> semaphore) = 0; 304 virtual void waitSemaphore(sk_sp<GrSemaphore> semaphore) = 0; 305 306 /** 307 * Put this texture in a safe and known state for use across multiple GrContexts. Depending on 308 * the backend, this may return a GrSemaphore. If so, other contexts should wait on that 309 * semaphore before using this texture. 310 */ 311 virtual sk_sp<GrSemaphore> prepareTextureForCrossContextUsage(GrTexture*) = 0; 312 313 /////////////////////////////////////////////////////////////////////////// 314 // Debugging and Stats 315 316 class Stats { 317 public: 318 #if GR_GPU_STATS Stats()319 Stats() { this->reset(); } 320 reset()321 void reset() { 322 fRenderTargetBinds = 0; 323 fShaderCompilations = 0; 324 fTextureCreates = 0; 325 fTextureUploads = 0; 326 fTransfersToTexture = 0; 327 fStencilAttachmentCreates = 0; 328 fNumDraws = 0; 329 fNumFailedDraws = 0; 330 fNumFinishFlushes = 0; 331 } 332 renderTargetBinds()333 int renderTargetBinds() const { return fRenderTargetBinds; } incRenderTargetBinds()334 void incRenderTargetBinds() { fRenderTargetBinds++; } shaderCompilations()335 int shaderCompilations() const { return fShaderCompilations; } incShaderCompilations()336 void incShaderCompilations() { fShaderCompilations++; } textureCreates()337 int textureCreates() const { return fTextureCreates; } incTextureCreates()338 void incTextureCreates() { fTextureCreates++; } textureUploads()339 int textureUploads() const { return fTextureUploads; } incTextureUploads()340 void incTextureUploads() { fTextureUploads++; } transfersToTexture()341 int transfersToTexture() const { return fTransfersToTexture; } incTransfersToTexture()342 void incTransfersToTexture() { fTransfersToTexture++; } incStencilAttachmentCreates()343 void incStencilAttachmentCreates() { fStencilAttachmentCreates++; } incNumDraws()344 void incNumDraws() { fNumDraws++; } incNumFailedDraws()345 void incNumFailedDraws() { ++fNumFailedDraws; } incNumFinishFlushes()346 void incNumFinishFlushes() { ++fNumFinishFlushes; } 347 #if GR_TEST_UTILS 348 void dump(SkString*); 349 void dumpKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values); 350 #endif numDraws()351 int numDraws() const { return fNumDraws; } numFailedDraws()352 int numFailedDraws() const { return fNumFailedDraws; } numFinishFlushes()353 int numFinishFlushes() const { return fNumFinishFlushes; } 354 private: 355 int fRenderTargetBinds; 356 int fShaderCompilations; 357 int fTextureCreates; 358 int fTextureUploads; 359 int fTransfersToTexture; 360 int fStencilAttachmentCreates; 361 int fNumDraws; 362 int fNumFailedDraws; 363 int fNumFinishFlushes; 364 #else 365 366 #if GR_TEST_UTILS 367 void dump(SkString*) {} 368 void dumpKeyValuePairs(SkTArray<SkString>*, SkTArray<double>*) {} 369 #endif 370 void incRenderTargetBinds() {} 371 void incShaderCompilations() {} 372 void incTextureCreates() {} 373 void incTextureUploads() {} 374 void incTransfersToTexture() {} 375 void incStencilAttachmentCreates() {} 376 void incNumDraws() {} 377 void incNumFailedDraws() {} 378 void incNumFinishFlushes() {} 379 #endif 380 }; 381 stats()382 Stats* stats() { return &fStats; } 383 void dumpJSON(SkJSONWriter*) const; 384 385 #if GR_TEST_UTILS 386 GrBackendTexture createTestingOnlyBackendTexture(const void* pixels, int w, int h, 387 SkColorType, bool isRenderTarget, 388 GrMipMapped, size_t rowBytes = 0); 389 390 /** Creates a texture directly in the backend API without wrapping it in a GrTexture. This is 391 only to be used for testing (particularly for testing the methods that import an externally 392 created texture into Skia. Must be matched with a call to deleteTestingOnlyTexture(). */ 393 virtual GrBackendTexture createTestingOnlyBackendTexture(const void* pixels, int w, int h, 394 GrColorType, bool isRenderTarget, 395 GrMipMapped, size_t rowBytes = 0) = 0; 396 397 /** Check a handle represents an actual texture in the backend API that has not been freed. */ 398 virtual bool isTestingOnlyBackendTexture(const GrBackendTexture&) const = 0; 399 /** 400 * Frees a texture created by createTestingOnlyBackendTexture(). If ownership of the backend 401 * texture has been transferred to a GrContext using adopt semantics this should not be called. 402 */ 403 virtual void deleteTestingOnlyBackendTexture(const GrBackendTexture&) = 0; 404 405 virtual GrBackendRenderTarget createTestingOnlyBackendRenderTarget(int w, int h, 406 GrColorType) = 0; 407 408 virtual void deleteTestingOnlyBackendRenderTarget(const GrBackendRenderTarget&) = 0; 409 410 // This is only to be used in GL-specific tests. glContextForTesting()411 virtual const GrGLContext* glContextForTesting() const { return nullptr; } 412 413 // This is only to be used by testing code resetShaderCacheForTesting()414 virtual void resetShaderCacheForTesting() const {} 415 416 /** 417 * Flushes all work to the gpu and forces the GPU to wait until all the gpu work has completed. 418 * This is for testing purposes only. 419 */ 420 virtual void testingOnly_flushGpuAndSync() = 0; 421 #endif 422 423 // width and height may be larger than rt (if underlying API allows it). 424 // Returns nullptr if compatible sb could not be created, otherwise the caller owns the ref on 425 // the GrStencilAttachment. 426 virtual GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTarget*, 427 int width, 428 int height) = 0; 429 430 // Determines whether a texture will need to be rescaled in order to be used with the 431 // GrSamplerState. 432 static bool IsACopyNeededForRepeatWrapMode(const GrCaps*, GrTextureProxy* texProxy, 433 int width, int height, 434 GrSamplerState::Filter, 435 GrTextureProducer::CopyParams*, 436 SkScalar scaleAdjust[2]); 437 438 // Determines whether a texture will need to be copied because the draw requires mips but the 439 // texutre doesn't have any. This call should be only checked if IsACopyNeededForTextureParams 440 // fails. If the previous call succeeds, then a copy should be done using those params and the 441 // mip mapping requirements will be handled there. 442 static bool IsACopyNeededForMips(const GrCaps* caps, const GrTextureProxy* texProxy, 443 GrSamplerState::Filter filter, 444 GrTextureProducer::CopyParams* copyParams); 445 handleDirtyContext()446 void handleDirtyContext() { 447 if (fResetBits) { 448 this->resetContext(); 449 } 450 } 451 452 /** 453 * Returns a key that represents the sampler that will be created for the passed in parameters. 454 * Currently this key is only used when we are building a vulkan pipeline with immutable 455 * samplers. In that case, we need our cache key to also contain this key. 456 * 457 * A return value of 0 indicates that the program/pipeline we are creating is not affected by 458 * the sampler. 459 */ getExtraSamplerKeyForProgram(const GrSamplerState &,const GrBackendFormat &)460 virtual uint32_t getExtraSamplerKeyForProgram(const GrSamplerState&, const GrBackendFormat&) { 461 return 0; 462 } 463 storeVkPipelineCacheData()464 virtual void storeVkPipelineCacheData() {} 465 466 protected: 467 // Handles cases where a surface will be updated without a call to flushRenderTarget. 468 void didWriteToSurface(GrSurface* surface, GrSurfaceOrigin origin, const SkIRect* bounds, 469 uint32_t mipLevels = 1) const; 470 471 Stats fStats; 472 std::unique_ptr<GrPathRendering> fPathRendering; 473 // Subclass must initialize this in its constructor. 474 sk_sp<const GrCaps> fCaps; 475 476 private: 477 // called when the 3D context state is unknown. Subclass should emit any 478 // assumed 3D context state and dirty any state cache. 479 virtual void onResetContext(uint32_t resetBits) = 0; 480 481 // Implementation of resetTextureBindings. onResetTextureBindings()482 virtual void onResetTextureBindings() {} 483 484 // Queries the effective number of samples in use by the hardware for the given render target, 485 // and queries the individual sample locations. 486 virtual void querySampleLocations( 487 GrRenderTarget*, const GrStencilSettings&, SkTArray<SkPoint>*) = 0; 488 489 // Called before certain draws in order to guarantee coherent results from dst reads. 490 virtual void xferBarrier(GrRenderTarget*, GrXferBarrierType) = 0; 491 492 // overridden by backend-specific derived class to create objects. 493 // Texture size and sample size will have already been validated in base class before 494 // onCreateTexture is called. 495 virtual sk_sp<GrTexture> onCreateTexture(const GrSurfaceDesc&, SkBudgeted, 496 const GrMipLevel texels[], int mipLevelCount) = 0; 497 498 virtual sk_sp<GrTexture> onWrapBackendTexture(const GrBackendTexture&, GrWrapOwnership, 499 GrWrapCacheable, GrIOType) = 0; 500 virtual sk_sp<GrTexture> onWrapRenderableBackendTexture(const GrBackendTexture&, int sampleCnt, 501 GrWrapOwnership, GrWrapCacheable) = 0; 502 virtual sk_sp<GrRenderTarget> onWrapBackendRenderTarget(const GrBackendRenderTarget&) = 0; 503 virtual sk_sp<GrRenderTarget> onWrapBackendTextureAsRenderTarget(const GrBackendTexture&, 504 int sampleCnt) = 0; 505 virtual sk_sp<GrRenderTarget> onWrapVulkanSecondaryCBAsRenderTarget(const SkImageInfo&, 506 const GrVkDrawableInfo&); 507 508 virtual sk_sp<GrGpuBuffer> onCreateBuffer(size_t size, GrGpuBufferType intendedType, 509 GrAccessPattern, const void* data) = 0; 510 511 // overridden by backend-specific derived class to perform the surface read 512 virtual bool onReadPixels(GrSurface*, int left, int top, int width, int height, GrColorType, 513 void* buffer, size_t rowBytes) = 0; 514 515 // overridden by backend-specific derived class to perform the surface write 516 virtual bool onWritePixels(GrSurface*, int left, int top, int width, int height, GrColorType, 517 const GrMipLevel texels[], int mipLevelCount) = 0; 518 519 // overridden by backend-specific derived class to perform the texture transfer 520 virtual bool onTransferPixels(GrTexture*, int left, int top, int width, int height, 521 GrColorType colorType, GrGpuBuffer* transferBuffer, size_t offset, 522 size_t rowBytes) = 0; 523 524 // overridden by backend-specific derived class to perform the resolve 525 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; 526 527 // overridden by backend specific derived class to perform mip map level regeneration. 528 virtual bool onRegenerateMipMapLevels(GrTexture*) = 0; 529 530 // overridden by backend specific derived class to perform the copy surface 531 virtual bool onCopySurface(GrSurface* dst, GrSurfaceOrigin dstOrigin, 532 GrSurface* src, GrSurfaceOrigin srcOrigin, 533 const SkIRect& srcRect, const SkIPoint& dstPoint, 534 bool canDiscardOutsideDstRect) = 0; 535 536 virtual void onFinishFlush(GrSurfaceProxy*, SkSurface::BackendSurfaceAccess access, 537 GrFlushFlags flags, bool insertedSemaphores, 538 GrGpuFinishedProc finishedProc, 539 GrGpuFinishedContext finishedContext) = 0; 540 541 #ifdef SK_ENABLE_DUMP_GPU onDumpJSON(SkJSONWriter *)542 virtual void onDumpJSON(SkJSONWriter*) const {} 543 #endif 544 resetContext()545 void resetContext() { 546 this->onResetContext(fResetBits); 547 fResetBits = 0; 548 ++fResetTimestamp; 549 } 550 551 ResetTimestamp fResetTimestamp; 552 uint32_t fResetBits; 553 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. 554 GrContext* fContext; 555 GrSamplePatternDictionary fSamplePatternDictionary; 556 557 friend class GrPathRendering; 558 typedef SkRefCnt INHERITED; 559 }; 560 561 #endif 562