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

Side by Side Diff: chrome/browser/android/thumbnail/thumbnail_cache.cc

Issue 2206263003: Remove SK_SUPPORT_LEGACY_DATA_FACTORIES. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Ref when needed. Created 4 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 unified diff | Download patch
« no previous file with comments | « cc/debug/picture_debug_util.cc ('k') | content/renderer/gpu/gpu_benchmarking_extension.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/android/thumbnail/thumbnail_cache.h" 5 #include "chrome/browser/android/thumbnail/thumbnail_cache.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 gfx::Size raw_data_size(raw_data.width(), raw_data.height()); 562 gfx::Size raw_data_size(raw_data.width(), raw_data.height());
563 size_t pixel_size = 4; // Pixel size is 4 bytes for kARGB_8888_Config. 563 size_t pixel_size = 4; // Pixel size is 4 bytes for kARGB_8888_Config.
564 size_t stride = pixel_size * raw_data_size.width(); 564 size_t stride = pixel_size * raw_data_size.width();
565 565
566 size_t encoded_bytes = 566 size_t encoded_bytes =
567 etc1_get_encoded_data_size(encoded_size.width(), encoded_size.height()); 567 etc1_get_encoded_data_size(encoded_size.width(), encoded_size.height());
568 SkImageInfo info = SkImageInfo::Make(encoded_size.width(), 568 SkImageInfo info = SkImageInfo::Make(encoded_size.width(),
569 encoded_size.height(), 569 encoded_size.height(),
570 kUnknown_SkColorType, 570 kUnknown_SkColorType,
571 kUnpremul_SkAlphaType); 571 kUnpremul_SkAlphaType);
572 sk_sp<SkData> etc1_pixel_data(SkData::NewUninitialized(encoded_bytes)); 572 sk_sp<SkData> etc1_pixel_data(SkData::MakeUninitialized(encoded_bytes));
573 sk_sp<SkMallocPixelRef> etc1_pixel_ref( 573 sk_sp<SkMallocPixelRef> etc1_pixel_ref(
574 SkMallocPixelRef::NewWithData(info, 0, NULL, etc1_pixel_data.get())); 574 SkMallocPixelRef::NewWithData(info, 0, NULL, etc1_pixel_data.get()));
575 575
576 etc1_pixel_ref->lockPixels(); 576 etc1_pixel_ref->lockPixels();
577 bool success = etc1_encode_image( 577 bool success = etc1_encode_image(
578 reinterpret_cast<unsigned char*>(raw_data.getPixels()), 578 reinterpret_cast<unsigned char*>(raw_data.getPixels()),
579 raw_data_size.width(), 579 raw_data_size.width(),
580 raw_data_size.height(), 580 raw_data_size.height(),
581 pixel_size, 581 pixel_size,
582 stride, 582 stride,
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 display_info.GetDisplayHeight()); 678 display_info.GetDisplayHeight());
679 679
680 if (content_width > max_dimension 680 if (content_width > max_dimension
681 || content_height > max_dimension 681 || content_height > max_dimension
682 || static_cast<size_t>(raw_width) > NextPowerOfTwo(max_dimension) 682 || static_cast<size_t>(raw_width) > NextPowerOfTwo(max_dimension)
683 || static_cast<size_t>(raw_height) > NextPowerOfTwo(max_dimension)) { 683 || static_cast<size_t>(raw_height) > NextPowerOfTwo(max_dimension)) {
684 return false; 684 return false;
685 } 685 }
686 686
687 int data_size = etc1_get_encoded_data_size(raw_width, raw_height); 687 int data_size = etc1_get_encoded_data_size(raw_width, raw_height);
688 sk_sp<SkData> etc1_pixel_data(SkData::NewUninitialized(data_size)); 688 sk_sp<SkData> etc1_pixel_data(SkData::MakeUninitialized(data_size));
689 689
690 int pixel_bytes_read = file.ReadAtCurrentPos( 690 int pixel_bytes_read = file.ReadAtCurrentPos(
691 reinterpret_cast<char*>(etc1_pixel_data->writable_data()), 691 reinterpret_cast<char*>(etc1_pixel_data->writable_data()),
692 data_size); 692 data_size);
693 693
694 if (pixel_bytes_read != data_size) 694 if (pixel_bytes_read != data_size)
695 return false; 695 return false;
696 696
697 SkImageInfo info = SkImageInfo::Make(raw_width, 697 SkImageInfo info = SkImageInfo::Make(raw_width,
698 raw_height, 698 raw_height,
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
905 dst_bitmap.eraseColor(0); 905 dst_bitmap.eraseColor(0);
906 SkAutoLockPixels dst_bitmap_lock(dst_bitmap); 906 SkAutoLockPixels dst_bitmap_lock(dst_bitmap);
907 907
908 SkCanvas canvas(dst_bitmap); 908 SkCanvas canvas(dst_bitmap);
909 canvas.scale(new_scale, new_scale); 909 canvas.scale(new_scale, new_scale);
910 canvas.drawBitmap(bitmap, 0, 0, NULL); 910 canvas.drawBitmap(bitmap, 0, 0, NULL);
911 dst_bitmap.setImmutable(); 911 dst_bitmap.setImmutable();
912 912
913 return std::make_pair(dst_bitmap, new_scale * scale); 913 return std::make_pair(dst_bitmap, new_scale * scale);
914 } 914 }
OLDNEW
« no previous file with comments | « cc/debug/picture_debug_util.cc ('k') | content/renderer/gpu/gpu_benchmarking_extension.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698