| Index: ui/display/chromeos/x11/display_snapshot_x11.cc
 | 
| diff --git a/chromeos/display/output_util.cc b/ui/display/chromeos/x11/display_snapshot_x11.cc
 | 
| similarity index 68%
 | 
| rename from chromeos/display/output_util.cc
 | 
| rename to ui/display/chromeos/x11/display_snapshot_x11.cc
 | 
| index a1485b4d28dc1024d3616be33c64b878e17503d3..d0032fd71d3af6127e56d289cf32f0762eb798e5 100644
 | 
| --- a/chromeos/display/output_util.cc
 | 
| +++ b/ui/display/chromeos/x11/display_snapshot_x11.cc
 | 
| @@ -1,23 +1,18 @@
 | 
| -// Copyright (c) 2013 The Chromium Authors. All rights reserved.
 | 
| +// Copyright 2014 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 "chromeos/display/output_util.h"
 | 
| +#include "ui/display/chromeos/x11/display_snapshot_x11.h"
 | 
|  
 | 
| -#include <X11/extensions/Xrandr.h>
 | 
| -#include <X11/Xatom.h>
 | 
|  #include <X11/Xlib.h>
 | 
|  
 | 
| -#include "base/strings/string_util.h"
 | 
| +#include "base/strings/stringprintf.h"
 | 
|  #include "base/x11/edid_parser_x11.h"
 | 
| +#include "ui/display/chromeos/x11/display_mode_x11.h"
 | 
|  
 | 
