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

Side by Side Diff: components/exo/surface_unittest.cc

Issue 1548163002: exo: Add Surface::SetBufferScale. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use contents_size to determine layer transform Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « components/exo/surface.cc ('k') | components/exo/wayland/server.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "components/exo/buffer.h" 6 #include "components/exo/buffer.h"
7 #include "components/exo/surface.h" 7 #include "components/exo/surface.h"
8 #include "components/exo/test/exo_test_base.h" 8 #include "components/exo/test/exo_test_base.h"
9 #include "components/exo/test/exo_test_helper.h" 9 #include "components/exo/test/exo_test_helper.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 TEST_F(SurfaceTest, SetOpaqueRegion) { 84 TEST_F(SurfaceTest, SetOpaqueRegion) {
85 scoped_ptr<Surface> surface(new Surface); 85 scoped_ptr<Surface> surface(new Surface);
86 86
87 // Setting a non-empty opaque region should succeed. 87 // Setting a non-empty opaque region should succeed.
88 surface->SetOpaqueRegion(SkRegion(SkIRect::MakeWH(256, 256))); 88 surface->SetOpaqueRegion(SkRegion(SkIRect::MakeWH(256, 256)));
89 89
90 // Setting an empty opaque region should succeed. 90 // Setting an empty opaque region should succeed.
91 surface->SetOpaqueRegion(SkRegion(SkIRect::MakeEmpty())); 91 surface->SetOpaqueRegion(SkRegion(SkIRect::MakeEmpty()));
92 } 92 }
93 93
94 TEST_F(SurfaceTest, SetBufferScale) {
95 gfx::Size buffer_size(512, 512);
96 scoped_ptr<Buffer> buffer(
97 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size).Pass(),
98 GL_TEXTURE_2D));
99 scoped_ptr<Surface> surface(new Surface);
100
101 // Attach the buffer to the surface. This will update the pending bounds of
102 // the surface to the buffer size.
103 surface->Attach(buffer.get());
104 EXPECT_EQ(buffer_size.ToString(), surface->GetPreferredSize().ToString());
105
106 // This will update the pending bounds of the surface and take the buffer
107 // scale into account.
108 const float kBufferScale = 2.0f;
109 surface->SetBufferScale(kBufferScale);
110 EXPECT_EQ(
111 gfx::ScaleToFlooredSize(buffer_size, 1.0f / kBufferScale).ToString(),
112 surface->GetPreferredSize().ToString());
113 }
114
94 TEST_F(SurfaceTest, Commit) { 115 TEST_F(SurfaceTest, Commit) {
95 scoped_ptr<Surface> surface(new Surface); 116 scoped_ptr<Surface> surface(new Surface);
96 117
97 // Calling commit without a buffer should succeed. 118 // Calling commit without a buffer should succeed.
98 surface->Commit(); 119 surface->Commit();
99 } 120 }
100 121
101 } // namespace 122 } // namespace
102 } // namespace exo 123 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/surface.cc ('k') | components/exo/wayland/server.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698