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

Unified Diff: cc/resources/resource_provider.cc

Issue 197883017: SkColorType instead of (deprecated) SkBitmap::Config (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments from #5 Created 6 years, 9 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 | « cc/resources/picture_pile_impl_unittest.cc ('k') | cc/resources/resource_provider_unittest.cc » ('j') | 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 55dafbd47d20e36196a8924b800c97cbbc9191db..a8e0e9ffa07b7e798c5240055040d0320e2ee47b 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -449,10 +449,8 @@ skia::RefPtr<SkSurface> ResourceProvider::DirectRasterBuffer::CreateSurface() {
DCHECK_EQ(RGBA_8888, resource()->format);
SkImageInfo image_info = SkImageInfo::MakeN32Premul(
resource()->size.width(), resource()->size.height());
- size_t row_bytes = SkBitmap::ComputeRowBytes(SkBitmap::kARGB_8888_Config,
- resource()->size.width());
surface = skia::AdoptRef(SkSurface::NewRasterDirect(
- image_info, resource()->pixels, row_bytes));
+ image_info, resource()->pixels, image_info.minRowBytes()));
break;
}
default:
@@ -483,19 +481,18 @@ SkCanvas* ResourceProvider::BitmapRasterBuffer::DoLockForWrite() {
case RGBA_4444:
// Use the default stride if we will eventually convert this
// bitmap to 4444.
- raster_bitmap_.setConfig(SkBitmap::kARGB_8888_Config,
- resource()->size.width(),
- resource()->size.height());
- raster_bitmap_.allocPixels();
+ raster_bitmap_.allocN32Pixels(resource()->size.width(),
+ resource()->size.height());
break;
case RGBA_8888:
- case BGRA_8888:
- raster_bitmap_.setConfig(SkBitmap::kARGB_8888_Config,
- resource()->size.width(),
- resource()->size.height(),
- stride);
- raster_bitmap_.setPixels(mapped_buffer_);
+ case BGRA_8888: {
+ SkImageInfo info = SkImageInfo::MakeN32Premul(resource()->size.width(),
+ resource()->size.height());
+ if (0 == stride)
+ stride = info.minRowBytes();
+ raster_bitmap_.installPixels(info, mapped_buffer_, stride);
break;
+ }
case LUMINANCE_8:
case RGB_565:
case ETC1:
@@ -933,21 +930,20 @@ void ResourceProvider::SetPixels(ResourceId id,
DCHECK_EQ(Bitmap, resource->type);
DCHECK(resource->allocated);
DCHECK_EQ(RGBA_8888, resource->format);
- SkBitmap src_full;
- src_full.setConfig(
- SkBitmap::kARGB_8888_Config, image_rect.width(), image_rect.height());
- src_full.setPixels(const_cast<uint8_t*>(image));
- SkBitmap src_subset;
- SkIRect sk_source_rect = SkIRect::MakeXYWH(source_rect.x(),
- source_rect.y(),
- source_rect.width(),
- source_rect.height());
- sk_source_rect.offset(-image_rect.x(), -image_rect.y());
- src_full.extractSubset(&src_subset, sk_source_rect);
+ DCHECK(source_rect.x() >= image_rect.x());
+ DCHECK(source_rect.y() >= image_rect.y());
+ DCHECK(source_rect.right() <= image_rect.right());
+ DCHECK(source_rect.bottom() <= image_rect.bottom());
+ SkImageInfo source_info =
+ SkImageInfo::MakeN32Premul(source_rect.width(), source_rect.height());
+ size_t image_row_bytes = image_rect.width() * 4;
+ gfx::Vector2d source_offset = source_rect.origin() - image_rect.origin();
+ image += source_offset.y() * image_row_bytes + source_offset.x() * 4;
ScopedWriteLockSoftware lock(this, id);
SkCanvas* dest = lock.sk_canvas();
- dest->writePixels(src_subset, dest_offset.x(), dest_offset.y());
+ dest->writePixels(
+ source_info, image, image_row_bytes, dest_offset.x(), dest_offset.y());
}
}
@@ -1175,10 +1171,9 @@ ResourceProvider::ScopedWriteLockGL::~ScopedWriteLockGL() {
void ResourceProvider::PopulateSkBitmapWithResource(
SkBitmap* sk_bitmap, const Resource* resource) {
DCHECK_EQ(RGBA_8888, resource->format);
- sk_bitmap->setConfig(SkBitmap::kARGB_8888_Config,
- resource->size.width(),
- resource->size.height());
- sk_bitmap->setPixels(resource->pixels);
+ SkImageInfo info = SkImageInfo::MakeN32Premul(resource->size.width(),
+ resource->size.height());
+ sk_bitmap->installPixels(info, resource->pixels, info.minRowBytes());
}
ResourceProvider::ScopedReadLockSoftware::ScopedReadLockSoftware(
« no previous file with comments | « cc/resources/picture_pile_impl_unittest.cc ('k') | cc/resources/resource_provider_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698