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

Unified Diff: ash/common/accelerators/debug_commands.cc

Issue 2760133002: ui: Remove a bunch of uses of gfx::Canvas::ExtractImageRep() (Closed)
Patch Set: canvasbounds: ashnit 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ash/common/frame/caption_buttons/frame_caption_button.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/common/accelerators/debug_commands.cc
diff --git a/ash/common/accelerators/debug_commands.cc b/ash/common/accelerators/debug_commands.cc
index 2712e4032749263ccd9ce1a89fe88f3d10aad348..4445d33a20cd5776d4b6d3ac2a0384caa8c2ff54 100644
--- a/ash/common/accelerators/debug_commands.cc
+++ b/ash/common/accelerators/debug_commands.cc
@@ -25,6 +25,7 @@
#include "ui/compositor/layer.h"
#include "ui/gfx/canvas.h"
#include "ui/gfx/image/image_skia.h"
+#include "ui/gfx/image/image_skia_rep.h"
#include "ui/views/debug_utils.h"
#include "ui/views/widget/widget.h"
@@ -90,15 +91,19 @@ gfx::ImageSkia CreateWallpaperImage(SkColor fill, SkColor rect) {
// TODO(oshima): Consider adding a command line option to control wallpaper
// images for testing. The size is randomly picked.
gfx::Size image_size(1366, 768);
- gfx::Canvas canvas(image_size, 1.0f, true);
- canvas.DrawColor(fill);
- cc::PaintFlags flags;
- flags.setColor(rect);
- flags.setStrokeWidth(10);
- flags.setStyle(cc::PaintFlags::kStroke_Style);
- flags.setBlendMode(SkBlendMode::kSrcOver);
- canvas.DrawRoundRect(gfx::Rect(image_size), 100, flags);
- return gfx::ImageSkia(canvas.ExtractImageRep());
+ SkBitmap bitmap;
+ bitmap.allocN32Pixels(image_size.width(), image_size.height(), true);
+ sk_sp<SkSurface> surface = SkSurface::MakeRasterDirect(
+ bitmap.info(), bitmap.getPixels(), bitmap.rowBytes());
+ surface->getCanvas()->drawColor(fill);
+ SkPaint paint;
+ paint.setColor(rect);
+ paint.setStrokeWidth(10);
+ paint.setStyle(SkPaint::kStroke_Style);
+ paint.setBlendMode(SkBlendMode::kSrcOver);
+ surface->getCanvas()->drawRoundRect(gfx::RectToSkRect(gfx::Rect(image_size)),
+ 100.f, 100.f, paint);
+ return gfx::ImageSkia(gfx::ImageSkiaRep(std::move(bitmap), 1.f));
}
void HandleToggleWallpaperMode() {
« no previous file with comments | « no previous file | ash/common/frame/caption_buttons/frame_caption_button.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698