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

Side by Side Diff: cc/CCDecorationLayerImplTest.cpp

Issue 10963056: [cc] Add window decoration layers (NinePatch) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hacky rebase for Jerome to use Created 8 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « cc/CCDecorationLayerImpl.cpp ('k') | cc/DecorationLayerChromium.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2012 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 "config.h"
6
7 #include "CCDecorationLayerImpl.h"
8
9 #include "CCAppendQuadsData.h"
10 #include "CCLayerTestCommon.h"
11 #include "CCSingleThreadProxy.h"
12 #include "CCTextureDrawQuad.h"
13 #include "MockCCQuadCuller.h"
14 #include "public/WebTransformationMatrix.h"
15 #include "testing/gmock/include/gmock/gmock.h"
16 #include "testing/gtest/include/gtest/gtest.h"
17
18 using namespace cc;
19 using namespace CCLayerTestCommon;
20
21 namespace {
22
23 TEST(CCDecorationLayerImplTest, verifyDrawQuads)
24 {
25 DebugScopedSetImplThread scopedImplThread;
26
27 // Input is a 100x100 bitmap with a 20x20 aperture at x=20, y=20.
28 // The bounds of the layer are set to 400x400, so the draw quads
29 // generated should leave the border width (20) intact.
30 MockCCQuadCuller quadCuller;
31 IntSize bitmapSize = IntSize(100, 100);
32 IntSize layerSize = IntSize(400, 400);
33 IntRect visibleContentRect = IntRect(IntPoint(), layerSize);
34 IntRect apertureRect = IntRect(20, 20, 20, 20);
35 IntRect scaledApertureNonUniform = IntRect(20, 20, 320, 320);
36
37 OwnPtr<CCDecorationLayerImpl> layer = CCDecorationLayerImpl::create(1);
38 layer->setVisibleContentRect(visibleContentRect);
39 layer->setBounds(layerSize);
40 layer->setContentBounds(layerSize);
41 layer->createRenderSurface();
42 layer->setRenderTarget(layer.get());
43 layer->setDecorationLayout(bitmapSize, apertureRect);
44 layer->setResourceId(1);
45
46 // This scale should not affect the generated quad geometry, but only
47 // the shared draw transform.
48 WebKit::WebTransformationMatrix transform;
49 transform.scale(10);
50 layer->setDrawTransform(transform);
51
52 CCAppendQuadsData data;
53 layer->appendQuads(quadCuller, data);
54
55 // Verify quad rects
56 const CCQuadList& quads = quadCuller.quadList();
57 EXPECT_EQ(quads.size(), 8);
58 Region remaining(visibleContentRect);
59 for (size_t i = 0; i < quads.size(); ++i) {
60 CCDrawQuad* quad = quads[i];
61 IntRect quadRect = quad->quadRect();
62
63 EXPECT_TRUE(visibleContentRect.contains(quadRect)) << quadString << i;
64 EXPECT_TRUE(remaining.contains(quadRect)) << quadString << i;
65 EXPECT_EQ(quad->sharedQuadState()->quadTransform, transform) << quadStri ng << i;
66 remaining.subtract(cc::Region(quadRect));
67 }
68 EXPECT_EQ(remaining.rects().size(), 1);
69 EXPECT_EQ(remaining.rects()[0], scaledApertureNonUniform);
70
71 // Verify UV rects
72 IntRect bitmapRect(IntPoint(), bitmapSize);
73 Region texRemaining(bitmapRect);
74 for (size_t i = 0; i < quads.size(); ++i) {
75 CCDrawQuad* quad = quads[i];
76 ASSERT_EQ(quad->material(), CCDrawQuad::TextureContent);
77 CCTextureDrawQuad* texQuad = static_cast<CCTextureDrawQuad*>(quad);
78 WebCore::FloatRect texRect = texQuad->uvRect();
79 texRect.scale(bitmapSize.width(), bitmapSize.height());
80 WebCore::IntRect rect(texRect);
81 texRemaining.subtract(cc::Region(rect));
82 }
83 EXPECT_EQ(texRemaining.rects().size(), 1);
84 EXPECT_EQ(texRemaining.rects()[0], apertureRect);
85 }
86
87 } // namespace
OLDNEW
« no previous file with comments | « cc/CCDecorationLayerImpl.cpp ('k') | cc/DecorationLayerChromium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698