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

Side by Side Diff: trunk/src/mojo/services/public/cpp/view_manager/lib/view.cc

Issue 306403003: Revert 274322 "Implement a demo that shows one app embedding ren..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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 "mojo/services/public/cpp/view_manager/view.h" 5 #include "mojo/services/public/cpp/view_manager/view.h"
6 6
7 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h" 7 #include "mojo/services/public/cpp/view_manager/lib/view_manager_private.h"
8 #include "mojo/services/public/cpp/view_manager/lib/view_private.h" 8 #include "mojo/services/public/cpp/view_manager/lib/view_private.h"
9 #include "mojo/services/public/cpp/view_manager/view_observer.h" 9 #include "mojo/services/public/cpp/view_manager/view_observer.h"
10 #include "ui/gfx/canvas.h"
11 10
12 namespace mojo { 11 namespace mojo {
13 namespace view_manager { 12 namespace view_manager {
14 13
15 namespace { 14 namespace {
16 class ScopedDestructionNotifier { 15 class ScopedDestructionNotifier {
17 public: 16 public:
18 explicit ScopedDestructionNotifier(View* view) 17 explicit ScopedDestructionNotifier(View* view)
19 : view_(view) { 18 : view_(view) {
20 FOR_EACH_OBSERVER( 19 FOR_EACH_OBSERVER(
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 54
56 void View::RemoveObserver(ViewObserver* observer) { 55 void View::RemoveObserver(ViewObserver* observer) {
57 observers_.RemoveObserver(observer); 56 observers_.RemoveObserver(observer);
58 } 57 }
59 58
60 void View::SetContents(const SkBitmap& contents) { 59 void View::SetContents(const SkBitmap& contents) {
61 if (manager_) 60 if (manager_)
62 ViewManagerPrivate(manager_).synchronizer()->SetViewContents(id_, contents); 61 ViewManagerPrivate(manager_).synchronizer()->SetViewContents(id_, contents);
63 } 62 }
64 63
65 void View::SetColor(SkColor color) {
66 gfx::Canvas canvas(node_->bounds().size(), 1.0f, true);
67 canvas.DrawColor(color);
68 SetContents(skia::GetTopDevice(*canvas.sk_canvas())->accessBitmap(true));
69 }
70
71 View::View(ViewManager* manager) 64 View::View(ViewManager* manager)
72 : id_(ViewManagerPrivate(manager).synchronizer()->CreateView()), 65 : id_(ViewManagerPrivate(manager).synchronizer()->CreateView()),
73 node_(NULL), 66 node_(NULL),
74 manager_(manager) {} 67 manager_(manager) {}
75 68
76 View::View() 69 View::View()
77 : id_(-1), 70 : id_(-1),
78 node_(NULL), 71 node_(NULL),
79 manager_(NULL) {} 72 manager_(NULL) {}
80 73
81 View::~View() { 74 View::~View() {
82 ScopedDestructionNotifier notifier(this); 75 ScopedDestructionNotifier notifier(this);
83 if (manager_) 76 if (manager_)
84 ViewManagerPrivate(manager_).RemoveView(id_); 77 ViewManagerPrivate(manager_).RemoveView(id_);
85 } 78 }
86 79
87 void View::LocalDestroy() { 80 void View::LocalDestroy() {
88 delete this; 81 delete this;
89 } 82 }
90 83
91 } // namespace view_manager 84 } // namespace view_manager
92 } // namespace mojo 85 } // namespace mojo
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698