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

Side by Side Diff: ui/ozone/platform/dri/test/mock_dri_wrapper.cc

Issue 402773002: [Ozone-DRI] Removing MockDriSurface implementation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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
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 "ui/ozone/platform/dri/test/mock_dri_wrapper.h" 5 #include "ui/ozone/platform/dri/test/mock_dri_wrapper.h"
6 6
7 #include <xf86drm.h> 7 #include <xf86drm.h>
8 #include <xf86drmMode.h> 8 #include <xf86drmMode.h>
9 9
10 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "ui/ozone/platform/dri/dri_surface.h" 11 #include "ui/ozone/platform/dri/dri_surface.h"
11 #include "ui/ozone/platform/dri/hardware_display_controller.h" 12 #include "ui/ozone/platform/dri/hardware_display_controller.h"
12 13
13 namespace ui { 14 namespace ui {
14 15
15 namespace { 16 namespace {
16 17
17 template<class Object> Object* DrmAllocator() { 18 template<class Object> Object* DrmAllocator() {
18 return static_cast<Object*>(drmMalloc(sizeof(Object))); 19 return static_cast<Object*>(drmMalloc(sizeof(Object)));
19 } 20 }
20 21
21 } // namespace 22 } // namespace
22 23
23 MockDriWrapper::MockDriWrapper(int fd) 24 MockDriWrapper::MockDriWrapper(int fd)
24 : DriWrapper(""), 25 : DriWrapper(""),
25 get_crtc_call_count_(0), 26 get_crtc_call_count_(0),
26 restore_crtc_call_count_(0), 27 restore_crtc_call_count_(0),
27 add_framebuffer_call_count_(0), 28 add_framebuffer_call_count_(0),
28 remove_framebuffer_call_count_(0), 29 remove_framebuffer_call_count_(0),
29 page_flip_call_count_(0), 30 page_flip_call_count_(0),
30 overlay_flip_call_count_(0), 31 overlay_flip_call_count_(0),
31 set_crtc_expectation_(true), 32 set_crtc_expectation_(true),
32 add_framebuffer_expectation_(true), 33 add_framebuffer_expectation_(true),
33 page_flip_expectation_(true) { 34 page_flip_expectation_(true),
35 create_dumb_buffer_expectation_(true) {
34 fd_ = fd; 36 fd_ = fd;
35 } 37 }
36 38
37 MockDriWrapper::~MockDriWrapper() { 39 MockDriWrapper::~MockDriWrapper() {
38 fd_ = -1; 40 fd_ = -1;
39 } 41 }
40 42
41 ScopedDrmCrtcPtr MockDriWrapper::GetCrtc(uint32_t crtc_id) { 43 ScopedDrmCrtcPtr MockDriWrapper::GetCrtc(uint32_t crtc_id) {
42 get_crtc_call_count_++; 44 get_crtc_call_count_++;
43 return ScopedDrmCrtcPtr(DrmAllocator<drmModeCrtc>()); 45 return ScopedDrmCrtcPtr(DrmAllocator<drmModeCrtc>());
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 return true; 115 return true;
114 } 116 }
115 117
116 bool MockDriWrapper::MoveCursor(uint32_t crtc_id, int x, int y) { 118 bool MockDriWrapper::MoveCursor(uint32_t crtc_id, int x, int y) {
117 return true; 119 return true;
118 } 120 }
119 121
120 void MockDriWrapper::HandleEvent(drmEventContext& event) { 122 void MockDriWrapper::HandleEvent(drmEventContext& event) {
121 } 123 }
122 124
125 bool MockDriWrapper::CreateDumbBuffer(const SkImageInfo& info,
126 uint32_t* handle,
127 uint32_t* stride,
128 void** pixels) {
129 if (!create_dumb_buffer_expectation_)
130 return false;
131
132 *handle = 0;
133 *stride = info.minRowBytes();
134 *pixels = new char[info.getSafeSize(*stride)];
135 buffers_.push_back(
136 skia::AdoptRef(SkSurface::NewRasterDirect(info, *pixels, *stride)));
137 buffers_.back()->getCanvas()->clear(SK_ColorBLACK);
138
139 return true;
140 }
141
142 void MockDriWrapper::DestroyDumbBuffer(const SkImageInfo& info,
143 uint32_t handle,
144 uint32_t stride,
145 void* pixels) {
146 delete[] static_cast<char*>(pixels);
147 }
148
123 } // namespace ui 149 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698