| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "ui/ozone/platform/dri/test/mock_dri_surface.h" | |
| 6 | |
| 7 #include "third_party/skia/include/core/SkCanvas.h" | |
| 8 #include "ui/ozone/platform/dri/dri_buffer.h" | |
| 9 #include "ui/ozone/platform/dri/dri_wrapper.h" | |
| 10 | |
| 11 namespace ui { | |
| 12 | |
| 13 namespace { | |
| 14 | |
| 15 class MockDriBuffer : public DriBuffer { | |
| 16 public: | |
| 17 MockDriBuffer(DriWrapper* dri, bool initialize_expectation) | |
| 18 : DriBuffer(dri), initialize_expectation_(initialize_expectation) {} | |
| 19 virtual ~MockDriBuffer() { surface_.clear(); } | |
| 20 | |
| 21 virtual bool Initialize(const SkImageInfo& info) OVERRIDE { | |
| 22 if (!initialize_expectation_) | |
| 23 return false; | |
| 24 | |
| 25 dri_->AddFramebuffer( | |
| 26 info.width(), info.height(), 24, 32, stride_, handle_, &framebuffer_); | |
| 27 surface_ = skia::AdoptRef(SkSurface::NewRaster(info)); | |
| 28 surface_->getCanvas()->clear(SK_ColorBLACK); | |
| 29 | |
| 30 return true; | |
| 31 } | |
| 32 | |
| 33 private: | |
| 34 bool initialize_expectation_; | |
| 35 | |
| 36 DISALLOW_COPY_AND_ASSIGN(MockDriBuffer); | |
| 37 }; | |
| 38 | |
| 39 } // namespace | |
| 40 | |
| 41 MockDriSurface::MockDriSurface(DriWrapper* dri, const gfx::Size& size) | |
| 42 : DriSurface(dri, size), dri_(dri), initialize_expectation_(true) {} | |
| 43 | |
| 44 MockDriSurface::~MockDriSurface() {} | |
| 45 | |
| 46 DriBuffer* MockDriSurface::CreateBuffer() { | |
| 47 MockDriBuffer* bitmap = new MockDriBuffer(dri_, initialize_expectation_); | |
| 48 bitmaps_.push_back(bitmap); | |
| 49 | |
| 50 return bitmap; | |
| 51 } | |
| 52 | |
| 53 } // namespace ui | |
| OLD | NEW |