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

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

Issue 2619103002: android: Use Display in thumbnail_cache (Closed)
Patch Set: Created 3 years, 11 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_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 10 matching lines...) Expand all
21 #include "base/time/time.h" 21 #include "base/time/time.h"
22 #include "build/build_config.h" 22 #include "build/build_config.h"
23 #include "content/public/browser/browser_thread.h" 23 #include "content/public/browser/browser_thread.h"
24 #include "third_party/android_opengl/etc1/etc1.h" 24 #include "third_party/android_opengl/etc1/etc1.h"
25 #include "third_party/skia/include/core/SkBitmap.h" 25 #include "third_party/skia/include/core/SkBitmap.h"
26 #include "third_party/skia/include/core/SkCanvas.h" 26 #include "third_party/skia/include/core/SkCanvas.h"
27 #include "third_party/skia/include/core/SkData.h" 27 #include "third_party/skia/include/core/SkData.h"
28 #include "third_party/skia/include/core/SkMallocPixelRef.h" 28 #include "third_party/skia/include/core/SkMallocPixelRef.h"
29 #include "third_party/skia/include/core/SkPixelRef.h" 29 #include "third_party/skia/include/core/SkPixelRef.h"
30 #include "ui/android/resources/ui_resource_provider.h" 30 #include "ui/android/resources/ui_resource_provider.h"
31 #include "ui/gfx/android/device_display_info.h" 31 #include "ui/display/display.h"
32 #include "ui/display/screen.h"
32 #include "ui/gfx/geometry/size_conversions.h" 33 #include "ui/gfx/geometry/size_conversions.h"
33 34
34 namespace { 35 namespace {
35 36
36 const float kApproximationScaleFactor = 4.f; 37 const float kApproximationScaleFactor = 4.f;
37 const base::TimeDelta kCaptureMinRequestTimeMs( 38 const base::TimeDelta kCaptureMinRequestTimeMs(
38 base::TimeDelta::FromMilliseconds(1000)); 39 base::TimeDelta::FromMilliseconds(1000));
39 40
40 const int kCompressedKey = 0xABABABAB; 41 const int kCompressedKey = 0xABABABAB;
41 const int kCurrentExtraVersion = 1; 42 const int kCurrentExtraVersion = 1;
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 return false; 688 return false;
688 689
689 int raw_height = 0; 690 int raw_height = 0;
690 raw_height = etc1_pkm_get_height(etc1_buffer); 691 raw_height = etc1_pkm_get_height(etc1_buffer);
691 if (raw_height <= 0) 692 if (raw_height <= 0)
692 return false; 693 return false;
693 694
694 // Do some simple sanity check validation. We can't have thumbnails larger 695 // Do some simple sanity check validation. We can't have thumbnails larger
695 // than the max display size of the screen. We also can't have etc1 texture 696 // than the max display size of the screen. We also can't have etc1 texture
696 // data larger than the next power of 2 up from that. 697 // data larger than the next power of 2 up from that.
697 gfx::DeviceDisplayInfo display_info; 698 gfx::Size display_size =
698 int max_dimension = std::max(display_info.GetDisplayWidth(), 699 display::Screen::GetScreen()->GetPrimaryDisplay().GetSizeInPixel();
699 display_info.GetDisplayHeight()); 700 int max_dimension = std::max(display_size.width(), display_size.height());
700 701
701 if (content_width > max_dimension 702 if (content_width > max_dimension
702 || content_height > max_dimension 703 || content_height > max_dimension
703 || static_cast<size_t>(raw_width) > NextPowerOfTwo(max_dimension) 704 || static_cast<size_t>(raw_width) > NextPowerOfTwo(max_dimension)
704 || static_cast<size_t>(raw_height) > NextPowerOfTwo(max_dimension)) { 705 || static_cast<size_t>(raw_height) > NextPowerOfTwo(max_dimension)) {
705 return false; 706 return false;
706 } 707 }
707 708
708 int data_size = etc1_get_encoded_data_size(raw_width, raw_height); 709 int data_size = etc1_get_encoded_data_size(raw_width, raw_height);
709 sk_sp<SkData> etc1_pixel_data(SkData::MakeUninitialized(data_size)); 710 sk_sp<SkData> etc1_pixel_data(SkData::MakeUninitialized(data_size));
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 return std::make_pair(dst_bitmap, new_scale * scale); 935 return std::make_pair(dst_bitmap, new_scale * scale);
935 } 936 }
936 937
937 void ThumbnailCache::OnMemoryPressure( 938 void ThumbnailCache::OnMemoryPressure(
938 base::MemoryPressureListener::MemoryPressureLevel level) { 939 base::MemoryPressureListener::MemoryPressureLevel level) {
939 if (level == base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) { 940 if (level == base::MemoryPressureListener::MEMORY_PRESSURE_LEVEL_CRITICAL) {
940 cache_.Clear(); 941 cache_.Clear();
941 approximation_cache_.Clear(); 942 approximation_cache_.Clear();
942 } 943 }
943 } 944 }
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