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

Side by Side Diff: ios/chrome/browser/google/google_logo_service.mm

Issue 2855503003: Replace uses of legacy SkBitmap::copyTo() API (Closed)
Patch Set: image_info Created 3 years, 7 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
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 "ios/chrome/browser/google/google_logo_service.h" 5 #include "ios/chrome/browser/google/google_logo_service.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 base::Bind(&search_provider_logos::GoogleAppendQueryparamsToLogoURL), 114 base::Bind(&search_provider_logos::GoogleAppendQueryparamsToLogoURL),
115 true, false /* gray_background */); 115 true, false /* gray_background */);
116 logo_tracker_->GetLogo(observer); 116 logo_tracker_->GetLogo(observer);
117 } 117 }
118 118
119 void GoogleLogoService::SetCachedLogo(const search_provider_logos::Logo* logo) { 119 void GoogleLogoService::SetCachedLogo(const search_provider_logos::Logo* logo) {
120 if (logo) { 120 if (logo) {
121 if (cached_metadata_.fingerprint == logo->metadata.fingerprint) { 121 if (cached_metadata_.fingerprint == logo->metadata.fingerprint) {
122 return; 122 return;
123 } 123 }
124 logo->image.deepCopyTo(&cached_image_); 124 if (cached_image_.tryAllocPixels(logo->image.info())) {
125 logo->image.readPixels(cached_image_.info(), cached_image_.getPixels(),
126 cached_image_.rowBytes(), 0, 0);
127 }
125 cached_metadata_ = logo->metadata; 128 cached_metadata_ = logo->metadata;
126 } else { 129 } else {
127 cached_image_ = SkBitmap(); 130 cached_image_ = SkBitmap();
128 cached_metadata_ = empty_metadata; 131 cached_metadata_ = empty_metadata;
129 } 132 }
130 } 133 }
131 134
132 search_provider_logos::Logo GoogleLogoService::GetCachedLogo() { 135 search_provider_logos::Logo GoogleLogoService::GetCachedLogo() {
133 search_provider_logos::Logo logo; 136 search_provider_logos::Logo logo;
134 logo.image = cached_image_; 137 logo.image = cached_image_;
135 logo.metadata = cached_metadata_; 138 logo.metadata = cached_metadata_;
136 return logo; 139 return logo;
137 } 140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698