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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: ui/ozone/platform/dri/test/mock_dri_wrapper.cc
diff --git a/ui/ozone/platform/dri/test/mock_dri_wrapper.cc b/ui/ozone/platform/dri/test/mock_dri_wrapper.cc
index 5063c2f805b83b1c00a2e37e333924590e28edb3..bb6bc13bfde88f2abd1b5575cb1e63afdab58ffb 100644
--- a/ui/ozone/platform/dri/test/mock_dri_wrapper.cc
+++ b/ui/ozone/platform/dri/test/mock_dri_wrapper.cc
@@ -7,6 +7,7 @@
#include <xf86drm.h>
#include <xf86drmMode.h>
+#include "third_party/skia/include/core/SkCanvas.h"
#include "ui/ozone/platform/dri/dri_surface.h"
#include "ui/ozone/platform/dri/hardware_display_controller.h"
@@ -30,7 +31,8 @@ MockDriWrapper::MockDriWrapper(int fd)
overlay_flip_call_count_(0),
set_crtc_expectation_(true),
add_framebuffer_expectation_(true),
- page_flip_expectation_(true) {
+ page_flip_expectation_(true),
+ create_dumb_buffer_expectation_(true) {
fd_ = fd;
}
@@ -120,4 +122,28 @@ bool MockDriWrapper::MoveCursor(uint32_t crtc_id, int x, int y) {
void MockDriWrapper::HandleEvent(drmEventContext& event) {
}
+bool MockDriWrapper::CreateDumbBuffer(const SkImageInfo& info,
+ uint32_t* handle,
+ uint32_t* stride,
+ void** pixels) {
+ if (!create_dumb_buffer_expectation_)
+ return false;
+
+ *handle = 0;
+ *stride = info.minRowBytes();
+ *pixels = new char[info.getSafeSize(*stride)];
+ buffers_.push_back(
+ skia::AdoptRef(SkSurface::NewRasterDirect(info, *pixels, *stride)));
+ buffers_.back()->getCanvas()->clear(SK_ColorBLACK);
+
+ return true;
+}
+
+void MockDriWrapper::DestroyDumbBuffer(const SkImageInfo& info,
+ uint32_t handle,
+ uint32_t stride,
+ void* pixels) {
+ delete[] static_cast<char*>(pixels);
+}
+
} // namespace ui

Powered by Google App Engine
This is Rietveld 408576698