GrGpu.h revision d3312595c86289113ea5994234844388523499e8
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 "GrPipelineBuilder.h" 12#include "GrProgramDesc.h" 13#include "GrStencil.h" 14#include "GrSwizzle.h" 15#include "GrTextureParamsAdjuster.h" 16#include "GrTypes.h" 17#include "GrXferProcessor.h" 18#include "SkPath.h" 19#include "SkTArray.h" 20 21class GrBatchTracker; 22class GrContext; 23class GrGLContext; 24class GrIndexBuffer; 25class GrNonInstancedVertices; 26class GrPath; 27class GrPathRange; 28class GrPathRenderer; 29class GrPathRendererChain; 30class GrPathRendering; 31class GrPipeline; 32class GrPrimitiveProcessor; 33class GrRenderTarget; 34class GrStencilAttachment; 35class GrSurface; 36class GrTexture; 37class GrTransferBuffer; 38class GrVertexBuffer; 39class GrVertices; 40 41class GrGpu : public SkRefCnt { 42public: 43 /** 44 * Create an instance of GrGpu that matches the specified backend. If the requested backend is 45 * not supported (at compile-time or run-time) this returns nullptr. The context will not be 46 * fully constructed and should not be used by GrGpu until after this function returns. 47 */ 48 static GrGpu* Create(GrBackend, GrBackendContext, const GrContextOptions&, GrContext* context); 49 50 //////////////////////////////////////////////////////////////////////////// 51 52 GrGpu(GrContext* context); 53 ~GrGpu() override; 54 55 GrContext* getContext() { return fContext; } 56 const GrContext* getContext() const { return fContext; } 57 58 /** 59 * Gets the capabilities of the draw target. 60 */ 61 const GrCaps* caps() const { return fCaps.get(); } 62 63 GrPathRendering* pathRendering() { return fPathRendering.get(); } 64 65 // Called by GrContext when the underlying backend context has been destroyed. 66 // GrGpu should use this to ensure that no backend API calls will be made from 67 // here onward, including in its destructor. Subclasses should call 68 // INHERITED::contextAbandoned() if they override this. 69 virtual void contextAbandoned(); 70 71 /** 72 * The GrGpu object normally assumes that no outsider is setting state 73 * within the underlying 3D API's context/device/whatever. This call informs 74 * the GrGpu that the state was modified and it shouldn't make assumptions 75 * about the state. 76 */ 77 void markContextDirty(uint32_t state = kAll_GrBackendState) { fResetBits |= state; } 78 79 /** 80 * Creates a texture object. If kRenderTarget_GrSurfaceFlag the texture can 81 * be used as a render target by calling GrTexture::asRenderTarget(). Not all 82 * pixel configs can be used as render targets. Support for configs as textures 83 * or render targets can be checked using GrCaps. 84 * 85 * @param desc describes the texture to be created. 86 * @param budgeted does this texture count against the resource cache budget? 87 * @param texels array of mipmap levels containing texel data to load. 88 * Each level begins with full-size palette data for paletted textures. 89 * For compressed formats the level contains the compressed pixel data. 90 * Otherwise, it contains width*height texels. If there is only one 91 * element and it contains nullptr fPixels, texture data is 92 * uninitialized. 93 * @return The texture object if successful, otherwise nullptr. 94 */ 95 GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, 96 const SkTArray<GrMipLevel>& texels); 97 98 /** 99 * This function is a shim which creates a SkTArGrMipLevell> of size 1. 100 * It then calls createTexture with that SkTArray. 101 * 102 * @param srcData texel data to load texture. Begins with full-size 103 * palette data for paletted texture. For compressed 104 * formats it contains the compressed pixel data. Otherwise, 105 * it contains width*height texels. If nullptr texture data 106 * is uninitialized. 107 * @param rowBytes the number of bytes between consecutive rows. Zero 108 * means rows are tightly packed. This field is ignored 109 * for compressed pixel formats. 110 * @return The texture object if successful, otherwise, nullptr. 111 */ 112 GrTexture* createTexture(const GrSurfaceDesc& desc, SkBudgeted budgeted, 113 const void* srcData, size_t rowBytes); 114 115 /** 116 * Implements GrTextureProvider::wrapBackendTexture 117 */ 118 GrTexture* wrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership); 119 120 /** 121 * Implements GrTextureProvider::wrapBackendRenderTarget 122 */ 123 GrRenderTarget* wrapBackendRenderTarget(const GrBackendRenderTargetDesc&, GrWrapOwnership); 124 125 /** 126 * Implements GrTextureProvider::wrapBackendTextureAsRenderTarget 127 */ 128 GrRenderTarget* wrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&, GrWrapOwnership); 129 130 /** 131 * Creates a vertex buffer. 132 * 133 * @param size size in bytes of the vertex buffer 134 * @param dynamic hints whether the data will be frequently changed 135 * by either GrVertexBuffer::map() or 136 * GrVertexBuffer::updateData(). 137 * 138 * @return The vertex buffer if successful, otherwise nullptr. 139 */ 140 GrVertexBuffer* createVertexBuffer(size_t size, bool dynamic); 141 142 /** 143 * Creates an index buffer. 144 * 145 * @param size size in bytes of the index buffer 146 * @param dynamic hints whether the data will be frequently changed 147 * by either GrIndexBuffer::map() or 148 * GrIndexBuffer::updateData(). 149 * 150 * @return The index buffer if successful, otherwise nullptr. 151 */ 152 GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic); 153 154 /** 155 * Creates a transfer buffer. 156 * 157 * @param size size in bytes of the index buffer 158 * @param toGpu true if used to transfer from the cpu to the gpu 159 * otherwise to be used to transfer from the gpu to the cpu 160 * 161 * @return The transfer buffer if successful, otherwise nullptr. 162 */ 163 GrTransferBuffer* createTransferBuffer(size_t size, TransferType type); 164 165 /** 166 * Resolves MSAA. 167 */ 168 void resolveRenderTarget(GrRenderTarget* target); 169 170 /** Info struct returned by getReadPixelsInfo about performing intermediate draws before 171 reading pixels for performance or correctness. */ 172 struct ReadPixelTempDrawInfo { 173 /** If the GrGpu is requesting that the caller do a draw to an intermediate surface then 174 this is descriptor for the temp surface. The draw should always be a rect with 175 dst 0,0,w,h. */ 176 GrSurfaceDesc fTempSurfaceDesc; 177 /** Indicates whether there is a performance advantage to using an exact match texture 178 (in terms of width and height) for the intermediate texture instead of approximate. */ 179 bool fUseExactScratch; 180 /** Swizzle to apply during the draw. This is used to compensate for either feature or 181 performance limitations in the underlying 3D API. */ 182 GrSwizzle fSwizzle; 183 /** The config that should be used to read from the temp surface after the draw. This may be 184 different than the original read config in order to compensate for swizzling. The 185 read data will effectively be in the original read config. */ 186 GrPixelConfig fReadConfig; 187 }; 188 189 /** Describes why an intermediate draw must/should be performed before readPixels. */ 190 enum DrawPreference { 191 /** On input means that the caller would proceed without draw if the GrGpu doesn't request 192 one. 193 On output means that the GrGpu is not requesting a draw. */ 194 kNoDraw_DrawPreference, 195 /** Means that the client would prefer a draw for performance of the readback but 196 can satisfy a straight readPixels call on the inputs without an intermediate draw. 197 getReadPixelsInfo will never set the draw preference to this value but may leave 198 it set. */ 199 kCallerPrefersDraw_DrawPreference, 200 /** On output means that GrGpu would prefer a draw for performance of the readback but 201 can satisfy a straight readPixels call on the inputs without an intermediate draw. The 202 caller of getReadPixelsInfo should never specify this on intput. */ 203 kGpuPrefersDraw_DrawPreference, 204 /** On input means that the caller requires a draw to do a transformation and there is no 205 CPU fallback. 206 On output means that GrGpu can only satisfy the readPixels request if the intermediate 207 draw is performed. 208 */ 209 kRequireDraw_DrawPreference 210 }; 211 212 /** 213 * Used to negotiate whether and how an intermediate draw should or must be performed before 214 * a readPixels call. If this returns false then GrGpu could not deduce an intermediate draw 215 * that would allow a successful readPixels call. The passed width, height, and rowBytes, 216 * must be non-zero and already reflect clipping to the src bounds. 217 */ 218 bool getReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeight, size_t rowBytes, 219 GrPixelConfig readConfig, DrawPreference*, ReadPixelTempDrawInfo*); 220 221 /** Info struct returned by getWritePixelsInfo about performing an intermediate draw in order 222 to write pixels to a GrSurface for either performance or correctness reasons. */ 223 struct WritePixelTempDrawInfo { 224 /** If the GrGpu is requesting that the caller upload to an intermediate surface and draw 225 that to the dst then this is the descriptor for the intermediate surface. The caller 226 should upload the pixels such that the upper left pixel of the upload rect is at 0,0 in 227 the intermediate surface.*/ 228 GrSurfaceDesc fTempSurfaceDesc; 229 /** Swizzle to apply during the draw. This is used to compensate for either feature or 230 performance limitations in the underlying 3D API. */ 231 GrSwizzle fSwizzle; 232 /** The config that should be specified when uploading the *original* data to the temp 233 surface before the draw. This may be different than the original src data config in 234 order to compensate for swizzling that will occur when drawing. */ 235 GrPixelConfig fWriteConfig; 236 }; 237 238 /** 239 * Used to negotiate whether and how an intermediate surface should be used to write pixels to 240 * a GrSurface. If this returns false then GrGpu could not deduce an intermediate draw 241 * that would allow a successful transfer of the src pixels to the dst. The passed width, 242 * height, and rowBytes, must be non-zero and already reflect clipping to the dst bounds. 243 */ 244 bool getWritePixelsInfo(GrSurface* dstSurface, int width, int height, 245 GrPixelConfig srcConfig, DrawPreference*, WritePixelTempDrawInfo*); 246 247 /** 248 * Reads a rectangle of pixels from a render target. 249 * 250 * @param surface The surface to read from 251 * @param left left edge of the rectangle to read (inclusive) 252 * @param top top edge of the rectangle to read (inclusive) 253 * @param width width of rectangle to read in pixels. 254 * @param height height of rectangle to read in pixels. 255 * @param config the pixel config of the destination buffer 256 * @param buffer memory to read the rectangle into. 257 * @param rowBytes the number of bytes between consecutive rows. Zero 258 * means rows are tightly packed. 259 * @param invertY buffer should be populated bottom-to-top as opposed 260 * to top-to-bottom (skia's usual order) 261 * 262 * @return true if the read succeeded, false if not. The read can fail 263 * because of a unsupported pixel config or because no render 264 * target is currently set. 265 */ 266 bool readPixels(GrSurface* surface, 267 int left, int top, int width, int height, 268 GrPixelConfig config, void* buffer, size_t rowBytes); 269 270 /** 271 * Updates the pixels in a rectangle of a surface. 272 * 273 * @param surface The surface to write to. 274 * @param left left edge of the rectangle to write (inclusive) 275 * @param top top edge of the rectangle to write (inclusive) 276 * @param width width of rectangle to write in pixels. 277 * @param height height of rectangle to write in pixels. 278 * @param config the pixel config of the source buffer 279 * @param texels array of mipmap levels containing texture data 280 */ 281 bool writePixels(GrSurface* surface, 282 int left, int top, int width, int height, 283 GrPixelConfig config, 284 const SkTArray<GrMipLevel>& texels); 285 286 /** 287 * This function is a shim which creates a SkTArray<GrMipLevel> of size 1. 288 * It then calls writePixels with that SkTArray. 289 * 290 * @param buffer memory to read pixels from. 291 * @param rowBytes number of bytes between consecutive rows. Zero 292 * means rows are tightly packed. 293 */ 294 bool writePixels(GrSurface* surface, 295 int left, int top, int width, int height, 296 GrPixelConfig config, const void* buffer, 297 size_t rowBytes); 298 299 /** 300 * Updates the pixels in a rectangle of a surface using a GrTransferBuffer 301 * 302 * @param surface The surface to write to. 303 * @param left left edge of the rectangle to write (inclusive) 304 * @param top top edge of the rectangle to write (inclusive) 305 * @param width width of rectangle to write in pixels. 306 * @param height height of rectangle to write in pixels. 307 * @param config the pixel config of the source buffer 308 * @param buffer GrTransferBuffer to read pixels from 309 * @param offset offset from the start of the buffer 310 * @param rowBytes number of bytes between consecutive rows. Zero 311 * means rows are tightly packed. 312 */ 313 bool transferPixels(GrSurface* surface, 314 int left, int top, int width, int height, 315 GrPixelConfig config, GrTransferBuffer* buffer, 316 size_t offset, size_t rowBytes); 317 318 /** 319 * Clear the passed in render target. Ignores the draw state and clip. 320 */ 321 void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget); 322 323 324 void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget* renderTarget); 325 326 /** 327 * Discards the contents render target. nullptr indicates that the current render target should 328 * be discarded. 329 **/ 330 virtual void discard(GrRenderTarget* = nullptr) = 0; 331 332 /** 333 * This is can be called before allocating a texture to be a dst for copySurface. It will 334 * populate the origin, config, and flags fields of the desc such that copySurface can 335 * efficiently succeed. It should only succeed if it can allow copySurface to perform a copy 336 * that would be more effecient than drawing the src to a dst render target. 337 */ 338 virtual bool initCopySurfaceDstDesc(const GrSurface* src, GrSurfaceDesc* desc) const = 0; 339 340 // After the client interacts directly with the 3D context state the GrGpu 341 // must resync its internal state and assumptions about 3D context state. 342 // Each time this occurs the GrGpu bumps a timestamp. 343 // state of the 3D context 344 // At 10 resets / frame and 60fps a 64bit timestamp will overflow in about 345 // a billion years. 346 typedef uint64_t ResetTimestamp; 347 348 // This timestamp is always older than the current timestamp 349 static const ResetTimestamp kExpiredTimestamp = 0; 350 // Returns a timestamp based on the number of times the context was reset. 351 // This timestamp can be used to lazily detect when cached 3D context state 352 // is dirty. 353 ResetTimestamp getResetTimestamp() const { return fResetTimestamp; } 354 355 virtual void buildProgramDesc(GrProgramDesc*, 356 const GrPrimitiveProcessor&, 357 const GrPipeline&) const = 0; 358 359 // Called to perform a surface to surface copy. Fallbacks to issuing a draw from the src to dst 360 // take place at the GrDrawTarget level and this function implement faster copy paths. The rect 361 // and point are pre-clipped. The src rect and implied dst rect are guaranteed to be within the 362 // src/dst bounds and non-empty. 363 bool copySurface(GrSurface* dst, 364 GrSurface* src, 365 const SkIRect& srcRect, 366 const SkIPoint& dstPoint); 367 368 struct DrawArgs { 369 DrawArgs(const GrPrimitiveProcessor* primProc, 370 const GrPipeline* pipeline, 371 const GrProgramDesc* desc) 372 : fPrimitiveProcessor(primProc) 373 , fPipeline(pipeline) 374 , fDesc(desc) { 375 SkASSERT(primProc && pipeline && desc); 376 } 377 const GrPrimitiveProcessor* fPrimitiveProcessor; 378 const GrPipeline* fPipeline; 379 const GrProgramDesc* fDesc; 380 }; 381 382 void draw(const DrawArgs&, const GrVertices&); 383 384 // Called by drawtarget when flushing. 385 // Provides a hook for post-flush actions (e.g. PLS reset and Vulkan command buffer submits). 386 virtual void finishDrawTarget() {} 387 388 /////////////////////////////////////////////////////////////////////////// 389 // Debugging and Stats 390 391 class Stats { 392 public: 393#if GR_GPU_STATS 394 Stats() { this->reset(); } 395 396 void reset() { 397 fRenderTargetBinds = 0; 398 fShaderCompilations = 0; 399 fTextureCreates = 0; 400 fTextureUploads = 0; 401 fTransfersToTexture = 0; 402 fStencilAttachmentCreates = 0; 403 fNumDraws = 0; 404 } 405 406 int renderTargetBinds() const { return fRenderTargetBinds; } 407 void incRenderTargetBinds() { fRenderTargetBinds++; } 408 int shaderCompilations() const { return fShaderCompilations; } 409 void incShaderCompilations() { fShaderCompilations++; } 410 int textureCreates() const { return fTextureCreates; } 411 void incTextureCreates() { fTextureCreates++; } 412 int textureUploads() const { return fTextureUploads; } 413 void incTextureUploads() { fTextureUploads++; } 414 int transfersToTexture() const { return fTransfersToTexture; } 415 void incTransfersToTexture() { fTransfersToTexture++; } 416 void incStencilAttachmentCreates() { fStencilAttachmentCreates++; } 417 void incNumDraws() { fNumDraws++; } 418 void dump(SkString*); 419 void dumpKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* values); 420 421 private: 422 int fRenderTargetBinds; 423 int fShaderCompilations; 424 int fTextureCreates; 425 int fTextureUploads; 426 int fTransfersToTexture; 427 int fStencilAttachmentCreates; 428 int fNumDraws; 429#else 430 void dump(SkString*) {} 431 void dumpKeyValuePairs(SkTArray<SkString>*, SkTArray<double>*) {} 432 void incRenderTargetBinds() {} 433 void incShaderCompilations() {} 434 void incTextureCreates() {} 435 void incTextureUploads() {} 436 void incTransfersToTexture() {} 437 void incStencilAttachmentCreates() {} 438 void incNumDraws() {} 439#endif 440 }; 441 442 Stats* stats() { return &fStats; } 443 444 /** Creates a texture directly in the backend API without wrapping it in a GrTexture. This is 445 only to be used for testing (particularly for testing the methods that import an externally 446 created texture into Skia. Must be matched with a call to deleteTestingOnlyTexture(). */ 447 virtual GrBackendObject createTestingOnlyBackendTexture(void* pixels, int w, int h, 448 GrPixelConfig config) = 0; 449 /** Check a handle represents an actual texture in the backend API that has not been freed. */ 450 virtual bool isTestingOnlyBackendTexture(GrBackendObject) const = 0; 451 /** If ownership of the backend texture has been transferred pass true for abandonTexture. This 452 will do any necessary cleanup of the handle without freeing the texture in the backend 453 API. */ 454 virtual void deleteTestingOnlyBackendTexture(GrBackendObject, 455 bool abandonTexture = false) = 0; 456 457 // width and height may be larger than rt (if underlying API allows it). 458 // Returns nullptr if compatible sb could not be created, otherwise the caller owns the ref on 459 // the GrStencilAttachment. 460 virtual GrStencilAttachment* createStencilAttachmentForRenderTarget(const GrRenderTarget*, 461 int width, 462 int height) = 0; 463 // clears target's entire stencil buffer to 0 464 virtual void clearStencil(GrRenderTarget* target) = 0; 465 466 // draws an outline rectangle for debugging/visualization purposes. 467 virtual void drawDebugWireRect(GrRenderTarget*, const SkIRect&, GrColor) = 0; 468 469 // Determines whether a texture will need to be rescaled in order to be used with the 470 // GrTextureParams. This variation is called when the caller will create a new texture using the 471 // texture provider from a non-texture src (cpu-backed image, ...). 472 bool makeCopyForTextureParams(int width, int height, const GrTextureParams&, 473 GrTextureProducer::CopyParams*) const; 474 475 // Like the above but this variation should be called when the caller is not creating the 476 // original texture but rather was handed the original texture. It adds additional checks 477 // relevant to original textures that were created external to Skia via 478 // GrTextureProvider::wrap methods. 479 bool makeCopyForTextureParams(GrTexture* texture, const GrTextureParams& params, 480 GrTextureProducer::CopyParams* copyParams) const { 481 if (this->makeCopyForTextureParams(texture->width(), texture->height(), params, 482 copyParams)) { 483 return true; 484 } 485 return this->onMakeCopyForTextureParams(texture, params, copyParams); 486 } 487 488 // This is only to be used in GL-specific tests. 489 virtual const GrGLContext* glContextForTesting() const { return nullptr; } 490 491 // This is only to be used by testing code 492 virtual void resetShaderCacheForTesting() const {} 493 494protected: 495 // Functions used to map clip-respecting stencil tests into normal 496 // stencil funcs supported by GPUs. 497 static GrStencilFunc ConvertStencilFunc(bool stencilInClip, 498 GrStencilFunc func); 499 static void ConvertStencilFuncAndMask(GrStencilFunc func, 500 bool clipInStencil, 501 unsigned int clipBit, 502 unsigned int userBits, 503 unsigned int* ref, 504 unsigned int* mask); 505 506 static void ElevateDrawPreference(GrGpu::DrawPreference* preference, 507 GrGpu::DrawPreference elevation) { 508 GR_STATIC_ASSERT(GrGpu::kCallerPrefersDraw_DrawPreference > GrGpu::kNoDraw_DrawPreference); 509 GR_STATIC_ASSERT(GrGpu::kGpuPrefersDraw_DrawPreference > 510 GrGpu::kCallerPrefersDraw_DrawPreference); 511 GR_STATIC_ASSERT(GrGpu::kRequireDraw_DrawPreference > 512 GrGpu::kGpuPrefersDraw_DrawPreference); 513 *preference = SkTMax(*preference, elevation); 514 } 515 516 void handleDirtyContext() { 517 if (fResetBits) { 518 this->resetContext(); 519 } 520 } 521 522 Stats fStats; 523 SkAutoTDelete<GrPathRendering> fPathRendering; 524 // Subclass must initialize this in its constructor. 525 SkAutoTUnref<const GrCaps> fCaps; 526 527private: 528 // called when the 3D context state is unknown. Subclass should emit any 529 // assumed 3D context state and dirty any state cache. 530 virtual void onResetContext(uint32_t resetBits) = 0; 531 532 // Called before certain draws in order to guarantee coherent results from dst reads. 533 virtual void xferBarrier(GrRenderTarget*, GrXferBarrierType) = 0; 534 535 // overridden by backend-specific derived class to create objects. 536 // Texture size and sample size will have already been validated in base class before 537 // onCreateTexture/CompressedTexture are called. 538 virtual GrTexture* onCreateTexture(const GrSurfaceDesc& desc, 539 GrGpuResource::LifeCycle lifeCycle, 540 const SkTArray<GrMipLevel>& texels) = 0; 541 virtual GrTexture* onCreateCompressedTexture(const GrSurfaceDesc& desc, 542 GrGpuResource::LifeCycle lifeCycle, 543 const SkTArray<GrMipLevel>& texels) = 0; 544 545 virtual GrTexture* onWrapBackendTexture(const GrBackendTextureDesc&, GrWrapOwnership) = 0; 546 virtual GrRenderTarget* onWrapBackendRenderTarget(const GrBackendRenderTargetDesc&, 547 GrWrapOwnership) = 0; 548 virtual GrRenderTarget* onWrapBackendTextureAsRenderTarget(const GrBackendTextureDesc&, 549 GrWrapOwnership) = 0; 550 virtual GrVertexBuffer* onCreateVertexBuffer(size_t size, bool dynamic) = 0; 551 virtual GrIndexBuffer* onCreateIndexBuffer(size_t size, bool dynamic) = 0; 552 virtual GrTransferBuffer* onCreateTransferBuffer(size_t size, TransferType type) = 0; 553 554 // overridden by backend-specific derived class to perform the clear. 555 virtual void onClear(GrRenderTarget*, const SkIRect& rect, GrColor color) = 0; 556 557 558 // Overridden by backend specific classes to perform a clear of the stencil clip bits. This is 559 // ONLY used by the the clip target 560 virtual void onClearStencilClip(GrRenderTarget*, const SkIRect& rect, bool insideClip) = 0; 561 562 // overridden by backend-specific derived class to perform the draw call. 563 virtual void onDraw(const DrawArgs&, const GrNonInstancedVertices&) = 0; 564 565 virtual bool onMakeCopyForTextureParams(GrTexture* texture, const GrTextureParams&, 566 GrTextureProducer::CopyParams*) const { return false; } 567 568 virtual bool onGetReadPixelsInfo(GrSurface* srcSurface, int readWidth, int readHeight, 569 size_t rowBytes, GrPixelConfig readConfig, DrawPreference*, 570 ReadPixelTempDrawInfo*) = 0; 571 virtual bool onGetWritePixelsInfo(GrSurface* dstSurface, int width, int height, 572 GrPixelConfig srcConfig, DrawPreference*, 573 WritePixelTempDrawInfo*) = 0; 574 575 // overridden by backend-specific derived class to perform the surface read 576 virtual bool onReadPixels(GrSurface*, 577 int left, int top, 578 int width, int height, 579 GrPixelConfig, 580 void* buffer, 581 size_t rowBytes) = 0; 582 583 // overridden by backend-specific derived class to perform the surface write 584 virtual bool onWritePixels(GrSurface*, 585 int left, int top, int width, int height, 586 GrPixelConfig config, 587 const SkTArray<GrMipLevel>& texels) = 0; 588 589 // overridden by backend-specific derived class to perform the surface write 590 virtual bool onTransferPixels(GrSurface*, 591 int left, int top, int width, int height, 592 GrPixelConfig config, GrTransferBuffer* buffer, 593 size_t offset, size_t rowBytes) = 0; 594 595 // overridden by backend-specific derived class to perform the resolve 596 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; 597 598 // overridden by backend specific derived class to perform the copy surface 599 virtual bool onCopySurface(GrSurface* dst, 600 GrSurface* src, 601 const SkIRect& srcRect, 602 const SkIPoint& dstPoint) = 0; 603 604 void resetContext() { 605 this->onResetContext(fResetBits); 606 fResetBits = 0; 607 ++fResetTimestamp; 608 } 609 610 ResetTimestamp fResetTimestamp; 611 uint32_t fResetBits; 612 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. 613 GrContext* fContext; 614 615 friend class GrPathRendering; 616 typedef SkRefCnt INHERITED; 617}; 618 619#endif 620