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

Side by Side Diff: chrome/browser/ui/views/toolbar/app_menu.cc

Issue 2823003002: SkBitmap and SkPixelRef no longer need lock/unlock (Closed)
Patch Set: win fix after rebase Created 3 years, 8 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/views/toolbar/app_menu.h" 5 #include "chrome/browser/ui/views/toolbar/app_menu.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 color_(color) { 380 color_(color) {
381 } 381 }
382 ~HoveredImageSource() override {} 382 ~HoveredImageSource() override {}
383 383
384 gfx::ImageSkiaRep GetImageForScale(float scale) override { 384 gfx::ImageSkiaRep GetImageForScale(float scale) override {
385 const gfx::ImageSkiaRep& rep = image_.GetRepresentation(scale); 385 const gfx::ImageSkiaRep& rep = image_.GetRepresentation(scale);
386 SkBitmap bitmap = rep.sk_bitmap(); 386 SkBitmap bitmap = rep.sk_bitmap();
387 SkBitmap white; 387 SkBitmap white;
388 white.allocN32Pixels(bitmap.width(), bitmap.height()); 388 white.allocN32Pixels(bitmap.width(), bitmap.height());
389 white.eraseARGB(0, 0, 0, 0); 389 white.eraseARGB(0, 0, 0, 0);
390 bitmap.lockPixels();
391 for (int y = 0; y < bitmap.height(); ++y) { 390 for (int y = 0; y < bitmap.height(); ++y) {
392 uint32_t* image_row = bitmap.getAddr32(0, y); 391 uint32_t* image_row = bitmap.getAddr32(0, y);
393 uint32_t* dst_row = white.getAddr32(0, y); 392 uint32_t* dst_row = white.getAddr32(0, y);
394 for (int x = 0; x < bitmap.width(); ++x) { 393 for (int x = 0; x < bitmap.width(); ++x) {
395 uint32_t image_pixel = image_row[x]; 394 uint32_t image_pixel = image_row[x];
396 // Fill the non transparent pixels with |color_|. 395 // Fill the non transparent pixels with |color_|.
397 dst_row[x] = (image_pixel & 0xFF000000) == 0x0 ? 0x0 : color_; 396 dst_row[x] = (image_pixel & 0xFF000000) == 0x0 ? 0x0 : color_;
398 } 397 }
399 } 398 }
400 bitmap.unlockPixels();
401 return gfx::ImageSkiaRep(white, scale); 399 return gfx::ImageSkiaRep(white, scale);
402 } 400 }
403 401
404 private: 402 private:
405 const gfx::ImageSkia image_; 403 const gfx::ImageSkia image_;
406 const SkColor color_; 404 const SkColor color_;
407 DISALLOW_COPY_AND_ASSIGN(HoveredImageSource); 405 DISALLOW_COPY_AND_ASSIGN(HoveredImageSource);
408 }; 406 };
409 407
410 } // namespace 408 } // namespace
(...skipping 817 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 0, 1226 0,
1229 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS, 1227 BookmarkMenuDelegate::SHOW_PERMANENT_FOLDERS,
1230 BOOKMARK_LAUNCH_LOCATION_APP_MENU); 1228 BOOKMARK_LAUNCH_LOCATION_APP_MENU);
1231 } 1229 }
1232 1230
1233 int AppMenu::ModelIndexFromCommandId(int command_id) const { 1231 int AppMenu::ModelIndexFromCommandId(int command_id) const {
1234 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id); 1232 CommandIDToEntry::const_iterator ix = command_id_to_entry_.find(command_id);
1235 DCHECK(ix != command_id_to_entry_.end()); 1233 DCHECK(ix != command_id_to_entry_.end());
1236 return ix->second.second; 1234 return ix->second.second;
1237 } 1235 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/toolbar/back_forward_menu_model_unittest.cc ('k') | chrome/browser/web_applications/web_app_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698