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

Side by Side Diff: ui/ozone/platform/caca/caca_connection.cc

Issue 387993002: ozone: caca: Preparatory work for resize / multiple windows (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | « ui/ozone/platform/caca/caca_connection.h ('k') | ui/ozone/platform/caca/scoped_caca_types.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "ui/ozone/platform/caca/caca_connection.h" 5 #include "ui/ozone/platform/caca/caca_connection.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 8
9 namespace ui { 9 namespace ui {
10 10
11 // TODO(dnicoara) As an optimization, |bitmap_size_| should be scaled based on 11 namespace {
12 // |physical_size_| and font size. 12
13 CacaConnection::CacaConnection() 13 // Size of initial cnavas (in characters).
14 : canvas_(NULL), 14 const int kDefaultCanvasWidth = 160;
15 display_(NULL), 15 const int kDefaultCanvasHeight = 48;
16 physical_size_(160, 48), 16
17 bitmap_size_(800, 600) {} 17 } // namespace
18
19 CacaConnection::CacaConnection() {
20 }
18 21
19 CacaConnection::~CacaConnection() { 22 CacaConnection::~CacaConnection() {
20 if (display_) {
21 caca_free_display(display_);
22 caca_free_canvas(canvas_);
23 }
24 } 23 }
25 24
26 void CacaConnection::Initialize() { 25 bool CacaConnection::Initialize() {
27 if (display_) 26 if (display_)
28 return; 27 return true;
29 28
30 canvas_ = caca_create_canvas(physical_size_.width(), physical_size_.height()); 29 canvas_.reset(caca_create_canvas(kDefaultCanvasWidth, kDefaultCanvasHeight));
31 display_ = caca_create_display(canvas_); 30 if (!canvas_) {
31 PLOG(ERROR) << "failed to create libcaca canvas";
32 return false;
33 }
32 34
33 physical_size_.SetSize(caca_get_canvas_width(canvas_), 35 display_.reset(caca_create_display(canvas_.get()));
34 caca_get_canvas_height(canvas_)); 36 if (!display_) {
37 PLOG(ERROR) << "failed to initialize libcaca display";
38 return false;
39 }
35 40
36 caca_set_cursor(display_, 1); 41 caca_set_cursor(display_.get(), 1);
37 caca_set_display_title(display_, "Ozone Content Shell"); 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()));
38 } 55 }
39 56
40 } // namespace ui 57 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/caca/caca_connection.h ('k') | ui/ozone/platform/caca/scoped_caca_types.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698