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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 * | 122 * |
123 * @param size size in bytes of the index buffer | 123 * @param size size in bytes of the index buffer |
124 * @param dynamic hints whether the data will be frequently changed | 124 * @param dynamic hints whether the data will be frequently changed |
125 * by either GrIndexBuffer::map() or | 125 * by either GrIndexBuffer::map() or |
126 * GrIndexBuffer::updateData(). | 126 * GrIndexBuffer::updateData(). |
127 * | 127 * |
128 * @return The index buffer if successful, otherwise nullptr. | 128 * @return The index buffer if successful, otherwise nullptr. |
129 */ | 129 */ |
130 GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic); | 130 GrIndexBuffer* createIndexBuffer(size_t size, bool dynamic); |
131 | 131 |
132 enum TransferType { | |
133 kCpuToGpu_TransferType, | |
134 kGpuToCpu_TransferType | |
135 }; | |
136 | |
137 /** | 132 /** |
138 * Creates a transfer buffer. | 133 * Creates a transfer buffer. |
139 * | 134 * |
140 * @param size size in bytes of the index buffer | 135 * @param size size in bytes of the index buffer |
141 * @param toGpu true if used to transfer from the cpu to the gpu | 136 * @param toGpu true if used to transfer from the cpu to the gpu |
142 * otherwise to be used to transfer from the gpu to the cpu | 137 * otherwise to be used to transfer from the gpu to the cpu |
143 * | 138 * |
144 * @return The transfer buffer if successful, otherwise nullptr. | 139 * @return The transfer buffer if successful, otherwise nullptr. |
145 */ | 140 */ |
146 GrTransferBuffer* createTransferBuffer(size_t size, TransferType type); | 141 GrTransferBuffer* createTransferBuffer(size_t size, TransferType type); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 * @param buffer memory to read pixels from | 254 * @param buffer memory to read pixels from |
260 * @param rowBytes number of bytes between consecutive rows. Zero | 255 * @param rowBytes number of bytes between consecutive rows. Zero |
261 * means rows are tightly packed. | 256 * means rows are tightly packed. |
262 */ | 257 */ |
263 bool writePixels(GrSurface* surface, | 258 bool writePixels(GrSurface* surface, |
264 int left, int top, int width, int height, | 259 int left, int top, int width, int height, |
265 GrPixelConfig config, const void* buffer, | 260 GrPixelConfig config, const void* buffer, |
266 size_t rowBytes); | 261 size_t rowBytes); |
267 | 262 |
268 /** | 263 /** |
| 264 * Updates the pixels in a rectangle of a surface using a GrTransferBuffer |
| 265 * |
| 266 * @param surface The surface to write to. |
| 267 * @param left left edge of the rectangle to write (inclusive) |
| 268 * @param top top edge of the rectangle to write (inclusive) |
| 269 * @param width width of rectangle to write in pixels. |
| 270 * @param height height of rectangle to write in pixels. |
| 271 * @param config the pixel config of the source buffer |
| 272 * @param buffer GrTransferBuffer to read pixels from |
| 273 * @param offset offset from the start of the buffer |
| 274 * @param rowBytes number of bytes between consecutive rows. Zero |
| 275 * means rows are tightly packed. |
| 276 */ |
| 277 bool transferPixels(GrSurface* surface, |
| 278 int left, int top, int width, int height, |
| 279 GrPixelConfig config, GrTransferBuffer* buffer, |
| 280 size_t offset, size_t rowBytes); |
| 281 |
| 282 /** |
269 * Clear the passed in render target. Ignores the draw state and clip. | 283 * Clear the passed in render target. Ignores the draw state and clip. |
270 */ | 284 */ |
271 void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget)
; | 285 void clear(const SkIRect& rect, GrColor color, GrRenderTarget* renderTarget)
; |
272 | 286 |
273 | 287 |
274 void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget*
renderTarget); | 288 void clearStencilClip(const SkIRect& rect, bool insideClip, GrRenderTarget*
renderTarget); |
275 | 289 |
276 /** | 290 /** |
277 * Discards the contents render target. nullptr indicates that the current r
ender target should | 291 * Discards the contents render target. nullptr indicates that the current r
ender target should |
278 * be discarded. | 292 * be discarded. |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 class Stats { | 351 class Stats { |
338 public: | 352 public: |
339 #if GR_GPU_STATS | 353 #if GR_GPU_STATS |
340 Stats() { this->reset(); } | 354 Stats() { this->reset(); } |
341 | 355 |
342 void reset() { | 356 void reset() { |
343 fRenderTargetBinds = 0; | 357 fRenderTargetBinds = 0; |
344 fShaderCompilations = 0; | 358 fShaderCompilations = 0; |
345 fTextureCreates = 0; | 359 fTextureCreates = 0; |
346 fTextureUploads = 0; | 360 fTextureUploads = 0; |
| 361 fTransfersToTexture = 0; |
347 fStencilAttachmentCreates = 0; | 362 fStencilAttachmentCreates = 0; |
348 fNumDraws = 0; | 363 fNumDraws = 0; |
349 } | 364 } |
350 | 365 |
351 int renderTargetBinds() const { return fRenderTargetBinds; } | 366 int renderTargetBinds() const { return fRenderTargetBinds; } |
352 void incRenderTargetBinds() { fRenderTargetBinds++; } | 367 void incRenderTargetBinds() { fRenderTargetBinds++; } |
353 int shaderCompilations() const { return fShaderCompilations; } | 368 int shaderCompilations() const { return fShaderCompilations; } |
354 void incShaderCompilations() { fShaderCompilations++; } | 369 void incShaderCompilations() { fShaderCompilations++; } |
355 int textureCreates() const { return fTextureCreates; } | 370 int textureCreates() const { return fTextureCreates; } |
356 void incTextureCreates() { fTextureCreates++; } | 371 void incTextureCreates() { fTextureCreates++; } |
357 int textureUploads() const { return fTextureUploads; } | 372 int textureUploads() const { return fTextureUploads; } |
358 void incTextureUploads() { fTextureUploads++; } | 373 void incTextureUploads() { fTextureUploads++; } |
| 374 int transfersToTexture() const { return fTransfersToTexture; } |
| 375 void incTransfersToTexture() { fTransfersToTexture++; } |
359 void incStencilAttachmentCreates() { fStencilAttachmentCreates++; } | 376 void incStencilAttachmentCreates() { fStencilAttachmentCreates++; } |
360 void incNumDraws() { fNumDraws++; } | 377 void incNumDraws() { fNumDraws++; } |
361 void dump(SkString*); | 378 void dump(SkString*); |
362 void dumpKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* value
s); | 379 void dumpKeyValuePairs(SkTArray<SkString>* keys, SkTArray<double>* value
s); |
363 | 380 |
364 private: | 381 private: |
365 int fRenderTargetBinds; | 382 int fRenderTargetBinds; |
366 int fShaderCompilations; | 383 int fShaderCompilations; |
367 int fTextureCreates; | 384 int fTextureCreates; |
368 int fTextureUploads; | 385 int fTextureUploads; |
| 386 int fTransfersToTexture; |
369 int fStencilAttachmentCreates; | 387 int fStencilAttachmentCreates; |
370 int fNumDraws; | 388 int fNumDraws; |
371 #else | 389 #else |
372 void dump(SkString*) {} | 390 void dump(SkString*) {} |
373 void dumpKeyValuePairs(SkTArray<SkString>*, SkTArray<double>*) {} | 391 void dumpKeyValuePairs(SkTArray<SkString>*, SkTArray<double>*) {} |
374 void incRenderTargetBinds() {} | 392 void incRenderTargetBinds() {} |
375 void incShaderCompilations() {} | 393 void incShaderCompilations() {} |
376 void incTextureCreates() {} | 394 void incTextureCreates() {} |
377 void incTextureUploads() {} | 395 void incTextureUploads() {} |
| 396 void incTransfersToTexture() {} |
378 void incStencilAttachmentCreates() {} | 397 void incStencilAttachmentCreates() {} |
379 void incNumDraws() {} | 398 void incNumDraws() {} |
380 #endif | 399 #endif |
381 }; | 400 }; |
382 | 401 |
383 Stats* stats() { return &fStats; } | 402 Stats* stats() { return &fStats; } |
384 | 403 |
385 /** Creates a texture directly in the backend API without wrapping it in a G
rTexture. This is | 404 /** Creates a texture directly in the backend API without wrapping it in a G
rTexture. This is |
386 only to be used for testing (particularly for testing the methods that i
mport an externally | 405 only to be used for testing (particularly for testing the methods that i
mport an externally |
387 created texture into Skia. Must be matched with a call to deleteTestingO
nlyTexture(). */ | 406 created texture into Skia. Must be matched with a call to deleteTestingO
nlyTexture(). */ |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 GrPixelConfig, | 520 GrPixelConfig, |
502 void* buffer, | 521 void* buffer, |
503 size_t rowBytes) = 0; | 522 size_t rowBytes) = 0; |
504 | 523 |
505 // overridden by backend-specific derived class to perform the surface write | 524 // overridden by backend-specific derived class to perform the surface write |
506 virtual bool onWritePixels(GrSurface*, | 525 virtual bool onWritePixels(GrSurface*, |
507 int left, int top, int width, int height, | 526 int left, int top, int width, int height, |
508 GrPixelConfig config, const void* buffer, | 527 GrPixelConfig config, const void* buffer, |
509 size_t rowBytes) = 0; | 528 size_t rowBytes) = 0; |
510 | 529 |
| 530 // overridden by backend-specific derived class to perform the surface write |
| 531 virtual bool onTransferPixels(GrSurface*, |
| 532 int left, int top, int width, int height, |
| 533 GrPixelConfig config, GrTransferBuffer* buffer
, |
| 534 size_t offset, size_t rowBytes) = 0; |
| 535 |
511 // overridden by backend-specific derived class to perform the resolve | 536 // overridden by backend-specific derived class to perform the resolve |
512 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; | 537 virtual void onResolveRenderTarget(GrRenderTarget* target) = 0; |
513 | 538 |
514 // overridden by backend specific derived class to perform the copy surface | 539 // overridden by backend specific derived class to perform the copy surface |
515 virtual bool onCopySurface(GrSurface* dst, | 540 virtual bool onCopySurface(GrSurface* dst, |
516 GrSurface* src, | 541 GrSurface* src, |
517 const SkIRect& srcRect, | 542 const SkIRect& srcRect, |
518 const SkIPoint& dstPoint) = 0; | 543 const SkIPoint& dstPoint) = 0; |
519 | 544 |
520 void resetContext() { | 545 void resetContext() { |
521 this->onResetContext(fResetBits); | 546 this->onResetContext(fResetBits); |
522 fResetBits = 0; | 547 fResetBits = 0; |
523 ++fResetTimestamp; | 548 ++fResetTimestamp; |
524 } | 549 } |
525 | 550 |
526 ResetTimestamp fResetTi
mestamp; | 551 ResetTimestamp fResetTi
mestamp; |
527 uint32_t fResetBi
ts; | 552 uint32_t fResetBi
ts; |
528 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. | 553 // The context owns us, not vice-versa, so this ptr is not ref'ed by Gpu. |
529 GrContext* fContext
; | 554 GrContext* fContext
; |
530 | 555 |
531 friend class GrPathRendering; | 556 friend class GrPathRendering; |
532 typedef SkRefCnt INHERITED; | 557 typedef SkRefCnt INHERITED; |
533 }; | 558 }; |
534 | 559 |
535 #endif | 560 #endif |
OLD | NEW |