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 "ui/ozone/platform/drm/test/mock_drm_device.h" | 5 #include "ui/ozone/platform/drm/test/mock_drm_device.h" |
6 | 6 |
7 #include <xf86drm.h> | 7 #include <xf86drm.h> |
8 #include <xf86drmMode.h> | 8 #include <xf86drmMode.h> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 196 |
197 bool MockDrmDevice::CreateDumbBuffer(const SkImageInfo& info, | 197 bool MockDrmDevice::CreateDumbBuffer(const SkImageInfo& info, |
198 uint32_t* handle, | 198 uint32_t* handle, |
199 uint32_t* stride) { | 199 uint32_t* stride) { |
200 if (!create_dumb_buffer_expectation_) | 200 if (!create_dumb_buffer_expectation_) |
201 return false; | 201 return false; |
202 | 202 |
203 *handle = allocate_buffer_count_++; | 203 *handle = allocate_buffer_count_++; |
204 *stride = info.minRowBytes(); | 204 *stride = info.minRowBytes(); |
205 void* pixels = new char[info.getSafeSize(*stride)]; | 205 void* pixels = new char[info.getSafeSize(*stride)]; |
206 buffers_.push_back( | 206 buffers_.push_back(SkSurface::MakeRasterDirect(info, pixels, *stride)); |
207 skia::AdoptRef(SkSurface::NewRasterDirect(info, pixels, *stride))); | |
208 buffers_[*handle]->getCanvas()->clear(SK_ColorBLACK); | 207 buffers_[*handle]->getCanvas()->clear(SK_ColorBLACK); |
209 | 208 |
210 return true; | 209 return true; |
211 } | 210 } |
212 | 211 |
213 bool MockDrmDevice::DestroyDumbBuffer(uint32_t handle) { | 212 bool MockDrmDevice::DestroyDumbBuffer(uint32_t handle) { |
214 if (handle >= buffers_.size() || !buffers_[handle]) | 213 if (handle >= buffers_.size() || !buffers_[handle]) |
215 return false; | 214 return false; |
216 | 215 |
217 buffers_[handle].clear(); | 216 buffers_[handle].clear(); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 | 252 |
254 void MockDrmDevice::RunCallbacks() { | 253 void MockDrmDevice::RunCallbacks() { |
255 while (!callbacks_.empty()) { | 254 while (!callbacks_.empty()) { |
256 PageFlipCallback callback = callbacks_.front(); | 255 PageFlipCallback callback = callbacks_.front(); |
257 callbacks_.pop(); | 256 callbacks_.pop(); |
258 callback.Run(0, 0, 0); | 257 callback.Run(0, 0, 0); |
259 } | 258 } |
260 } | 259 } |
261 | 260 |
262 } // namespace ui | 261 } // namespace ui |
OLD | NEW |