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

Side by Side Diff: cc/trees/layer_tree_host_pixeltest_on_demand_raster.cc

Issue 12642010: Implement on demand quad rasterization for PicturePiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase. 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/resources/tile_manager.cc ('k') | content/common/cc_messages.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 2013 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/layers/append_quads_data.h"
6 #include "cc/layers/content_layer_client.h"
7 #include "cc/layers/picture_layer.h"
8 #include "cc/layers/picture_layer_impl.h"
9 #include "cc/quads/draw_quad.h"
10 #include "cc/test/layer_tree_pixel_test.h"
11 #include "cc/test/mock_quad_culler.h"
12 #include "cc/trees/layer_tree_impl.h"
13 #include "third_party/skia/include/core/SkCanvas.h"
14 #include "third_party/skia/include/core/SkColor.h"
15 #include "ui/gfx/rect.h"
16 #include "ui/gfx/rect_f.h"
17
18 #if !defined(OS_ANDROID)
19
20 namespace cc {
21 namespace {
22
23 class LayerTreeHostOnDemandRasterPixelTest : public LayerTreePixelTest {
24 public:
25 virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
26 settings->impl_side_painting = true;
27 }
28
29 virtual void BeginCommitOnThread(LayerTreeHostImpl* impl) OVERRIDE {
30 // Not enough memory available. Enforce on-demand rasterization.
31 impl->SetManagedMemoryPolicy(
32 ManagedMemoryPolicy(1, ManagedMemoryPolicy::CUTOFF_ALLOW_EVERYTHING,
33 1, ManagedMemoryPolicy::CUTOFF_ALLOW_NOTHING));
34 }
35
36 virtual void SwapBuffersOnThread(LayerTreeHostImpl* host_impl,
37 bool result) OVERRIDE {
38 // Find the PictureLayerImpl ask it to append quads to check their material.
39 // The PictureLayerImpl is assumed to be the first child of the root layer
40 // in the active tree.
41 PictureLayerImpl* picture_layer = static_cast<PictureLayerImpl*>(
42 host_impl->active_tree()->root_layer()->child_at(0));
43
44 QuadList quads;
45 SharedQuadStateList shared_states;
46 MockQuadCuller quad_culler(&quads, &shared_states);
47
48 AppendQuadsData data;
49 picture_layer->AppendQuads(&quad_culler, &data);
50
51 for (size_t i = 0; i < quads.size(); ++i)
52 EXPECT_EQ(quads[i]->material, DrawQuad::PICTURE_CONTENT);
53
54 // Triggers pixel readback and ends the test.
55 LayerTreePixelTest::SwapBuffersOnThread(host_impl, result);
56 }
57 };
58
59 class BlueYellowLayerClient : public ContentLayerClient {
60 public:
61 BlueYellowLayerClient(gfx::Rect layer_rect) : layer_rect_(layer_rect) { }
62
63 virtual void DidChangeLayerCanUseLCDText() OVERRIDE { }
64
65 virtual void PaintContents(SkCanvas* canvas,
66 gfx::Rect clip,
67 gfx::RectF* opaque) OVERRIDE {
68 *opaque = gfx::RectF(layer_rect_.width(), layer_rect_.height());
69
70 SkPaint paint;
71 paint.setColor(SK_ColorBLUE);
72 canvas->drawRect(SkRect::MakeWH(layer_rect_.width() / 2,
73 layer_rect_.height()),
74 paint);
75
76 paint.setColor(SK_ColorYELLOW);
77 canvas->drawRect(
78 SkRect::MakeXYWH(layer_rect_.width() / 2,
79 0,
80 layer_rect_.width() / 2,
81 layer_rect_.height()),
82 paint);
83 }
84
85 private:
86 gfx::Rect layer_rect_;
87 };
88
89 TEST_F(LayerTreeHostOnDemandRasterPixelTest, RasterPictureLayer) {
90 // Use multiple colors in a single layer to prevent bypassing on-demand
91 // rasterization if a single solid color is detected in picture analysis.
92 gfx::Rect layer_rect(200, 200);
93 BlueYellowLayerClient client(layer_rect);
94 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
95
96 layer->SetIsDrawable(true);
97 layer->SetAnchorPoint(gfx::PointF());
98 layer->SetBounds(layer_rect.size());
99 layer->SetPosition(layer_rect.origin());
100
101 RunPixelTest(layer, base::FilePath(FILE_PATH_LITERAL("blue_yellow.png")));
102 }
103
104 } // namespace
105 } // namespace cc
106
107 #endif // OS_ANDROID
OLDNEW
« no previous file with comments | « cc/resources/tile_manager.cc ('k') | content/common/cc_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698