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

Side by Side Diff: cc/content_layer_unittest.cc

Issue 12603013: Part 10 of cc/ directory shuffles: layers (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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/content_layer_client.h ('k') | cc/contents_scaling_layer.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 "cc/content_layer.h"
6
7 #include "cc/content_layer_client.h"
8 #include "cc/resources/bitmap_content_layer_updater.h"
9 #include "cc/test/geometry_test_utils.h"
10 #include "skia/ext/platform_canvas.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "ui/gfx/rect_conversions.h"
13
14 using namespace WebKit;
15
16 namespace cc {
17 namespace {
18
19 class MockContentLayerClient : public ContentLayerClient {
20 public:
21 explicit MockContentLayerClient(gfx::Rect opaque_layer_rect)
22 : opaque_layer_rect_(opaque_layer_rect) {}
23
24 virtual void PaintContents(SkCanvas* canvas,
25 gfx::Rect clip,
26 gfx::RectF* opaque) OVERRIDE {
27 *opaque = gfx::RectF(opaque_layer_rect_);
28 }
29
30 private:
31 gfx::Rect opaque_layer_rect_;
32 };
33
34 TEST(ContentLayerTest, ContentLayerPainterWithDeviceScale) {
35 float contents_scale = 2.f;
36 gfx::Rect content_rect(10, 10, 100, 100);
37 gfx::Rect opaque_rect_in_layer_space(5, 5, 20, 20);
38 gfx::RectF opaque_rect_in_content_space = gfx::ScaleRect(
39 opaque_rect_in_layer_space, contents_scale, contents_scale);
40 MockContentLayerClient client(opaque_rect_in_layer_space);
41 scoped_refptr<BitmapContentLayerUpdater> updater =
42 BitmapContentLayerUpdater::Create(ContentLayerPainter::Create(&client).
43 PassAs<LayerPainter>());
44
45 gfx::Rect resulting_opaque_rect;
46 updater->PrepareToUpdate(content_rect,
47 gfx::Size(256, 256),
48 contents_scale,
49 contents_scale,
50 &resulting_opaque_rect,
51 NULL);
52
53 EXPECT_RECT_EQ(gfx::ToEnclosingRect(opaque_rect_in_content_space),
54 resulting_opaque_rect);
55 }
56
57 } // namespace
58 } // namespace cc
OLDNEW
« no previous file with comments | « cc/content_layer_client.h ('k') | cc/contents_scaling_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698