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

Unified Diff: cc/output/gl_renderer_unittest.cc

Issue 2646243002: Use IDCompositionSurface to implement DirectCompositionSurfaceWin. (Closed)
Patch Set: rebase Created 3 years, 10 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
« no previous file with comments | « cc/output/direct_renderer.cc ('k') | cc/output/output_surface.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/output/gl_renderer_unittest.cc
diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc
index d7bf09e3c8da46a998c61a8d75bb5730f662f905..59d711d165e0996bb2a371fa58297465e087286b 100644
--- a/cc/output/gl_renderer_unittest.cc
+++ b/cc/output/gl_renderer_unittest.cc
@@ -1532,6 +1532,7 @@ class MockOutputSurface : public OutputSurface {
bool has_alpha,
bool use_stencil));
MOCK_METHOD0(BindFramebuffer, void());
+ MOCK_METHOD1(SetDrawRectangle, void(const gfx::Rect&));
MOCK_METHOD0(GetFramebufferCopyTextureFormat, GLenum());
MOCK_METHOD1(SwapBuffers_, void(OutputSurfaceFrame& frame)); // NOLINT
void SwapBuffers(OutputSurfaceFrame frame) override { SwapBuffers_(frame); }
@@ -1899,19 +1900,27 @@ TEST_F(GLRendererTest, OverlaySyncTokensAreProcessed) {
class PartialSwapMockGLES2Interface : public TestGLES2Interface {
public:
+ explicit PartialSwapMockGLES2Interface(bool support_set_draw_rectangle)
+ : support_set_draw_rectangle_(support_set_draw_rectangle) {}
+
void InitializeTestContext(TestWebGraphicsContext3D* context) override {
context->set_have_post_sub_buffer(true);
+ context->set_support_set_draw_rectangle(support_set_draw_rectangle_);
}
MOCK_METHOD1(Enable, void(GLenum cap));
MOCK_METHOD1(Disable, void(GLenum cap));
MOCK_METHOD4(Scissor, void(GLint x, GLint y, GLsizei width, GLsizei height));
+
+ private:
+ bool support_set_draw_rectangle_;
};
class GLRendererPartialSwapTest : public GLRendererTest {
protected:
- void RunTest(bool partial_swap) {
- auto gl_owned = base::MakeUnique<PartialSwapMockGLES2Interface>();
+ void RunTest(bool partial_swap, bool set_draw_rectangle) {
+ auto gl_owned =
+ base::MakeUnique<PartialSwapMockGLES2Interface>(set_draw_rectangle);
auto* gl = gl_owned.get();
auto provider = TestContextProvider::Create(std::move(gl_owned));
@@ -1955,12 +1964,19 @@ class GLRendererPartialSwapTest : public GLRendererTest {
// Partial frame, we should use a scissor to swap only that part when
// partial swap is enabled.
root_pass->damage_rect = gfx::Rect(2, 2, 3, 3);
+ gfx::Rect output_rectangle =
+ partial_swap ? root_pass->damage_rect : gfx::Rect(viewport_size);
- if (partial_swap) {
+ if (partial_swap || set_draw_rectangle) {
EXPECT_CALL(*gl, Enable(GL_SCISSOR_TEST)).InSequence(seq);
// The scissor is flipped, so subtract the y coord and height from the
// bottom of the GL viewport.
- EXPECT_CALL(*gl, Scissor(2, viewport_size.height() - 3 - 2, 3, 3))
+ EXPECT_CALL(
+ *gl,
+ Scissor(output_rectangle.x(),
+ viewport_size.height() - output_rectangle.y() -
+ output_rectangle.height(),
+ output_rectangle.width(), output_rectangle.height()))
.InSequence(seq);
}
@@ -1973,16 +1989,27 @@ class GLRendererPartialSwapTest : public GLRendererTest {
renderer.DecideRenderPassAllocationsForFrame(
render_passes_in_draw_order_);
DrawFrame(&renderer, viewport_size);
+ if (set_draw_rectangle) {
+ EXPECT_EQ(output_rectangle, output_surface->last_set_draw_rectangle());
+ }
}
}
};
TEST_F(GLRendererPartialSwapTest, PartialSwap) {
- RunTest(true);
+ RunTest(true, false);
}
TEST_F(GLRendererPartialSwapTest, NoPartialSwap) {
- RunTest(false);
+ RunTest(false, false);
+}
+
+TEST_F(GLRendererPartialSwapTest, SetDrawRectangle_PartialSwap) {
+ RunTest(true, true);
+}
+
+TEST_F(GLRendererPartialSwapTest, SetDrawRectangle_NoPartialSwap) {
+ RunTest(false, true);
}
class GLRendererWithMockContextTest : public ::testing::Test {
« no previous file with comments | « cc/output/direct_renderer.cc ('k') | cc/output/output_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698