OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 <cstddef> | 8 #include <cstddef> |
9 #include <cstring> | 9 #include <cstring> |
10 #include <type_traits> | 10 #include <type_traits> |
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 402 |
403 | 403 |
404 return shouldUseMipMaps; | 404 return shouldUseMipMaps; |
405 } | 405 } |
406 | 406 |
407 namespace { | 407 namespace { |
408 | 408 |
409 class DTIBufferFiller | 409 class DTIBufferFiller |
410 { | 410 { |
411 public: | 411 public: |
412 explicit DTIBufferFiller(intptr_t bufferAsInt) | 412 explicit DTIBufferFiller(uintptr_t bufferAsInt) |
413 : bufferAsInt_(bufferAsInt) {} | 413 : bufferAsInt_(bufferAsInt) {} |
414 | 414 |
415 void fillMember(const void* source, size_t memberOffset, size_t size) { | 415 void fillMember(const void* source, size_t memberOffset, size_t size) { |
416 memcpy(reinterpret_cast<void*>(bufferAsInt_ + memberOffset), source, siz
e); | 416 memcpy(reinterpret_cast<void*>(bufferAsInt_ + memberOffset), source, siz
e); |
417 } | 417 } |
418 | 418 |
419 private: | 419 private: |
420 | 420 |
421 intptr_t bufferAsInt_; | 421 uintptr_t bufferAsInt_; |
422 }; | 422 }; |
423 } | 423 } |
424 | 424 |
425 #define FILL_MEMBER(bufferFiller, member, source) \ | 425 #define FILL_MEMBER(bufferFiller, member, source) \ |
426 bufferFiller.fillMember(source, \ | 426 bufferFiller.fillMember(source, \ |
427 offsetof(DeferredTextureImage, member), \ | 427 offsetof(DeferredTextureImage, member), \ |
428 sizeof(DeferredTextureImage::member)); | 428 sizeof(DeferredTextureImage::member)); |
429 | 429 |
430 size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& prox
y, | 430 size_t SkImage::getDeferredTextureImageData(const GrContextThreadSafeProxy& prox
y, |
431 const DeferredTextureImageUsageParam
s params[], | 431 const DeferredTextureImageUsageParam
s params[], |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 size_t colorSpaceOffset = 0; | 545 size_t colorSpaceOffset = 0; |
546 size_t colorSpaceSize = 0; | 546 size_t colorSpaceSize = 0; |
547 if (info.colorSpace()) { | 547 if (info.colorSpace()) { |
548 colorSpaceOffset = size; | 548 colorSpaceOffset = size; |
549 colorSpaceSize = info.colorSpace()->writeToMemory(nullptr); | 549 colorSpaceSize = info.colorSpace()->writeToMemory(nullptr); |
550 size += colorSpaceSize; | 550 size += colorSpaceSize; |
551 } | 551 } |
552 if (!fillMode) { | 552 if (!fillMode) { |
553 return size; | 553 return size; |
554 } | 554 } |
555 intptr_t bufferAsInt = reinterpret_cast<intptr_t>(buffer); | 555 uintptr_t bufferAsInt = reinterpret_cast<uintptr_t>(buffer); |
556 intptr_t pixelsAsInt = bufferAsInt + pixelOffset; | 556 uintptr_t pixelsAsInt = bufferAsInt + pixelOffset; |
557 void* pixels = reinterpret_cast<void*>(pixelsAsInt); | 557 void* pixels = reinterpret_cast<void*>(pixelsAsInt); |
558 void* ct = nullptr; | 558 void* ct = nullptr; |
559 if (ctSize) { | 559 if (ctSize) { |
560 ct = reinterpret_cast<void*>(bufferAsInt + ctOffset); | 560 ct = reinterpret_cast<void*>(bufferAsInt + ctOffset); |
561 } | 561 } |
562 | 562 |
563 memcpy(reinterpret_cast<void*>(SkAlign8(pixelsAsInt)), pixmap.addr(), pixmap
.getSafeSize()); | 563 memcpy(reinterpret_cast<void*>(SkAlign8(pixelsAsInt)), pixmap.addr(), pixmap
.getSafeSize()); |
564 if (ctSize) { | 564 if (ctSize) { |
565 memcpy(ct, pixmap.ctable()->readColors(), ctSize); | 565 memcpy(ct, pixmap.ctable()->readColors(), ctSize); |
566 } | 566 } |
(...skipping 30 matching lines...) Expand all Loading... |
597 } else { | 597 } else { |
598 memset(reinterpret_cast<void*>(bufferAsInt + | 598 memset(reinterpret_cast<void*>(bufferAsInt + |
599 offsetof(DeferredTextureImage, fColorSpac
e)), | 599 offsetof(DeferredTextureImage, fColorSpac
e)), |
600 0, sizeof(DeferredTextureImage::fColorSpace)); | 600 0, sizeof(DeferredTextureImage::fColorSpace)); |
601 memset(reinterpret_cast<void*>(bufferAsInt + | 601 memset(reinterpret_cast<void*>(bufferAsInt + |
602 offsetof(DeferredTextureImage, fColorSpac
eSize)), | 602 offsetof(DeferredTextureImage, fColorSpac
eSize)), |
603 0, sizeof(DeferredTextureImage::fColorSpaceSize)); | 603 0, sizeof(DeferredTextureImage::fColorSpaceSize)); |
604 } | 604 } |
605 | 605 |
606 // Fill in the mipmap levels if they exist | 606 // Fill in the mipmap levels if they exist |
607 intptr_t mipLevelPtr = pixelsAsInt + SkAlign8(pixmap.getSafeSize()); | 607 uintptr_t mipLevelPtr = pixelsAsInt + SkAlign8(pixmap.getSafeSize()); |
608 | 608 |
609 if (useMipMaps) { | 609 if (useMipMaps) { |
610 static_assert(std::is_standard_layout<MipMapLevelData>::value, | 610 static_assert(std::is_standard_layout<MipMapLevelData>::value, |
611 "offsetof, which we use below, requires the type have a st
andard layout"); | 611 "offsetof, which we use below, requires the type have a st
andard layout"); |
612 | 612 |
613 SkAutoTDelete<SkMipMap> mipmaps(SkMipMap::Build(pixmap, gammaTreatment,
nullptr)); | 613 SkAutoTDelete<SkMipMap> mipmaps(SkMipMap::Build(pixmap, gammaTreatment,
nullptr)); |
614 // SkMipMap holds only the mipmap levels it generates. | 614 // SkMipMap holds only the mipmap levels it generates. |
615 // A programmer can use the data they provided to SkMipMap::Build as lev
el 0. | 615 // A programmer can use the data they provided to SkMipMap::Build as lev
el 0. |
616 // So the SkMipMap provides levels 1-x but it stores them in its own | 616 // So the SkMipMap provides levels 1-x but it stores them in its own |
617 // range 0-(x-1). | 617 // range 0-(x-1). |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
708 } | 708 } |
709 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m
ipLevelCount)); | 709 SkAutoTUnref<GrTexture> texture(GrUploadMipMapToTexture(ctx, info, texels, m
ipLevelCount)); |
710 if (!texture) { | 710 if (!texture) { |
711 return nullptr; | 711 return nullptr; |
712 } | 712 } |
713 texture->texturePriv().setGammaTreatment(gammaTreatment); | 713 texture->texturePriv().setGammaTreatment(gammaTreatment); |
714 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, | 714 return sk_make_sp<SkImage_Gpu>(texture->width(), texture->height(), kNeedNew
ImageUniqueID, |
715 info.alphaType(), texture, sk_ref_sp(info.col
orSpace()), | 715 info.alphaType(), texture, sk_ref_sp(info.col
orSpace()), |
716 budgeted); | 716 budgeted); |
717 } | 717 } |
OLD | NEW |