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

Side by Side Diff: content/browser/renderer_host/software_output_device_linux.cc

Issue 11967033: [CLOSED] In-browser software compositing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix the lack SkCanvas::clear scissoring. Created 7 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
OLDNEW
(Empty)
1 // Copyright (c) 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/renderer_host/software_output_device.h"
6
7 #include <X11/Xlib.h>
8 #include <X11/Xutil.h>
9
10 #include "third_party/skia/include/core/SkBitmap.h"
11 #include "third_party/skia/include/core/SkDevice.h"
12 #include "ui/compositor/compositor.h"
13
14 namespace content {
15
16 SoftwareOutputDevice::SoftwareOutputDevice(ui::Compositor* compositor)
17 : compositor_(compositor),
18 display_(ui::GetXDisplay()),
19 gc_(NULL),
20 image_(NULL) {
21 gc_ = XCreateGC(display_, compositor_->widget(), 0, NULL);
22 }
23
24 SoftwareOutputDevice::~SoftwareOutputDevice() {
25 XFreeGC(display_, gc_);
26 ClearImage();
27 }
28
29 void SoftwareOutputDevice::ClearImage() {
30 if (image_) {
31 // XDestroyImage deletes the data referenced by the image which
32 // is actually owned by the device_. So we have to reset data here.
33 image_->data = NULL;
34 XDestroyImage(image_);
35 image_ = NULL;
36 }
37 }
38
39 void SoftwareOutputDevice::Resize(const gfx::Size& viewport_size) {
40 SoftwareOutputDeviceImpl::Resize(viewport_size);
41
42 ClearImage();
43 if (!device_)
44 return;
45
46 const SkBitmap& bitmap = device_->accessBitmap(false);
47 image_ = XCreateImage(display_, CopyFromParent,
48 DefaultDepth(display_, DefaultScreen(display_)),
49 ZPixmap, 0,
50 static_cast<char*>(bitmap.getPixels()),
51 viewport_size_.width(), viewport_size_.height(),
52 32, 4 * viewport_size_.width());
53 }
54
55 void SoftwareOutputDevice::EndPaint(const gfx::Rect& damage_rect) {
56 if (!device_)
57 return;
58
59 gfx::Rect rect = damage_rect;
60 rect.Intersect(gfx::Rect(viewport_size_));
61 if (rect.IsEmpty())
62 return;
63
64 // TODO(skaslev): Maybe switch XShmPutImage since it's async.
65 XPutImage(display_, compositor_->widget(), gc_, image_,
66 rect.x(), rect.y(),
67 rect.x(), rect.y(),
68 rect.width(), rect.height());
69 }
70
71 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/software_output_device.h ('k') | content/browser/renderer_host/software_output_device_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698