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

Side by Side Diff: content/browser/aura/software_output_device_x11.cc

Issue 140753005: Add the UI compositor to the Mac build (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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 | « content/browser/aura/software_output_device_x11.h ('k') | content/browser/browser_main_loop.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 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 "content/browser/aura/software_output_device_x11.h"
6
7 #include <X11/Xlib.h>
8 #include <X11/Xutil.h>
9
10 #include "content/public/browser/browser_thread.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "third_party/skia/include/core/SkDevice.h"
13 #include "ui/compositor/compositor.h"
14 #include "ui/gfx/x/x11_types.h"
15
16 namespace content {
17
18 SoftwareOutputDeviceX11::SoftwareOutputDeviceX11(ui::Compositor* compositor)
19 : compositor_(compositor), display_(gfx::GetXDisplay()), gc_(NULL) {
20 // TODO(skaslev) Remove this when crbug.com/180702 is fixed.
21 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
22
23 gc_ = XCreateGC(display_, compositor_->widget(), 0, NULL);
24 if (!XGetWindowAttributes(display_, compositor_->widget(), &attributes_)) {
25 LOG(ERROR) << "XGetWindowAttributes failed for window "
26 << compositor_->widget();
27 return;
28 }
29 }
30
31 SoftwareOutputDeviceX11::~SoftwareOutputDeviceX11() {
32 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
33
34 XFreeGC(display_, gc_);
35 }
36
37 void SoftwareOutputDeviceX11::EndPaint(cc::SoftwareFrameData* frame_data) {
38 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
39 DCHECK(device_);
40 DCHECK(frame_data);
41
42 if (!device_)
43 return;
44
45 SoftwareOutputDevice::EndPaint(frame_data);
46
47 gfx::Rect rect = damage_rect_;
48 rect.Intersect(gfx::Rect(viewport_size_));
49 if (rect.IsEmpty())
50 return;
51
52 // TODO(jbauman): Switch to XShmPutImage since it's async.
53 const SkBitmap& bitmap = device_->accessBitmap(false);
54 gfx::PutARGBImage(display_,
55 attributes_.visual,
56 attributes_.depth,
57 compositor_->widget(),
58 gc_,
59 static_cast<const uint8*>(bitmap.getPixels()),
60 viewport_size_.width(),
61 viewport_size_.height(),
62 rect.x(),
63 rect.y(),
64 rect.x(),
65 rect.y(),
66 rect.width(),
67 rect.height());
68 }
69
70 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/aura/software_output_device_x11.h ('k') | content/browser/browser_main_loop.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698