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

Side by Side Diff: cc/test/layer_tree_json_parser.cc

Issue 1783613004: CC Animation: Erase cc::LayerSettings everywhere. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@eraseandroid
Patch Set: Rebase. Created 4 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
« no previous file with comments | « cc/test/layer_tree_host_common_test.cc ('k') | cc/test/layer_tree_pixel_test.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 2013 The Chromium Authors. All rights reserved. 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 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 "cc/test/layer_tree_json_parser.h" 5 #include "cc/test/layer_tree_json_parser.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/test/values_test_util.h" 9 #include "base/test/values_test_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "cc/layers/layer.h" 11 #include "cc/layers/layer.h"
12 #include "cc/layers/layer_settings.h"
13 #include "cc/layers/nine_patch_layer.h" 12 #include "cc/layers/nine_patch_layer.h"
14 #include "cc/layers/picture_layer.h" 13 #include "cc/layers/picture_layer.h"
15 #include "cc/layers/solid_color_layer.h" 14 #include "cc/layers/solid_color_layer.h"
16 #include "cc/layers/texture_layer.h" 15 #include "cc/layers/texture_layer.h"
17 #include "cc/trees/layer_tree_settings.h" 16 #include "cc/trees/layer_tree_settings.h"
18 17
19 namespace cc { 18 namespace cc {
20 19
21 namespace { 20 namespace {
22 21
(...skipping 10 matching lines...) Expand all
33 success &= list->GetInteger(0, &width); 32 success &= list->GetInteger(0, &width);
34 success &= list->GetInteger(1, &height); 33 success &= list->GetInteger(1, &height);
35 success &= dict->GetList("Position", &list); 34 success &= dict->GetList("Position", &list);
36 double position_x, position_y; 35 double position_x, position_y;
37 success &= list->GetDouble(0, &position_x); 36 success &= list->GetDouble(0, &position_x);
38 success &= list->GetDouble(1, &position_y); 37 success &= list->GetDouble(1, &position_y);
39 38
40 bool draws_content; 39 bool draws_content;
41 success &= dict->GetBoolean("DrawsContent", &draws_content); 40 success &= dict->GetBoolean("DrawsContent", &draws_content);
42 41
43 LayerSettings layer_settings;
44
45 scoped_refptr<Layer> new_layer; 42 scoped_refptr<Layer> new_layer;
46 if (layer_type == "SolidColorLayer") { 43 if (layer_type == "SolidColorLayer") {
47 new_layer = SolidColorLayer::Create(layer_settings); 44 new_layer = SolidColorLayer::Create();
48 } else if (layer_type == "NinePatchLayer") { 45 } else if (layer_type == "NinePatchLayer") {
49 success &= dict->GetList("ImageAperture", &list); 46 success &= dict->GetList("ImageAperture", &list);
50 int aperture_x, aperture_y, aperture_width, aperture_height; 47 int aperture_x, aperture_y, aperture_width, aperture_height;
51 success &= list->GetInteger(0, &aperture_x); 48 success &= list->GetInteger(0, &aperture_x);
52 success &= list->GetInteger(1, &aperture_y); 49 success &= list->GetInteger(1, &aperture_y);
53 success &= list->GetInteger(2, &aperture_width); 50 success &= list->GetInteger(2, &aperture_width);
54 success &= list->GetInteger(3, &aperture_height); 51 success &= list->GetInteger(3, &aperture_height);
55 52
56 base::ListValue* bounds; 53 base::ListValue* bounds;
57 success &= dict->GetList("ImageBounds", &bounds); 54 success &= dict->GetList("ImageBounds", &bounds);
58 double image_width, image_height; 55 double image_width, image_height;
59 success &= bounds->GetDouble(0, &image_width); 56 success &= bounds->GetDouble(0, &image_width);
60 success &= bounds->GetDouble(1, &image_height); 57 success &= bounds->GetDouble(1, &image_height);
61 58
62 success &= dict->GetList("Border", &list); 59 success &= dict->GetList("Border", &list);
63 int border_x, border_y, border_width, border_height; 60 int border_x, border_y, border_width, border_height;
64 success &= list->GetInteger(0, &border_x); 61 success &= list->GetInteger(0, &border_x);
65 success &= list->GetInteger(1, &border_y); 62 success &= list->GetInteger(1, &border_y);
66 success &= list->GetInteger(2, &border_width); 63 success &= list->GetInteger(2, &border_width);
67 success &= list->GetInteger(3, &border_height); 64 success &= list->GetInteger(3, &border_height);
68 65
69 bool fill_center; 66 bool fill_center;
70 success &= dict->GetBoolean("FillCenter", &fill_center); 67 success &= dict->GetBoolean("FillCenter", &fill_center);
71 68
72 scoped_refptr<NinePatchLayer> nine_patch_layer = 69 scoped_refptr<NinePatchLayer> nine_patch_layer = NinePatchLayer::Create();
73 NinePatchLayer::Create(layer_settings);
74 70
75 SkBitmap bitmap; 71 SkBitmap bitmap;
76 bitmap.allocN32Pixels(image_width, image_height); 72 bitmap.allocN32Pixels(image_width, image_height);
77 bitmap.setImmutable(); 73 bitmap.setImmutable();
78 nine_patch_layer->SetBitmap(bitmap); 74 nine_patch_layer->SetBitmap(bitmap);
79 nine_patch_layer->SetAperture( 75 nine_patch_layer->SetAperture(
80 gfx::Rect(aperture_x, aperture_y, aperture_width, aperture_height)); 76 gfx::Rect(aperture_x, aperture_y, aperture_width, aperture_height));
81 nine_patch_layer->SetBorder( 77 nine_patch_layer->SetBorder(
82 gfx::Rect(border_x, border_y, border_width, border_height)); 78 gfx::Rect(border_x, border_y, border_width, border_height));
83 nine_patch_layer->SetFillCenter(fill_center); 79 nine_patch_layer->SetFillCenter(fill_center);
84 80
85 new_layer = nine_patch_layer; 81 new_layer = nine_patch_layer;
86 } else if (layer_type == "TextureLayer") { 82 } else if (layer_type == "TextureLayer") {
87 new_layer = TextureLayer::CreateForMailbox(layer_settings, NULL); 83 new_layer = TextureLayer::CreateForMailbox(NULL);
88 } else if (layer_type == "PictureLayer") { 84 } else if (layer_type == "PictureLayer") {
89 new_layer = PictureLayer::Create(layer_settings, content_client); 85 new_layer = PictureLayer::Create(content_client);
90 } else { // Type "Layer" or "unknown" 86 } else { // Type "Layer" or "unknown"
91 new_layer = Layer::Create(layer_settings); 87 new_layer = Layer::Create();
92 } 88 }
93 new_layer->SetPosition(gfx::PointF(position_x, position_y)); 89 new_layer->SetPosition(gfx::PointF(position_x, position_y));
94 new_layer->SetBounds(gfx::Size(width, height)); 90 new_layer->SetBounds(gfx::Size(width, height));
95 new_layer->SetIsDrawable(draws_content); 91 new_layer->SetIsDrawable(draws_content);
96 92
97 double opacity; 93 double opacity;
98 if (dict->GetDouble("Opacity", &opacity)) 94 if (dict->GetDouble("Opacity", &opacity))
99 new_layer->SetOpacity(opacity); 95 new_layer->SetOpacity(opacity);
100 96
101 bool contents_opaque; 97 bool contents_opaque;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 164
169 } // namespace 165 } // namespace
170 166
171 scoped_refptr<Layer> ParseTreeFromJson(std::string json, 167 scoped_refptr<Layer> ParseTreeFromJson(std::string json,
172 ContentLayerClient* content_client) { 168 ContentLayerClient* content_client) {
173 scoped_ptr<base::Value> val = base::test::ParseJson(json); 169 scoped_ptr<base::Value> val = base::test::ParseJson(json);
174 return ParseTreeFromValue(val.get(), content_client); 170 return ParseTreeFromValue(val.get(), content_client);
175 } 171 }
176 172
177 } // namespace cc 173 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_host_common_test.cc ('k') | cc/test/layer_tree_pixel_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698