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

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: rebase 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
Index: cc/resources/resource_provider.cc
diff --git a/cc/resources/resource_provider.cc b/cc/resources/resource_provider.cc
index 1cb215bd20993c51ead0dc647575d86e6f535eb3..74c96fbee2254932f047fe7f3bc54865e07ddaba 100644
--- a/cc/resources/resource_provider.cc
+++ b/cc/resources/resource_provider.cc
@@ -448,10 +448,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:
@@ -482,19 +480,16 @@ 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());
+ raster_bitmap_.installPixels(info, mapped_buffer_, stride);
break;
+ }
case LUMINANCE_8:
case RGB_565:
case ETC1:
@@ -926,21 +921,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.width() <= image_rect.width());
+ DCHECK(source_rect.height() <= image_rect.height());
+ SkImageInfo info =
+ SkImageInfo::MakeN32Premul(source_rect.width(), source_rect.height());
+ size_t rowBytes = image_rect.width() * 4;
+ int dx = source_rect.x() - image_rect.x();
+ int dy = source_rect.y() - image_rect.y();
+ image += dy * rowBytes + dx * 4;
Stephen White 2014/03/18 20:14:07 IWBN if we could still put the full image in an Sk
reed1 2014/03/21 20:49:01 Doesn't work against it per-se, but given that thi
ScopedWriteLockSoftware lock(this, id);
SkCanvas* dest = lock.sk_canvas();
- dest->writePixels(src_subset, dest_offset.x(), dest_offset.y());
+ dest->writePixels(info, image, rowBytes, dest_offset.x(), dest_offset.y());
}
}
@@ -1168,10 +1162,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(

Powered by Google App Engine
This is Rietveld 408576698