Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(12)

Unified Diff: cc/resources/resource_provider.cc

Issue 490543002: Merge 290367 "Use SkBitmap::readPixels to perform copy to 4444." (Closed) Base URL: svn://svn.chromium.org/chrome/branches/2062/src/
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/resources/resource_provider.cc
===================================================================
--- cc/resources/resource_provider.cc (revision 290559)
+++ cc/resources/resource_provider.cc (working copy)
@@ -109,25 +109,16 @@
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 {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698