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

Unified Diff: services/ui/demo/mus_demo.cc

Issue 2581163003: Don't hold onto SkBitmap in mus_demo. (Closed)
Patch Set: Move include. Created 4 years 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 | « services/ui/demo/mus_demo.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: services/ui/demo/mus_demo.cc
diff --git a/services/ui/demo/mus_demo.cc b/services/ui/demo/mus_demo.cc
index fa770d508f55f543a29d797ed69556eff84a6e09..66556daed3799dd8115792c3c551c63ddd50ff49 100644
--- a/services/ui/demo/mus_demo.cc
+++ b/services/ui/demo/mus_demo.cc
@@ -9,6 +9,7 @@
#include "services/service_manager/public/cpp/connector.h"
#include "services/service_manager/public/cpp/service_context.h"
#include "services/ui/public/cpp/gpu/gpu.h"
+#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkImageInfo.h"
@@ -224,21 +225,22 @@ void MusDemo::DrawFrame() {
if (angle_ >= 360.0)
angle_ = 0.0;
- // Re-initialize the bitmap
- bitmap_.reset();
- const gfx::Rect bounds = bitmap_window_->bounds();
+ const gfx::Rect& bounds = bitmap_window_->bounds();
+
+ // Allocate a bitmap of correct size.
+ SkBitmap bitmap;
SkImageInfo image_info = SkImageInfo::MakeN32(bounds.width(), bounds.height(),
kPremul_SkAlphaType);
- bitmap_.allocPixels(image_info);
+ bitmap.allocPixels(image_info);
// Draw the rotated square on background in bitmap.
- SkCanvas canvas(bitmap_);
+ SkCanvas canvas(bitmap);
canvas.clear(kBgColor);
// TODO(kylechar): Add GL drawing instead of software rasterization in future.
DrawSquare(bounds, angle_, &canvas);
canvas.flush();
- gfx::ImageSkiaRep image_skia_rep(bitmap_, 1);
+ gfx::ImageSkiaRep image_skia_rep(bitmap, 1);
gfx::ImageSkia image_skia(image_skia_rep);
gfx::Image image(image_skia);
« no previous file with comments | « services/ui/demo/mus_demo.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698