OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "ui/ozone/platform/caca/caca_connection.h" | |
6 | |
7 #include "base/logging.h" | |
8 | |
9 namespace ui { | |
10 | |
11 namespace { | |
12 | |
13 // Size of initial cnavas (in characters). | |
14 const int kDefaultCanvasWidth = 160; | |
15 const int kDefaultCanvasHeight = 48; | |
16 | |
17 } // namespace | |
18 | |
19 CacaConnection::CacaConnection() { | |
20 } | |
21 | |
22 CacaConnection::~CacaConnection() { | |
23 } | |
24 | |
25 bool CacaConnection::Initialize() { | |
26 if (display_) | |
27 return true; | |
28 | |
29 canvas_.reset(caca_create_canvas(kDefaultCanvasWidth, kDefaultCanvasHeight)); | |
30 if (!canvas_) { | |
31 PLOG(ERROR) << "failed to create libcaca canvas"; | |
32 return false; | |
33 } | |
34 | |
35 display_.reset(caca_create_display(canvas_.get())); | |
36 if (!display_) { | |
37 PLOG(ERROR) << "failed to initialize libcaca display"; | |
38 return false; | |
39 } | |
40 | |
41 caca_set_cursor(display_.get(), 1); | |
42 caca_set_display_title(display_.get(), "Ozone Content Shell"); | |
43 | |
44 UpdateDisplaySize(); | |
45 | |
46 return true; | |
47 } | |
48 | |
49 void CacaConnection::UpdateDisplaySize() { | |
50 physical_size_.SetSize(caca_get_canvas_width(canvas_.get()), | |
51 caca_get_canvas_height(canvas_.get())); | |
52 | |
53 bitmap_size_.SetSize(caca_get_display_width(display_.get()), | |
54 caca_get_display_height(display_.get())); | |
55 } | |
56 | |
57 } // namespace ui | |
OLD | NEW |