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

Side by Side Diff: ui/base/resource/resource_bundle.cc

Issue 1996723002: Switch ResourceBundle LoadDataResourceBytes to return RefCountedMemory. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update to address newly added use Created 4 years, 6 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 | « ui/base/resource/resource_bundle.h ('k') | ui/base/resource/resource_bundle_ios.mm » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/base/resource/resource_bundle.h" 5 #include "ui/base/resource/resource_bundle.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <utility> 10 #include <utility>
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 base::AutoLock lock_scope(*images_and_fonts_lock_); 433 base::AutoLock lock_scope(*images_and_fonts_lock_);
434 434
435 // Another thread raced the load and has already cached the image. 435 // Another thread raced the load and has already cached the image.
436 if (images_.count(resource_id)) 436 if (images_.count(resource_id))
437 return images_[resource_id]; 437 return images_[resource_id];
438 438
439 images_[resource_id] = image; 439 images_[resource_id] = image;
440 return images_[resource_id]; 440 return images_[resource_id];
441 } 441 }
442 442
443 base::RefCountedStaticMemory* ResourceBundle::LoadDataResourceBytes( 443 base::RefCountedMemory* ResourceBundle::LoadDataResourceBytes(
444 int resource_id) const { 444 int resource_id) const {
445 return LoadDataResourceBytesForScale(resource_id, ui::SCALE_FACTOR_NONE); 445 return LoadDataResourceBytesForScale(resource_id, ui::SCALE_FACTOR_NONE);
446 } 446 }
447 447
448 base::RefCountedStaticMemory* ResourceBundle::LoadDataResourceBytesForScale( 448 base::RefCountedMemory* ResourceBundle::LoadDataResourceBytesForScale(
449 int resource_id, 449 int resource_id,
450 ScaleFactor scale_factor) const { 450 ScaleFactor scale_factor) const {
451 base::RefCountedStaticMemory* bytes = NULL; 451 base::RefCountedMemory* bytes = NULL;
452 if (delegate_) 452 if (delegate_)
453 bytes = delegate_->LoadDataResourceBytes(resource_id, scale_factor); 453 bytes = delegate_->LoadDataResourceBytes(resource_id, scale_factor);
454 454
455 if (!bytes) { 455 if (!bytes) {
456 base::StringPiece data = 456 base::StringPiece data =
457 GetRawDataResourceForScale(resource_id, scale_factor); 457 GetRawDataResourceForScale(resource_id, scale_factor);
458 if (!data.empty()) { 458 if (!data.empty()) {
459 bytes = new base::RefCountedStaticMemory(data.data(), data.length()); 459 bytes = new base::RefCountedStaticMemory(data.data(), data.length());
460 } 460 }
461 } 461 }
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 // static 896 // static
897 bool ResourceBundle::DecodePNG(const unsigned char* buf, 897 bool ResourceBundle::DecodePNG(const unsigned char* buf,
898 size_t size, 898 size_t size,
899 SkBitmap* bitmap, 899 SkBitmap* bitmap,
900 bool* fell_back_to_1x) { 900 bool* fell_back_to_1x) {
901 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size); 901 *fell_back_to_1x = PNGContainsFallbackMarker(buf, size);
902 return gfx::PNGCodec::Decode(buf, size, bitmap); 902 return gfx::PNGCodec::Decode(buf, size, bitmap);
903 } 903 }
904 904
905 } // namespace ui 905 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/resource/resource_bundle.h ('k') | ui/base/resource/resource_bundle_ios.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698