| -namespace chromeos {
 | 
| -namespace {
 | 
| +namespace ui {
 | 
|  
 | 
| -// Prefixes for the built-in displays.
 | 
| -const char kInternal_LVDS[] = "LVDS";
 | 
| -const char kInternal_eDP[] = "eDP";
 | 
| -const char kInternal_DSI[] = "DSI";
 | 
| +namespace {
 | 
|  
 | 
|  // Gets some useful data from the specified output device, such like
 | 
|  // manufacturer's ID, product code, and human readable name. Returns false if it
 | 
| @@ -27,7 +22,7 @@ bool GetOutputDeviceData(XID output,
 | 
|                           uint16* manufacturer_id,
 | 
|                           std::string* human_readable_name) {
 | 
|    unsigned long nitems = 0;
 | 
| -  unsigned char *prop = NULL;
 | 
| +  unsigned char* prop = NULL;
 | 
|    if (!base::GetEDIDProperty(output, &nitems, &prop))
 | 
|      return false;
 | 
|  
 | 
| @@ -37,28 +32,9 @@ bool GetOutputDeviceData(XID output,
 | 
|    return result;
 | 
|  }
 | 
|  
 | 
| -}  // namespace
 | 
| -
 | 
| -std::string GetDisplayName(XID output_id) {
 | 
| -  std::string display_name;
 | 
| -  GetOutputDeviceData(output_id, NULL, &display_name);
 | 
| -  return display_name;
 | 
| -}
 | 
| -
 | 
| -bool GetOutputOverscanFlag(XID output, bool* flag) {
 | 
| -  unsigned long nitems = 0;
 | 
| -  unsigned char *prop = NULL;
 | 
| -  if (!base::GetEDIDProperty(output, &nitems, &prop))
 | 
| -    return false;
 | 
| -
 | 
| -  bool found = ParseOutputOverscanFlag(prop, nitems, flag);
 | 
| -  XFree(prop);
 | 
| -  return found;
 | 
| -}
 | 
| -
 | 
|  bool ParseOutputOverscanFlag(const unsigned char* prop,
 | 
|                               unsigned long nitems,
 | 
| -                             bool *flag) {
 | 
| +                             bool* flag) {
 | 
|    // See http://en.wikipedia.org/wiki/Extended_display_identification_data
 | 
|    // for the extension format of EDID.  Also see EIA/CEA-861 spec for
 | 
|    // the format of the extensions and how video capability is encoded.
 | 
| @@ -135,42 +111,66 @@ bool ParseOutputOverscanFlag(const unsigned char* prop,
 | 
|    return false;
 | 
|  }
 | 
|  
 | 
| -bool IsInternalOutputName(const std::string& name) {
 | 
| -  return name.find(kInternal_LVDS) == 0 || name.find(kInternal_eDP) == 0 ||
 | 
| -      name.find(kInternal_DSI) == 0;
 | 
| -}
 | 
| +}  // namespace
 | 
|  
 | 
| -const XRRModeInfo* FindXRRModeInfo(const XRRScreenResources* screen_resources,
 | 
| -                                   XID current_mode) {
 | 
| -  for (int m = 0; m < screen_resources->nmode; m++) {
 | 
| -    XRRModeInfo *mode = &screen_resources->modes[m];
 | 
| -    if (mode->id == current_mode)
 | 
| -      return mode;
 | 
| -  }
 | 
| -  return NULL;
 | 
| +DisplaySnapshotX11::DisplaySnapshotX11(
 | 
| +    int64_t display_id,
 | 
| +    bool has_proper_display_id,
 | 
| +    const gfx::Point& origin,
 | 
| +    const gfx::Size& physical_size,
 | 
| +    OutputType type,
 | 
| +    bool is_aspect_preserving_scaling,
 | 
| +    const std::vector<const DisplayMode*>& modes,
 | 
| +    const DisplayMode* current_mode,
 | 
| +    const DisplayMode* native_mode,
 | 
| +    RROutput output,
 | 
| +    RRCrtc crtc,
 | 
| +    int index)
 | 
| +    : DisplaySnapshot(display_id,
 | 
| +                      has_proper_display_id,
 | 
| +                      origin,
 | 
| +                      physical_size,
 | 
| +                      type,
 | 
| +                      is_aspect_preserving_scaling,
 | 
| +                      modes,
 | 
| +                      current_mode,
 | 
| +                      native_mode),
 | 
| +      output_(output),
 | 
| +      crtc_(crtc),
 | 
| +      index_(index) {}
 | 
| +
 | 
| +DisplaySnapshotX11::~DisplaySnapshotX11() {}
 | 
| +
 | 
| +std::string DisplaySnapshotX11::GetDisplayName() {
 | 
| +  std::string display_name;
 | 
| +  GetOutputDeviceData(output_, NULL, &display_name);
 | 
| +  return display_name;
 | 
|  }
 | 
|  
 | 
| -namespace test {
 | 
| -
 | 
| -XRRModeInfo CreateModeInfo(int id,
 | 
| -                           int width,
 | 
| -                           int height,
 | 
| -                           bool interlaced,
 | 
| -                           float refresh_rate) {
 | 
| -  XRRModeInfo mode_info = {0};
 | 
| -  mode_info.id = id;
 | 
| -  mode_info.width = width;
 | 
| -  mode_info.height = height;
 | 
| -  if (interlaced)
 | 
| -    mode_info.modeFlags = RR_Interlace;
 | 
| -  if (refresh_rate != 0.0f) {
 | 
| -    mode_info.hTotal = 1;
 | 
| -    mode_info.vTotal = 1;
 | 
| -    mode_info.dotClock = refresh_rate;
 | 
| -  }
 | 
| -  return mode_info;
 | 
| +bool DisplaySnapshotX11::GetOverscanFlag() {
 | 
| +  unsigned long nitems = 0;
 | 
| +  unsigned char* prop = NULL;
 | 
| +  bool flag = false;
 | 
| +  if (!base::GetEDIDProperty(output_, &nitems, &prop))
 | 
| +    return false;
 | 
| +
 | 
| +  ParseOutputOverscanFlag(prop, nitems, &flag);
 | 
| +  XFree(prop);
 | 
| +
 | 
| +  return flag;
 | 
|  }
 | 
|  
 | 
| -}  // namespace test
 | 
| +std::string DisplaySnapshotX11::ToString() const {
 | 
| +  return base::StringPrintf(
 | 
| +      "[type=%d, output=%ld, crtc=%ld, mode=%ld, dim=%dx%d]",
 | 
| +      type_,
 | 
| +      output_,
 | 
| +      crtc_,
 | 
| +      current_mode_
 | 
| +          ? static_cast<const DisplayModeX11*>(current_mode_)->mode_id()
 | 
| +          : 0,
 | 
| +      physical_size_.width(),
 | 
| +      physical_size_.height());
 | 
| +}
 | 
|  
 | 
| -}  // namespace chromeos
 | 
| +}  // namespace ui
 | 
| 
 |