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

Side by Side Diff: chrome/browser/ui/app_list/extension_app_item.cc

Issue 2769203002: Use SaveLayerWithFlags to avoid cpu bitmaps in RoundedCornersImageSource (Closed)
Patch Set: Created 3 years, 9 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 (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 "chrome/browser/ui/app_list/extension_app_item.h" 5 #include "chrome/browser/ui/app_list/extension_app_item.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 ~RoundedCornersImageSource() override {} 77 ~RoundedCornersImageSource() override {}
78 78
79 private: 79 private:
80 // gfx::CanvasImageSource overrides: 80 // gfx::CanvasImageSource overrides:
81 void Draw(gfx::Canvas* canvas) override { 81 void Draw(gfx::Canvas* canvas) override {
82 // The radius used to round the app icon. 82 // The radius used to round the app icon.
83 const size_t kRoundingRadius = 2; 83 const size_t kRoundingRadius = 2;
84 84
85 canvas->DrawImageInt(icon_, 0, 0); 85 canvas->DrawImageInt(icon_, 0, 0);
86 86
87 SkBitmap mask_bitmap;
88 mask_bitmap.allocN32Pixels(icon_.width(), icon_.height(), false);
89 SkCanvas mask_canvas(mask_bitmap);
90 mask_canvas.clear(SK_ColorTRANSPARENT);
91 SkPaint mask_paint;
92 mask_paint.setAntiAlias(true);
93 mask_paint.setColor(SK_ColorWHITE);
94 mask_canvas.drawRoundRect(
95 gfx::RectToSkRect(gfx::Rect(icon_.width(), icon_.height())),
96 kRoundingRadius, kRoundingRadius, mask_paint);
97
98 cc::PaintFlags masking_flags; 87 cc::PaintFlags masking_flags;
99 masking_flags.setBlendMode(SkBlendMode::kDstIn); 88 masking_flags.setBlendMode(SkBlendMode::kDstIn);
100 canvas->sk_canvas()->drawBitmap(mask_bitmap, 0, 0, &masking_flags); 89 canvas->SaveLayerWithFlags(masking_flags);
90
91 cc::PaintFlags mask_flags;
92 mask_flags.setAntiAlias(true);
93 mask_flags.setColor(SK_ColorWHITE);
94 canvas->DrawRoundRect(gfx::Rect(icon_.width(), icon_.height()),
95 kRoundingRadius, mask_flags);
96
97 canvas->Restore();
101 } 98 }
102 99
103 gfx::ImageSkia icon_; 100 gfx::ImageSkia icon_;
104 101
105 DISALLOW_COPY_AND_ASSIGN(RoundedCornersImageSource); 102 DISALLOW_COPY_AND_ASSIGN(RoundedCornersImageSource);
106 }; 103 };
107 104
108 } // namespace 105 } // namespace
109 106
110 ExtensionAppItem::ExtensionAppItem( 107 ExtensionAppItem::ExtensionAppItem(
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 // static 304 // static
308 const char ExtensionAppItem::kItemType[] = "ExtensionAppItem"; 305 const char ExtensionAppItem::kItemType[] = "ExtensionAppItem";
309 306
310 const char* ExtensionAppItem::GetItemType() const { 307 const char* ExtensionAppItem::GetItemType() const {
311 return ExtensionAppItem::kItemType; 308 return ExtensionAppItem::kItemType;
312 } 309 }
313 310
314 void ExtensionAppItem::ExecuteLaunchCommand(int event_flags) { 311 void ExtensionAppItem::ExecuteLaunchCommand(int event_flags) {
315 Launch(event_flags); 312 Launch(event_flags);
316 } 313 }
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