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/gpu/mock_drm_device.h" | 5 #include "ui/ozone/platform/drm/gpu/mock_drm_device.h" |
6 | 6 |
7 #include <xf86drm.h> | 7 #include <xf86drm.h> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 | 178 |
179 bool MockDrmDevice::CreateDumbBuffer(const SkImageInfo& info, | 179 bool MockDrmDevice::CreateDumbBuffer(const SkImageInfo& info, |
180 uint32_t* handle, | 180 uint32_t* handle, |
181 uint32_t* stride) { | 181 uint32_t* stride) { |
182 if (!create_dumb_buffer_expectation_) | 182 if (!create_dumb_buffer_expectation_) |
183 return false; | 183 return false; |
184 | 184 |
185 *handle = allocate_buffer_count_++; | 185 *handle = allocate_buffer_count_++; |
186 *stride = info.minRowBytes(); | 186 *stride = info.minRowBytes(); |
187 void* pixels = new char[info.getSafeSize(*stride)]; | 187 void* pixels = new char[info.getSafeSize(*stride)]; |
188 buffers_.push_back( | 188 buffers_.push_back(SkSurface::MakeRasterDirect(info, pixels, *stride)); |
189 skia::AdoptRef(SkSurface::NewRasterDirect(info, pixels, *stride))); | |
190 buffers_[*handle]->getCanvas()->clear(SK_ColorBLACK); | 189 buffers_[*handle]->getCanvas()->clear(SK_ColorBLACK); |
191 | 190 |
192 return true; | 191 return true; |
193 } | 192 } |
194 | 193 |
195 bool MockDrmDevice::DestroyDumbBuffer(uint32_t handle) { | 194 bool MockDrmDevice::DestroyDumbBuffer(uint32_t handle) { |
196 if (handle >= buffers_.size() || !buffers_[handle]) | 195 if (handle >= buffers_.size() || !buffers_[handle]) |
197 return false; | 196 return false; |
198 | 197 |
199 buffers_[handle].clear(); | 198 buffers_[handle].reset(); |
200 return true; | 199 return true; |
201 } | 200 } |
202 | 201 |
203 bool MockDrmDevice::MapDumbBuffer(uint32_t handle, size_t size, void** pixels) { | 202 bool MockDrmDevice::MapDumbBuffer(uint32_t handle, size_t size, void** pixels) { |
204 if (handle >= buffers_.size() || !buffers_[handle]) | 203 if (handle >= buffers_.size() || !buffers_[handle]) |
205 return false; | 204 return false; |
206 | 205 |
207 *pixels = const_cast<void*>(buffers_[handle]->peekPixels(nullptr, nullptr)); | 206 *pixels = const_cast<void*>(buffers_[handle]->peekPixels(nullptr, nullptr)); |
208 return true; | 207 return true; |
209 } | 208 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 241 |
243 void MockDrmDevice::RunCallbacks() { | 242 void MockDrmDevice::RunCallbacks() { |
244 while (!callbacks_.empty()) { | 243 while (!callbacks_.empty()) { |
245 PageFlipCallback callback = callbacks_.front(); | 244 PageFlipCallback callback = callbacks_.front(); |
246 callbacks_.pop(); | 245 callbacks_.pop(); |
247 callback.Run(0, 0, 0); | 246 callback.Run(0, 0, 0); |
248 } | 247 } |
249 } | 248 } |
250 | 249 |
251 } // namespace ui | 250 } // namespace ui |
OLD | NEW |