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

Side by Side Diff: chrome/browser/notifications/notification_conversion_helper.cc

Issue 1452853002: Convert vector_as_array to vector::data in //chrome{,cast,os}. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vector-data
Patch Set: Created 5 years, 1 month 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 "chrome/browser/notifications/notification_conversion_helper.h" 5 #include "chrome/browser/notifications/notification_conversion_helper.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/stl_util.h"
13 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
14 #include "chrome/common/extensions/api/notification_provider.h" 13 #include "chrome/common/extensions/api/notification_provider.h"
15 #include "chrome/common/extensions/api/notifications/notification_style.h" 14 #include "chrome/common/extensions/api/notifications/notification_style.h"
16 #include "ui/gfx/image/image_skia.h" 15 #include "ui/gfx/image/image_skia.h"
17 #include "ui/gfx/image/image_skia_rep.h" 16 #include "ui/gfx/image/image_skia_rep.h"
18 #include "ui/gfx/skia_util.h" 17 #include "ui/gfx/skia_util.h"
19 18
20 void NotificationConversionHelper::NotificationToNotificationOptions( 19 void NotificationConversionHelper::NotificationToNotificationOptions(
21 const Notification& notification, 20 const Notification& notification,
22 extensions::api::notifications::NotificationOptions* options) { 21 extensions::api::notifications::NotificationOptions* options) {
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 notification_bitmap->height = sk_bitmap.height(); 122 notification_bitmap->height = sk_bitmap.height();
124 int pixel_count = sk_bitmap.width() * sk_bitmap.height(); 123 int pixel_count = sk_bitmap.width() * sk_bitmap.height();
125 const int BYTES_PER_PIXEL = 4; 124 const int BYTES_PER_PIXEL = 4;
126 125
127 uint32_t* bitmap_pixels = sk_bitmap.getAddr32(0, 0); 126 uint32_t* bitmap_pixels = sk_bitmap.getAddr32(0, 0);
128 const unsigned char* bitmap = 127 const unsigned char* bitmap =
129 reinterpret_cast<const unsigned char*>(bitmap_pixels); 128 reinterpret_cast<const unsigned char*>(bitmap_pixels);
130 scoped_ptr<std::vector<char>> rgba_bitmap_data( 129 scoped_ptr<std::vector<char>> rgba_bitmap_data(
131 new std::vector<char>(pixel_count * BYTES_PER_PIXEL)); 130 new std::vector<char>(pixel_count * BYTES_PER_PIXEL));
132 131
133 gfx::ConvertSkiaToRGBA(bitmap, pixel_count, 132 gfx::ConvertSkiaToRGBA(bitmap, pixel_count, reinterpret_cast<unsigned char*>(
134 reinterpret_cast<unsigned char*>( 133 rgba_bitmap_data->data()));
135 vector_as_array(rgba_bitmap_data.get())));
136 sk_bitmap.unlockPixels(); 134 sk_bitmap.unlockPixels();
137 135
138 notification_bitmap->data = rgba_bitmap_data.Pass(); 136 notification_bitmap->data = rgba_bitmap_data.Pass();
139 return; 137 return;
140 } 138 }
141 139
142 bool NotificationConversionHelper::NotificationBitmapToGfxImage( 140 bool NotificationConversionHelper::NotificationBitmapToGfxImage(
143 float max_scale, 141 float max_scale,
144 const gfx::Size& target_size_dips, 142 const gfx::Size& target_size_dips,
145 const extensions::api::notifications::NotificationBitmap& 143 const extensions::api::notifications::NotificationBitmap&
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 return "image"; 204 return "image";
207 case message_center::NOTIFICATION_TYPE_MULTIPLE: 205 case message_center::NOTIFICATION_TYPE_MULTIPLE:
208 return "list"; 206 return "list";
209 case message_center::NOTIFICATION_TYPE_PROGRESS: 207 case message_center::NOTIFICATION_TYPE_PROGRESS:
210 return "progress"; 208 return "progress";
211 default: 209 default:
212 NOTREACHED(); 210 NOTREACHED();
213 return ""; 211 return "";
214 } 212 }
215 } 213 }
OLDNEW
« no previous file with comments | « chrome/browser/media/webrtc_rtp_dump_writer.cc ('k') | chrome/browser/plugins/plugin_power_saver_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698