OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/aura/window.h" | 5 #include "ui/aura/window.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 #include "ui/gfx/animation/multi_animation.h" | 33 #include "ui/gfx/animation/multi_animation.h" |
34 #include "ui/gfx/canvas.h" | 34 #include "ui/gfx/canvas.h" |
35 #include "ui/gfx/path.h" | 35 #include "ui/gfx/path.h" |
36 #include "ui/gfx/scoped_canvas.h" | 36 #include "ui/gfx/scoped_canvas.h" |
37 #include "ui/gfx/screen.h" | 37 #include "ui/gfx/screen.h" |
38 | 38 |
39 namespace aura { | 39 namespace aura { |
40 | 40 |
41 namespace { | 41 namespace { |
42 | 42 |
43 WindowLayerType UILayerTypeToWindowLayerType(ui::LayerType layer_type) { | |
44 switch (layer_type) { | |
45 case ui::LAYER_NOT_DRAWN: | |
46 return WINDOW_LAYER_NOT_DRAWN; | |
47 case ui::LAYER_TEXTURED: | |
48 return WINDOW_LAYER_TEXTURED; | |
49 case ui::LAYER_SOLID_COLOR: | |
50 return WINDOW_LAYER_SOLID_COLOR; | |
51 } | |
52 NOTREACHED(); | |
53 return WINDOW_LAYER_NOT_DRAWN; | |
54 } | |
55 | |
56 ui::LayerType WindowLayerTypeToUILayerType(WindowLayerType window_layer_type) { | 43 ui::LayerType WindowLayerTypeToUILayerType(WindowLayerType window_layer_type) { |
57 switch (window_layer_type) { | 44 switch (window_layer_type) { |
58 case WINDOW_LAYER_NONE: | 45 case WINDOW_LAYER_NONE: |
59 break; | 46 break; |
60 case WINDOW_LAYER_NOT_DRAWN: | 47 case WINDOW_LAYER_NOT_DRAWN: |
61 return ui::LAYER_NOT_DRAWN; | 48 return ui::LAYER_NOT_DRAWN; |
62 case WINDOW_LAYER_TEXTURED: | 49 case WINDOW_LAYER_TEXTURED: |
63 return ui::LAYER_TEXTURED; | 50 return ui::LAYER_TEXTURED; |
64 case WINDOW_LAYER_SOLID_COLOR: | 51 case WINDOW_LAYER_SOLID_COLOR: |
65 return ui::LAYER_SOLID_COLOR; | 52 return ui::LAYER_SOLID_COLOR; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
272 | 259 |
273 // If we have layer it will either be destroyed by |layer_owner_|'s dtor, or | 260 // If we have layer it will either be destroyed by |layer_owner_|'s dtor, or |
274 // by whoever acquired it. We don't have a layer if Init() wasn't invoked or | 261 // by whoever acquired it. We don't have a layer if Init() wasn't invoked or |
275 // we are layerless. | 262 // we are layerless. |
276 if (layer_) { | 263 if (layer_) { |
277 layer_->set_delegate(NULL); | 264 layer_->set_delegate(NULL); |
278 layer_ = NULL; | 265 layer_ = NULL; |
279 } | 266 } |
280 } | 267 } |
281 | 268 |
282 void Window::Init(ui::LayerType layer_type) { | 269 void Window::Init(WindowLayerType window_layer_type) { |
283 InitWithWindowLayerType(UILayerTypeToWindowLayerType(layer_type)); | |
284 } | |
285 | |
286 void Window::InitWithWindowLayerType(WindowLayerType window_layer_type) { | |
287 if (window_layer_type != WINDOW_LAYER_NONE) { | 270 if (window_layer_type != WINDOW_LAYER_NONE) { |
288 layer_ = new ui::Layer(WindowLayerTypeToUILayerType(window_layer_type)); | 271 layer_ = new ui::Layer(WindowLayerTypeToUILayerType(window_layer_type)); |
289 layer_owner_.reset(layer_); | 272 layer_owner_.reset(layer_); |
290 layer_->SetVisible(false); | 273 layer_->SetVisible(false); |
291 layer_->set_delegate(this); | 274 layer_->set_delegate(this); |
292 UpdateLayerName(name_); | 275 UpdateLayerName(name_); |
293 layer_->SetFillsBoundsOpaquely(!transparent_); | 276 layer_->SetFillsBoundsOpaquely(!transparent_); |
294 } | 277 } |
295 | 278 |
296 Env::GetInstance()->NotifyWindowInitialized(this); | 279 Env::GetInstance()->NotifyWindowInitialized(this); |
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1452 return window; | 1435 return window; |
1453 if (offset) | 1436 if (offset) |
1454 *offset += window->bounds().OffsetFromOrigin(); | 1437 *offset += window->bounds().OffsetFromOrigin(); |
1455 } | 1438 } |
1456 if (offset) | 1439 if (offset) |
1457 *offset = gfx::Vector2d(); | 1440 *offset = gfx::Vector2d(); |
1458 return NULL; | 1441 return NULL; |
1459 } | 1442 } |
1460 | 1443 |
1461 } // namespace aura | 1444 } // namespace aura |
OLD | NEW |