| 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 <vector> | 5 #include <vector> |
| 6 | 6 |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "third_party/skia/include/core/SkCanvas.h" | 10 #include "third_party/skia/include/core/SkCanvas.h" |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 scoped_ptr<ui::SurfaceOzoneCanvas> surf = factory_->CreateCanvasForWidget( | 123 scoped_ptr<ui::SurfaceOzoneCanvas> surf = factory_->CreateCanvasForWidget( |
| 124 ui::DriSurfaceFactory::kDefaultWidgetHandle); | 124 ui::DriSurfaceFactory::kDefaultWidgetHandle); |
| 125 EXPECT_TRUE(surf); | 125 EXPECT_TRUE(surf); |
| 126 | 126 |
| 127 SkBitmap image; | 127 SkBitmap image; |
| 128 SkImageInfo info = SkImageInfo::Make( | 128 SkImageInfo info = SkImageInfo::Make( |
| 129 6, 4, kN32_SkColorType, kPremul_SkAlphaType); | 129 6, 4, kN32_SkColorType, kPremul_SkAlphaType); |
| 130 image.allocPixels(info); | 130 image.allocPixels(info); |
| 131 image.eraseColor(SK_ColorWHITE); | 131 image.eraseColor(SK_ColorWHITE); |
| 132 | 132 |
| 133 factory_->SetHardwareCursor( | 133 std::vector<SkBitmap> cursor_bitmaps; |
| 134 ui::DriSurfaceFactory::kDefaultWidgetHandle, image, gfx::Point(4, 2)); | 134 cursor_bitmaps.push_back(image); |
| 135 factory_->SetHardwareCursor(ui::DriSurfaceFactory::kDefaultWidgetHandle, |
| 136 cursor_bitmaps, |
| 137 gfx::Point(4, 2), |
| 138 0); |
| 135 | 139 |
| 136 SkBitmap cursor; | 140 SkBitmap cursor; |
| 137 // Buffers 0 and 1 are the cursor buffers. | 141 // Buffers 0 and 1 are the cursor buffers. |
| 138 cursor.setInfo(dri_->buffers()[1]->getCanvas()->imageInfo()); | 142 cursor.setInfo(dri_->buffers()[1]->getCanvas()->imageInfo()); |
| 139 EXPECT_TRUE(dri_->buffers()[1]->getCanvas()->readPixels(&cursor, 0, 0)); | 143 EXPECT_TRUE(dri_->buffers()[1]->getCanvas()->readPixels(&cursor, 0, 0)); |
| 140 | 144 |
| 141 // Check that the frontbuffer is displaying the right image as set above. | 145 // Check that the frontbuffer is displaying the right image as set above. |
| 142 for (int i = 0; i < cursor.height(); ++i) { | 146 for (int i = 0; i < cursor.height(); ++i) { |
| 143 for (int j = 0; j < cursor.width(); ++j) { | 147 for (int j = 0; j < cursor.width(); ++j) { |
| 144 if (j < info.width() && i < info.height()) | 148 if (j < info.width() && i < info.height()) |
| 145 EXPECT_EQ(SK_ColorWHITE, cursor.getColor(j, i)); | 149 EXPECT_EQ(SK_ColorWHITE, cursor.getColor(j, i)); |
| 146 else | 150 else |
| 147 EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT), | 151 EXPECT_EQ(static_cast<SkColor>(SK_ColorTRANSPARENT), |
| 148 cursor.getColor(j, i)); | 152 cursor.getColor(j, i)); |
| 149 } | 153 } |
| 150 } | 154 } |
| 151 } | 155 } |
| OLD | NEW |