OLD | NEW |
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 "content/browser/compositor/software_output_device_x11.h" | 5 #include "content/browser/compositor/software_output_device_x11.h" |
6 | 6 |
7 #include <X11/Xlib.h> | 7 #include <X11/Xlib.h> |
8 #include <X11/Xutil.h> | 8 #include <X11/Xutil.h> |
9 | 9 |
10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
(...skipping 20 matching lines...) Expand all Loading... |
31 } | 31 } |
32 | 32 |
33 SoftwareOutputDeviceX11::~SoftwareOutputDeviceX11() { | 33 SoftwareOutputDeviceX11::~SoftwareOutputDeviceX11() { |
34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 34 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
35 | 35 |
36 XFreeGC(display_, gc_); | 36 XFreeGC(display_, gc_); |
37 } | 37 } |
38 | 38 |
39 void SoftwareOutputDeviceX11::EndPaint(cc::SoftwareFrameData* frame_data) { | 39 void SoftwareOutputDeviceX11::EndPaint(cc::SoftwareFrameData* frame_data) { |
40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 40 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
41 DCHECK(canvas_); | 41 DCHECK(surface_); |
42 DCHECK(frame_data); | 42 DCHECK(frame_data); |
43 | 43 |
44 if (!canvas_) | 44 if (!surface_) |
45 return; | 45 return; |
46 | 46 |
47 SoftwareOutputDevice::EndPaint(frame_data); | 47 SoftwareOutputDevice::EndPaint(frame_data); |
48 | 48 |
49 gfx::Rect rect = damage_rect_; | 49 gfx::Rect rect = damage_rect_; |
50 rect.Intersect(gfx::Rect(viewport_pixel_size_)); | 50 rect.Intersect(gfx::Rect(viewport_pixel_size_)); |
51 if (rect.IsEmpty()) | 51 if (rect.IsEmpty()) |
52 return; | 52 return; |
53 | 53 |
54 int bpp = gfx::BitsPerPixelForPixmapDepth(display_, attributes_.depth); | 54 int bpp = gfx::BitsPerPixelForPixmapDepth(display_, attributes_.depth); |
55 | 55 |
56 if (bpp != 32 && bpp != 16 && ui::QueryRenderSupport(display_)) { | 56 if (bpp != 32 && bpp != 16 && ui::QueryRenderSupport(display_)) { |
57 // gfx::PutARGBImage only supports 16 and 32 bpp, but Xrender can do other | 57 // gfx::PutARGBImage only supports 16 and 32 bpp, but Xrender can do other |
58 // conversions. | 58 // conversions. |
59 Pixmap pixmap = XCreatePixmap( | 59 Pixmap pixmap = XCreatePixmap( |
60 display_, compositor_->widget(), rect.width(), rect.height(), 32); | 60 display_, compositor_->widget(), rect.width(), rect.height(), 32); |
61 GC gc = XCreateGC(display_, pixmap, 0, NULL); | 61 GC gc = XCreateGC(display_, pixmap, 0, NULL); |
62 XImage image; | 62 XImage image; |
63 memset(&image, 0, sizeof(image)); | 63 memset(&image, 0, sizeof(image)); |
64 | 64 |
65 SkImageInfo info; | 65 SkImageInfo info; |
66 size_t rowBytes; | 66 size_t rowBytes; |
67 const void* addr = canvas_->peekPixels(&info, &rowBytes); | 67 const void* addr = surface_->peekPixels(&info, &rowBytes); |
68 image.width = viewport_pixel_size_.width(); | 68 image.width = viewport_pixel_size_.width(); |
69 image.height = viewport_pixel_size_.height(); | 69 image.height = viewport_pixel_size_.height(); |
70 image.depth = 32; | 70 image.depth = 32; |
71 image.bits_per_pixel = 32; | 71 image.bits_per_pixel = 32; |
72 image.format = ZPixmap; | 72 image.format = ZPixmap; |
73 image.byte_order = LSBFirst; | 73 image.byte_order = LSBFirst; |
74 image.bitmap_unit = 8; | 74 image.bitmap_unit = 8; |
75 image.bitmap_bit_order = LSBFirst; | 75 image.bitmap_bit_order = LSBFirst; |
76 image.bytes_per_line = rowBytes; | 76 image.bytes_per_line = rowBytes; |
77 image.red_mask = 0xff; | 77 image.red_mask = 0xff; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 rect.height()); // height | 111 rect.height()); // height |
112 XRenderFreePicture(display_, picture); | 112 XRenderFreePicture(display_, picture); |
113 XRenderFreePicture(display_, dest_picture); | 113 XRenderFreePicture(display_, dest_picture); |
114 XFreePixmap(display_, pixmap); | 114 XFreePixmap(display_, pixmap); |
115 return; | 115 return; |
116 } | 116 } |
117 | 117 |
118 // TODO(jbauman): Switch to XShmPutImage since it's async. | 118 // TODO(jbauman): Switch to XShmPutImage since it's async. |
119 SkImageInfo info; | 119 SkImageInfo info; |
120 size_t rowBytes; | 120 size_t rowBytes; |
121 const void* addr = canvas_->peekPixels(&info, &rowBytes); | 121 const void* addr = surface_->peekPixels(&info, &rowBytes); |
122 gfx::PutARGBImage(display_, | 122 gfx::PutARGBImage(display_, |
123 attributes_.visual, | 123 attributes_.visual, |
124 attributes_.depth, | 124 attributes_.depth, |
125 compositor_->widget(), | 125 compositor_->widget(), |
126 gc_, | 126 gc_, |
127 static_cast<const uint8*>(addr), | 127 static_cast<const uint8*>(addr), |
128 viewport_pixel_size_.width(), | 128 viewport_pixel_size_.width(), |
129 viewport_pixel_size_.height(), | 129 viewport_pixel_size_.height(), |
130 rect.x(), | 130 rect.x(), |
131 rect.y(), | 131 rect.y(), |
132 rect.x(), | 132 rect.x(), |
133 rect.y(), | 133 rect.y(), |
134 rect.width(), | 134 rect.width(), |
135 rect.height()); | 135 rect.height()); |
136 } | 136 } |
137 | 137 |
138 } // namespace content | 138 } // namespace content |
OLD | NEW |