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

Unified Diff: cc/tiles/software_image_decode_controller.cc

Issue 1808633002: Use preferred format to allocate memory for decoded images (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comment Created 4 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/tiles/software_image_decode_controller.h ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/tiles/software_image_decode_controller.cc
diff --git a/cc/tiles/software_image_decode_controller.cc b/cc/tiles/software_image_decode_controller.cc
index e4fc39eb68878c0ecf53a5e269d9bdc3946b8d10..987dd8be6ceeb5ae17143a7837c93598147fa131 100644
--- a/cc/tiles/software_image_decode_controller.cc
+++ b/cc/tiles/software_image_decode_controller.cc
@@ -107,12 +107,43 @@ SkFilterQuality GetDecodedFilterQuality(const ImageDecodeControllerKey& key) {
return std::min(key.filter_quality(), kLow_SkFilterQuality);
}
+SkColorType SkColorTypeForDecoding(ResourceFormat format) {
+ // Use kN32_SkColorType if there is no corresponding SkColorType.
+ switch (format) {
+ case RGBA_4444:
+ return kARGB_4444_SkColorType;
+ case RGBA_8888:
+ case BGRA_8888:
+ return kN32_SkColorType;
+ case ALPHA_8:
+ return kAlpha_8_SkColorType;
+ case RGB_565:
+ return kRGB_565_SkColorType;
+ case LUMINANCE_8:
reed1 2016/03/17 14:38:23 kGray_8_SkColorType
bashi 2016/03/17 23:29:38 Done.
+ case ETC1:
+ case RED_8:
+ case LUMINANCE_F16:
reed1 2016/03/17 14:38:23 BTW -- not hard for Skia to add native support for
bashi 2016/03/17 23:29:38 I'm not sure but I guess that LUM_16 is not common
+ return kN32_SkColorType;
+ }
+ NOTREACHED();
+ return kN32_SkColorType;
+}
+
+SkImageInfo CreateImageInfo(size_t width,
+ size_t height,
+ ResourceFormat format) {
+ return SkImageInfo::Make(width, height, SkColorTypeForDecoding(format),
+ kPremul_SkAlphaType);
reed1 2016/03/17 14:38:23 FYI -- Skia is actively working on native support
+}
+
} // namespace
-SoftwareImageDecodeController::SoftwareImageDecodeController()
+SoftwareImageDecodeController::SoftwareImageDecodeController(
+ ResourceFormat format)
: decoded_images_(ImageMRUCache::NO_AUTO_EVICT),
at_raster_decoded_images_(ImageMRUCache::NO_AUTO_EVICT),
- locked_images_budget_(kLockedMemoryLimitBytes) {}
+ locked_images_budget_(kLockedMemoryLimitBytes),
+ format_(format) {}
SoftwareImageDecodeController::~SoftwareImageDecodeController() {
DCHECK_EQ(0u, decoded_images_ref_counts_.size());
@@ -345,7 +376,7 @@ SoftwareImageDecodeController::DecodeImageInternal(
// just read pixels into the final memory.
if (key.can_use_original_decode()) {
SkImageInfo decoded_info =
- SkImageInfo::MakeN32Premul(image->width(), image->height());
+ CreateImageInfo(image->width(), image->height(), format_);
scoped_ptr<base::DiscardableMemory> decoded_pixels;
{
TRACE_EVENT0(
@@ -414,8 +445,8 @@ SoftwareImageDecodeController::DecodeImageInternal(
// Now we have a decoded_pixmap which represents the src_rect at the
// original scale. All we need to do is scale it.
DCHECK(!key.target_size().IsEmpty());
- SkImageInfo scaled_info = SkImageInfo::MakeN32Premul(
- key.target_size().width(), key.target_size().height());
+ SkImageInfo scaled_info = CreateImageInfo(
+ key.target_size().width(), key.target_size().height(), format_);
scoped_ptr<base::DiscardableMemory> scaled_pixels;
{
TRACE_EVENT0(
« no previous file with comments | « cc/tiles/software_image_decode_controller.h ('k') | cc/trees/layer_tree_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698