OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 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 #include "GrVkGpu.h" | 8 #include "GrVkGpu.h" |
9 | 9 |
10 #include "GrContextOptions.h" | 10 #include "GrContextOptions.h" |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 for (int y = 0; y < height; y++) { | 375 for (int y = 0; y < height; y++) { |
376 memcpy(dstRow, srcRow, trimRowBytes); | 376 memcpy(dstRow, srcRow, trimRowBytes); |
377 srcRow += rowBytes; | 377 srcRow += rowBytes; |
378 dstRow -= layout.rowPitch; | 378 dstRow -= layout.rowPitch; |
379 } | 379 } |
380 } else { | 380 } else { |
381 // If there is no padding on the src (rowBytes) or dst (layout.rowPi
tch) we can memcpy | 381 // If there is no padding on the src (rowBytes) or dst (layout.rowPi
tch) we can memcpy |
382 if (trimRowBytes == rowBytes && trimRowBytes == layout.rowPitch) { | 382 if (trimRowBytes == rowBytes && trimRowBytes == layout.rowPitch) { |
383 memcpy(mapPtr, data, trimRowBytes * height); | 383 memcpy(mapPtr, data, trimRowBytes * height); |
384 } else { | 384 } else { |
385 SkRectMemcpy(mapPtr, layout.rowPitch, data, rowBytes, trimRowByt
es, height); | 385 SkRectMemcpy(mapPtr, static_cast<size_t>(layout.rowPitch), data,
rowBytes, |
| 386 trimRowBytes, height); |
386 } | 387 } |
387 } | 388 } |
388 | 389 |
389 GR_VK_CALL(interface, UnmapMemory(fDevice, tex->textureMemory())); | 390 GR_VK_CALL(interface, UnmapMemory(fDevice, tex->textureMemory())); |
390 } else { | 391 } else { |
391 GrVkTransferBuffer* transferBuffer = | 392 GrVkTransferBuffer* transferBuffer = |
392 GrVkTransferBuffer::Create(this, trimRowBytes * height, GrVkBuffer::
kCopyRead_Type); | 393 GrVkTransferBuffer::Create(this, trimRowBytes * height, GrVkBuffer::
kCopyRead_Type); |
393 | 394 |
394 void* mapPtr = transferBuffer->map(); | 395 void* mapPtr = transferBuffer->map(); |
395 | 396 |
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
791 return 0; | 792 return 0; |
792 } | 793 } |
793 | 794 |
794 size_t bpp = GrBytesPerPixel(config); | 795 size_t bpp = GrBytesPerPixel(config); |
795 size_t rowCopyBytes = bpp * w; | 796 size_t rowCopyBytes = bpp * w; |
796 // If there is no padding on dst (layout.rowPitch) we can do a singl
e memcopy. | 797 // If there is no padding on dst (layout.rowPitch) we can do a singl
e memcopy. |
797 // This assumes the srcData comes in with no padding. | 798 // This assumes the srcData comes in with no padding. |
798 if (rowCopyBytes == layout.rowPitch) { | 799 if (rowCopyBytes == layout.rowPitch) { |
799 memcpy(mapPtr, srcData, rowCopyBytes * h); | 800 memcpy(mapPtr, srcData, rowCopyBytes * h); |
800 } else { | 801 } else { |
801 SkRectMemcpy(mapPtr, layout.rowPitch, srcData, w, rowCopyBytes,
h); | 802 SkRectMemcpy(mapPtr, static_cast<size_t>(layout.rowPitch), srcDa
ta, w, rowCopyBytes, |
| 803 h); |
802 } | 804 } |
803 GR_VK_CALL(interface, UnmapMemory(fDevice, imageRsrc->fAlloc)); | 805 GR_VK_CALL(interface, UnmapMemory(fDevice, imageRsrc->fAlloc)); |
804 } else { | 806 } else { |
805 // TODO: Add support for copying to optimal tiling | 807 // TODO: Add support for copying to optimal tiling |
806 SkASSERT(false); | 808 SkASSERT(false); |
807 } | 809 } |
808 } | 810 } |
809 | 811 |
810 return (GrBackendObject)imageRsrc; | 812 return (GrBackendObject)imageRsrc; |
811 } | 813 } |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1408 int set_a_break_pt_here = 9; | 1410 int set_a_break_pt_here = 9; |
1409 aglSwapBuffers(aglGetCurrentContext()); | 1411 aglSwapBuffers(aglGetCurrentContext()); |
1410 #elif defined(SK_BUILD_FOR_WIN32) | 1412 #elif defined(SK_BUILD_FOR_WIN32) |
1411 SwapBuf(); | 1413 SwapBuf(); |
1412 int set_a_break_pt_here = 9; | 1414 int set_a_break_pt_here = 9; |
1413 SwapBuf(); | 1415 SwapBuf(); |
1414 #endif | 1416 #endif |
1415 #endif | 1417 #endif |
1416 } | 1418 } |
1417 | 1419 |
OLD | NEW |