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

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

Issue 517803002: SkImageInfo will soon have a constructor, so can't init it with {} anymore (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « no previous file | no next file » | 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_store.h" 5 #include "chrome/browser/android/thumbnail/thumbnail_store.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/big_endian.h" 10 #include "base/big_endian.h"
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 gfx::Size content_size; 557 gfx::Size content_size;
558 558
559 if (!raw_data.empty()) { 559 if (!raw_data.empty()) {
560 SkAutoLockPixels raw_data_lock(raw_data); 560 SkAutoLockPixels raw_data_lock(raw_data);
561 gfx::Size raw_data_size(raw_data.width(), raw_data.height()); 561 gfx::Size raw_data_size(raw_data.width(), raw_data.height());
562 size_t pixel_size = 4; // Pixel size is 4 bytes for kARGB_8888_Config. 562 size_t pixel_size = 4; // Pixel size is 4 bytes for kARGB_8888_Config.
563 size_t stride = pixel_size * raw_data_size.width(); 563 size_t stride = pixel_size * raw_data_size.width();
564 564
565 size_t encoded_bytes = 565 size_t encoded_bytes =
566 etc1_get_encoded_data_size(encoded_size.width(), encoded_size.height()); 566 etc1_get_encoded_data_size(encoded_size.width(), encoded_size.height());
567 SkImageInfo info = {encoded_size.width(), 567 SkImageInfo info = SkImageInfo::Make(encoded_size.width(),
568 encoded_size.height(), 568 encoded_size.height(),
569 kUnknown_SkColorType, 569 kUnknown_SkColorType,
570 kUnpremul_SkAlphaType}; 570 kUnpremul_SkAlphaType);
571 skia::RefPtr<SkData> etc1_pixel_data = skia::AdoptRef( 571 skia::RefPtr<SkData> etc1_pixel_data = skia::AdoptRef(
572 SkData::NewFromMalloc(new uint8_t[encoded_bytes], encoded_bytes)); 572 SkData::NewFromMalloc(new uint8_t[encoded_bytes], encoded_bytes));
573 skia::RefPtr<SkMallocPixelRef> etc1_pixel_ref = skia::AdoptRef( 573 skia::RefPtr<SkMallocPixelRef> etc1_pixel_ref = skia::AdoptRef(
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(),
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 scoped_ptr<uint8_t[]> raw_data = 687 scoped_ptr<uint8_t[]> raw_data =
688 scoped_ptr<uint8_t[]>(new uint8_t[data_size]); 688 scoped_ptr<uint8_t[]>(new uint8_t[data_size]);
689 689
690 int pixel_bytes_read = file.ReadAtCurrentPos( 690 int pixel_bytes_read = file.ReadAtCurrentPos(
691 reinterpret_cast<char*>(raw_data.get()), 691 reinterpret_cast<char*>(raw_data.get()),
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 = {raw_width, 697 SkImageInfo info = SkImageInfo::Make(raw_width,
698 raw_height, 698 raw_height,
699 kUnknown_SkColorType, 699 kUnknown_SkColorType,
700 kUnpremul_SkAlphaType}; 700 kUnpremul_SkAlphaType);
701 701
702 etc1_pixel_data = skia::AdoptRef( 702 etc1_pixel_data = skia::AdoptRef(
703 SkData::NewFromMalloc(raw_data.release(), data_size)); 703 SkData::NewFromMalloc(raw_data.release(), data_size));
704 704
705 *out_pixels = skia::AdoptRef( 705 *out_pixels = skia::AdoptRef(
706 SkMallocPixelRef::NewWithData(info, 706 SkMallocPixelRef::NewWithData(info,
707 0, 707 0,
708 NULL, 708 NULL,
709 etc1_pixel_data.get())); 709 etc1_pixel_data.get()));
710 710
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 dst_bitmap.eraseColor(0); 841 dst_bitmap.eraseColor(0);
842 SkAutoLockPixels dst_bitmap_lock(dst_bitmap); 842 SkAutoLockPixels dst_bitmap_lock(dst_bitmap);
843 843
844 SkCanvas canvas(dst_bitmap); 844 SkCanvas canvas(dst_bitmap);
845 canvas.scale(new_scale, new_scale); 845 canvas.scale(new_scale, new_scale);
846 canvas.drawBitmap(bitmap, 0, 0, NULL); 846 canvas.drawBitmap(bitmap, 0, 0, NULL);
847 dst_bitmap.setImmutable(); 847 dst_bitmap.setImmutable();
848 848
849 return std::make_pair(dst_bitmap, new_scale * scale); 849 return std::make_pair(dst_bitmap, new_scale * scale);
850 } 850 }
OLDNEW
« 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