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

Side by Side Diff: aura/window.cc

Issue 7534002: Shell of implementation for embedded windows. At this point this is (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Incorporate review feedback Created 9 years, 4 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
« no previous file with comments | « aura/window.h ('k') | aura/window_delegate.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "aura/window.h"
6
7 #include "aura/desktop.h"
8 #include "aura/window_delegate.h"
9 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "ui/gfx/compositor/compositor.h"
11 #include "ui/gfx/compositor/layer.h"
12
13 namespace aura {
14
15 // TODO: do we need to support child windows?
16 Window::Window(Desktop* desktop)
17 : desktop_(desktop),
18 delegate_(NULL),
19 visibility_(VISIBILITY_HIDDEN),
20 // TODO: Need to make layers lazily create the texture.
21 layer_(new ui::Layer(desktop->compositor())),
22 needs_paint_all_(true) {
23 }
24
25 Window::~Window() {
26 }
27
28 void Window::SetVisibility(Visibility visibility) {
29 if (visibility_ == visibility)
30 return;
31
32 visibility_ = visibility;
33 if (visibility_ == VISIBILITY_SHOWN) {
34 // TODO: move to top of window stack?
35 desktop_->AddWindow(this);
36 } else {
37 // TODO: hide?
38 desktop_->RemoveWindow(this);
39 }
40 }
41
42 void Window::SetBounds(const gfx::Rect& bounds, int anim_ms) {
43 // TODO: support anim_ms
44 // TODO: funnel this through the Desktop.
45 bounds_ = bounds;
46 layer_->set_bounds(bounds);
47 }
48
49 void Window::SchedulePaint(const gfx::Rect& bounds) {
50 if (dirty_rect_.IsEmpty())
51 dirty_rect_ = bounds;
52 else
53 dirty_rect_ = dirty_rect_.Union(bounds);
54 }
55
56 void Window::SetCanvas(const SkCanvas& canvas, const gfx::Point& origin) {
57 // TODO: figure out how this is going to work when animating the layer. In
58 // particular if we're animating the size then the underyling Texture is going
59 // to be unhappy if we try to set a texture on a size bigger than the size of
60 // the texture.
61 layer_->SetCanvas(canvas, origin);
62 }
63
64 void Window::Draw() {
65 if (visibility_ != VISIBILITY_HIDDEN)
66 layer_->Draw();
67 }
68
69 void Window::UpdateLayerCanvas() {
70 if (needs_paint_all_) {
71 needs_paint_all_ = false;
72 dirty_rect_ = gfx::Rect(0, 0, bounds().width(), bounds().height());
73 }
74 gfx::Rect dirty_rect = dirty_rect_.Intersect(
75 gfx::Rect(0, 0, bounds().width(), bounds().height()));
76 dirty_rect_.SetRect(0, 0, 0, 0);
77 if (dirty_rect.IsEmpty())
78 return;
79 if (delegate_)
80 delegate_->OnPaint(dirty_rect);
81 }
82
83 } // namespace aura
OLDNEW
« no previous file with comments | « aura/window.h ('k') | aura/window_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698