diff options
author | feng@chromium.org <feng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-19 15:49:08 +0000 |
---|---|---|
committer | feng@chromium.org <feng@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-08-19 15:49:08 +0000 |
commit | d4c060f02bb5a8be331fbc832f1b826d039274d4 (patch) | |
tree | dc6d7263acaeb933518739f1114e27bdec3cfcbf | |
parent | bf8d76855d1611f5fcd7952605b3d7080234ad7b (diff) | |
download | chromium_src-d4c060f02bb5a8be331fbc832f1b826d039274d4.zip chromium_src-d4c060f02bb5a8be331fbc832f1b826d039274d4.tar.gz chromium_src-d4c060f02bb5a8be331fbc832f1b826d039274d4.tar.bz2 |
Merge 290367 "Use SkBitmap::readPixels to perform copy to 4444."
> Use SkBitmap::readPixels to perform copy to 4444.
>
> readPixels allows specifying the rowBytes, which is important for
> this caller, who wants them to be 4-byte aligned.
>
> BUG=chromium:390782
>
> Review URL: https://codereview.chromium.org/386743002
TBR=scroggo@google.com
Review URL: https://codereview.chromium.org/490543002
git-svn-id: svn://svn.chromium.org/chrome/branches/2062/src@290560 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | cc/resources/resource_provider.cc | 27 |
1 files changed, 9 insertions, 18 deletions
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc index e3c21ff..a3cded5 100644 --- a/cc/resources/resource_provider.cc +++ b/cc/resources/resource_provider.cc @@ -109,25 +109,16 @@ GrPixelConfig ToGrPixelConfig(ResourceFormat format) { return kSkia8888_GrPixelConfig; } -class IdentityAllocator : public SkBitmap::Allocator { - public: - explicit IdentityAllocator(void* buffer) : buffer_(buffer) {} - virtual bool allocPixelRef(SkBitmap* dst, SkColorTable*) OVERRIDE { - dst->setPixels(buffer_); - return true; - } - - private: - void* buffer_; -}; - -void CopyBitmap(const SkBitmap& src, uint8_t* dst, SkColorType dst_colorType) { - SkBitmap dst_bitmap; - IdentityAllocator allocator(dst); - src.copyTo(&dst_bitmap, dst_colorType, &allocator); +void CopyBitmap(const SkBitmap& src, uint8_t* dst, SkColorType dst_color_type) { + SkImageInfo dst_info = src.info(); + dst_info.fColorType = dst_color_type; // TODO(kaanb): The GL pipeline assumes a 4-byte alignment for the - // bitmap data. This check will be removed once crbug.com/293728 is fixed. - CHECK_EQ(0u, dst_bitmap.rowBytes() % 4); + // bitmap data. There will be no need to call SkAlign4 once crbug.com/293728 + // is fixed. + const size_t dst_row_bytes = SkAlign4(dst_info.minRowBytes()); + CHECK_EQ(0u, dst_row_bytes % 4); + bool success = src.readPixels(dst_info, dst, dst_row_bytes, 0, 0); + CHECK_EQ(true, success); } class ScopedSetActiveTexture { |