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

Side by Side Diff: ui/gfx/ozone/impl/dri_surface.cc

Issue 49303002: [Ozone] Rename software implementation files to use Dri prefix (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix ifdef Created 7 years, 1 month 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/gfx/ozone/impl/dri_surface.h ('k') | ui/gfx/ozone/impl/dri_surface_factory.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 2013 The Chromium Authors. All rights reserved. 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 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/gfx/ozone/impl/software_surface_ozone.h" 5 #include "ui/gfx/ozone/impl/dri_surface.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <sys/mman.h> 8 #include <sys/mman.h>
9 #include <sys/types.h> 9 #include <sys/types.h>
10 #include <xf86drm.h> 10 #include <xf86drm.h>
11 11
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "third_party/skia/include/core/SkBitmap.h" 13 #include "third_party/skia/include/core/SkBitmap.h"
14 #include "third_party/skia/include/core/SkBitmapDevice.h" 14 #include "third_party/skia/include/core/SkBitmapDevice.h"
15 #include "third_party/skia/include/core/SkCanvas.h" 15 #include "third_party/skia/include/core/SkCanvas.h"
16 #include "ui/gfx/ozone/impl/drm_skbitmap_ozone.h" 16 #include "ui/gfx/ozone/impl/dri_skbitmap.h"
17 #include "ui/gfx/ozone/impl/hardware_display_controller_ozone.h" 17 #include "ui/gfx/ozone/impl/hardware_display_controller.h"
18 #include "ui/gfx/skia_util.h" 18 #include "ui/gfx/skia_util.h"
19 19
20 namespace gfx { 20 namespace gfx {
21 21
22 namespace { 22 namespace {
23 23
24 // Extends the SkBitmapDevice to allow setting the SkPixelRef. We use the setter 24 // Extends the SkBitmapDevice to allow setting the SkPixelRef. We use the setter
25 // to change the SkPixelRef such that the device always points to the 25 // to change the SkPixelRef such that the device always points to the
26 // backbuffer. 26 // backbuffer.
27 class CustomSkBitmapDevice : public SkBitmapDevice { 27 class CustomSkBitmapDevice : public SkBitmapDevice {
28 public: 28 public:
29 CustomSkBitmapDevice(const SkBitmap& bitmap) : SkBitmapDevice(bitmap) {} 29 CustomSkBitmapDevice(const SkBitmap& bitmap) : SkBitmapDevice(bitmap) {}
30 virtual ~CustomSkBitmapDevice() {} 30 virtual ~CustomSkBitmapDevice() {}
31 31
32 void SetPixelRef(SkPixelRef* pixel_ref) { setPixelRef(pixel_ref, 0); } 32 void SetPixelRef(SkPixelRef* pixel_ref) { setPixelRef(pixel_ref, 0); }
33 33
34 private: 34 private:
35 DISALLOW_COPY_AND_ASSIGN(CustomSkBitmapDevice); 35 DISALLOW_COPY_AND_ASSIGN(CustomSkBitmapDevice);
36 }; 36 };
37 37
38 } // namespace 38 } // namespace
39 39
40 //////////////////////////////////////////////////////////////////////////////// 40 ////////////////////////////////////////////////////////////////////////////////
41 // SoftwareSurfaceOzone implementation 41 // DriSurface implementation
42 42
43 SoftwareSurfaceOzone::SoftwareSurfaceOzone( 43 DriSurface::DriSurface(
44 HardwareDisplayControllerOzone* controller) 44 HardwareDisplayController* controller)
45 : controller_(controller), 45 : controller_(controller),
46 bitmaps_(), 46 bitmaps_(),
47 front_buffer_(0) { 47 front_buffer_(0) {
48 } 48 }
49 49
50 SoftwareSurfaceOzone::~SoftwareSurfaceOzone() { 50 DriSurface::~DriSurface() {
51 } 51 }
52 52
53 bool SoftwareSurfaceOzone::Initialize() { 53 bool DriSurface::Initialize() {
54 for (int i = 0; i < 2; ++i) { 54 for (int i = 0; i < 2; ++i) {
55 bitmaps_[i].reset(CreateBuffer()); 55 bitmaps_[i].reset(CreateBuffer());
56 // TODO(dnicoara) Should select the configuration based on what the 56 // TODO(dnicoara) Should select the configuration based on what the
57 // underlying system supports. 57 // underlying system supports.
58 bitmaps_[i]->setConfig(SkBitmap::kARGB_8888_Config, 58 bitmaps_[i]->setConfig(SkBitmap::kARGB_8888_Config,
59 controller_->get_mode().hdisplay, 59 controller_->get_mode().hdisplay,
60 controller_->get_mode().vdisplay); 60 controller_->get_mode().vdisplay);
61 61
62 if (!bitmaps_[i]->Initialize()) { 62 if (!bitmaps_[i]->Initialize()) {
63 return false; 63 return false;
64 } 64 }
65 } 65 }
66 66
67 skia_device_ = skia::AdoptRef( 67 skia_device_ = skia::AdoptRef(
68 new CustomSkBitmapDevice(*bitmaps_[front_buffer_ ^ 1].get())); 68 new CustomSkBitmapDevice(*bitmaps_[front_buffer_ ^ 1].get()));
69 skia_canvas_ = skia::AdoptRef(new SkCanvas(skia_device_.get())); 69 skia_canvas_ = skia::AdoptRef(new SkCanvas(skia_device_.get()));
70 70
71 return true; 71 return true;
72 } 72 }
73 73
74 uint32_t SoftwareSurfaceOzone::GetFramebufferId() const { 74 uint32_t DriSurface::GetFramebufferId() const {
75 CHECK(bitmaps_[0].get() && bitmaps_[1].get()); 75 CHECK(bitmaps_[0].get() && bitmaps_[1].get());
76 return bitmaps_[front_buffer_ ^ 1]->get_framebuffer(); 76 return bitmaps_[front_buffer_ ^ 1]->get_framebuffer();
77 } 77 }
78 78
79 // This call is made after the hardware just started displaying our back buffer. 79 // This call is made after the hardware just started displaying our back buffer.
80 // We need to update our pointer reference and synchronize the two buffers. 80 // We need to update our pointer reference and synchronize the two buffers.
81 void SoftwareSurfaceOzone::SwapBuffers() { 81 void DriSurface::SwapBuffers() {
82 CHECK(bitmaps_[0].get() && bitmaps_[1].get()); 82 CHECK(bitmaps_[0].get() && bitmaps_[1].get());
83 83
84 // Update our front buffer pointer. 84 // Update our front buffer pointer.
85 front_buffer_ ^= 1; 85 front_buffer_ ^= 1;
86 86
87 // Unlocking will unset the pixel pointer, so it won't be pointing to the old 87 // Unlocking will unset the pixel pointer, so it won't be pointing to the old
88 // PixelRef. 88 // PixelRef.
89 skia_device_->accessBitmap(false).unlockPixels(); 89 skia_device_->accessBitmap(false).unlockPixels();
90 // Update the backing pixels for the bitmap device. 90 // Update the backing pixels for the bitmap device.
91 static_cast<CustomSkBitmapDevice*>(skia_device_.get())->SetPixelRef( 91 static_cast<CustomSkBitmapDevice*>(skia_device_.get())->SetPixelRef(
92 bitmaps_[front_buffer_ ^ 1]->pixelRef()); 92 bitmaps_[front_buffer_ ^ 1]->pixelRef());
93 // Locking the pixels will set the pixel pointer based on the PixelRef value. 93 // Locking the pixels will set the pixel pointer based on the PixelRef value.
94 skia_device_->accessBitmap(false).lockPixels(); 94 skia_device_->accessBitmap(false).lockPixels();
95 95
96 SkIRect device_damage; 96 SkIRect device_damage;
97 skia_canvas_->getClipDeviceBounds(&device_damage); 97 skia_canvas_->getClipDeviceBounds(&device_damage);
98 SkRect damage = SkRect::Make(device_damage); 98 SkRect damage = SkRect::Make(device_damage);
99 99
100 skia_canvas_->drawBitmapRectToRect(*bitmaps_[front_buffer_].get(), 100 skia_canvas_->drawBitmapRectToRect(*bitmaps_[front_buffer_].get(),
101 &damage, 101 &damage,
102 damage); 102 damage);
103 } 103 }
104 104
105 SkCanvas* SoftwareSurfaceOzone::GetDrawableForWidget() { 105 SkCanvas* DriSurface::GetDrawableForWidget() {
106 return skia_canvas_.get(); 106 return skia_canvas_.get();
107 } 107 }
108 108
109 DrmSkBitmapOzone* SoftwareSurfaceOzone::CreateBuffer() { 109 DriSkBitmap* DriSurface::CreateBuffer() {
110 return new DrmSkBitmapOzone(controller_->get_fd()); 110 return new DriSkBitmap(controller_->get_fd());
111 } 111 }
112 112
113 } // namespace gfx 113 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/ozone/impl/dri_surface.h ('k') | ui/gfx/ozone/impl/dri_surface_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698