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

Unified Diff: cc/resources/resource_provider.cc

Issue 386743002: Use SkBitmap::readPixels to perform copy to 4444. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index cf79940c44f36c87384c99fc9730c20d19e9411c..9b7d9b17ec294a5626c14f943d581e07723552a8 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);
+ SkImageInfo dst_info = src.info();
+ dst_info.fColorType = dst_colorType;
enne (OOO) 2014/07/24 17:58:18 This was here before you, but you can you make thi
scroggo 2014/07/24 18:11:38 Done.
// 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