summaryrefslogtreecommitdiffstats
path: root/aura/window.cc
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-29 19:32:06 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-07-29 19:32:06 +0000
commit81585f3fa532dbe0355991b56c8d5bbb7b9ae321 (patch)
tree69f78267fc35600fec11a9533fe5d7af18ed42dc /aura/window.cc
parentf1aa3566cb4b397eb4f567e8b88610d81de17566 (diff)
downloadchromium_src-81585f3fa532dbe0355991b56c8d5bbb7b9ae321.zip
chromium_src-81585f3fa532dbe0355991b56c8d5bbb7b9ae321.tar.gz
chromium_src-81585f3fa532dbe0355991b56c8d5bbb7b9ae321.tar.bz2
Shell of implementation for embedded windows. At this point this is
just a proof of concept. Next step is going to be pulling code from the window manager into this. Desktop will likely be renamed to WindowManager. At this point just make sure you think I'm not going off into the weeds. BUG=none TEST=none R=derat@chromium.org Review URL: http://codereview.chromium.org/7534002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@94733 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'aura/window.cc')
-rw-r--r--aura/window.cc83
1 files changed, 83 insertions, 0 deletions
diff --git a/aura/window.cc b/aura/window.cc
new file mode 100644
index 0000000..41a4af2
--- /dev/null
+++ b/aura/window.cc
@@ -0,0 +1,83 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "aura/window.h"
+
+#include "aura/desktop.h"
+#include "aura/window_delegate.h"
+#include "third_party/skia/include/core/SkCanvas.h"
+#include "ui/gfx/compositor/compositor.h"
+#include "ui/gfx/compositor/layer.h"
+
+namespace aura {
+
+// TODO: do we need to support child windows?
+Window::Window(Desktop* desktop)
+ : desktop_(desktop),
+ delegate_(NULL),
+ visibility_(VISIBILITY_HIDDEN),
+ // TODO: Need to make layers lazily create the texture.
+ layer_(new ui::Layer(desktop->compositor())),
+ needs_paint_all_(true) {
+}
+
+Window::~Window() {
+}
+
+void Window::SetVisibility(Visibility visibility) {
+ if (visibility_ == visibility)
+ return;
+
+ visibility_ = visibility;
+ if (visibility_ == VISIBILITY_SHOWN) {
+ // TODO: move to top of window stack?
+ desktop_->AddWindow(this);
+ } else {
+ // TODO: hide?
+ desktop_->RemoveWindow(this);
+ }
+}
+
+void Window::SetBounds(const gfx::Rect& bounds, int anim_ms) {
+ // TODO: support anim_ms
+ // TODO: funnel this through the Desktop.
+ bounds_ = bounds;
+ layer_->set_bounds(bounds);
+}
+
+void Window::SchedulePaint(const gfx::Rect& bounds) {
+ if (dirty_rect_.IsEmpty())
+ dirty_rect_ = bounds;
+ else
+ dirty_rect_ = dirty_rect_.Union(bounds);
+}
+
+void Window::SetCanvas(const SkCanvas& canvas, const gfx::Point& origin) {
+ // TODO: figure out how this is going to work when animating the layer. In
+ // particular if we're animating the size then the underyling Texture is going
+ // to be unhappy if we try to set a texture on a size bigger than the size of
+ // the texture.
+ layer_->SetCanvas(canvas, origin);
+}
+
+void Window::Draw() {
+ if (visibility_ != VISIBILITY_HIDDEN)
+ layer_->Draw();
+}
+
+void Window::UpdateLayerCanvas() {
+ if (needs_paint_all_) {
+ needs_paint_all_ = false;
+ dirty_rect_ = gfx::Rect(0, 0, bounds().width(), bounds().height());
+ }
+ gfx::Rect dirty_rect = dirty_rect_.Intersect(
+ gfx::Rect(0, 0, bounds().width(), bounds().height()));
+ dirty_rect_.SetRect(0, 0, 0, 0);
+ if (dirty_rect.IsEmpty())
+ return;
+ if (delegate_)
+ delegate_->OnPaint(dirty_rect);
+}
+
+} // namespace aura