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

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

Issue 12774006: cc: Chromify Layer and LayerImpl classes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: MoreAndroidCompilings 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/test/fake_scrollbar_layer.cc ('k') | cc/test/layer_tree_test_common.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 "base/test/values_test_util.h" 7 #include "base/test/values_test_util.h"
8 #include "base/values.h" 8 #include "base/values.h"
9 #include "cc/content_layer.h" 9 #include "cc/content_layer.h"
10 #include "cc/layer.h" 10 #include "cc/layer.h"
(...skipping 21 matching lines...) Expand all
32 success &= list->GetDouble(0, &position_x); 32 success &= list->GetDouble(0, &position_x);
33 success &= list->GetDouble(1, &position_y); 33 success &= list->GetDouble(1, &position_y);
34 34
35 bool draws_content; 35 bool draws_content;
36 success &= dict->GetBoolean("DrawsContent", &draws_content); 36 success &= dict->GetBoolean("DrawsContent", &draws_content);
37 37
38 scoped_refptr<Layer> new_layer; 38 scoped_refptr<Layer> new_layer;
39 if (layer_type == "SolidColorLayer") { 39 if (layer_type == "SolidColorLayer") {
40 new_layer = SolidColorLayer::Create(); 40 new_layer = SolidColorLayer::Create();
41 } else if (layer_type == "ContentLayer") { 41 } else if (layer_type == "ContentLayer") {
42 new_layer = ContentLayer::create(content_client); 42 new_layer = ContentLayer::Create(content_client);
43 } else if (layer_type == "NinePatchLayer") { 43 } else if (layer_type == "NinePatchLayer") {
44 success &= dict->GetList("ImageAperture", &list); 44 success &= dict->GetList("ImageAperture", &list);
45 int aperture_x, aperture_y, aperture_width, aperture_height; 45 int aperture_x, aperture_y, aperture_width, aperture_height;
46 success &= list->GetInteger(0, &aperture_x); 46 success &= list->GetInteger(0, &aperture_x);
47 success &= list->GetInteger(1, &aperture_y); 47 success &= list->GetInteger(1, &aperture_y);
48 success &= list->GetInteger(2, &aperture_width); 48 success &= list->GetInteger(2, &aperture_width);
49 success &= list->GetInteger(3, &aperture_height); 49 success &= list->GetInteger(3, &aperture_height);
50 50
51 success &= dict->GetList("ImageBounds", &list); 51 success &= dict->GetList("ImageBounds", &list);
52 int image_width, image_height; 52 int image_width, image_height;
53 success &= list->GetInteger(0, &image_width); 53 success &= list->GetInteger(0, &image_width);
54 success &= list->GetInteger(1, &image_height); 54 success &= list->GetInteger(1, &image_height);
55 55
56 scoped_refptr<NinePatchLayer> nine_patch_layer = NinePatchLayer::Create(); 56 scoped_refptr<NinePatchLayer> nine_patch_layer = NinePatchLayer::Create();
57 57
58 SkBitmap bitmap; 58 SkBitmap bitmap;
59 bitmap.setConfig(SkBitmap::kARGB_8888_Config, image_width, image_height); 59 bitmap.setConfig(SkBitmap::kARGB_8888_Config, image_width, image_height);
60 bitmap.allocPixels(NULL, NULL); 60 bitmap.allocPixels(NULL, NULL);
61 nine_patch_layer->SetBitmap(bitmap, 61 nine_patch_layer->SetBitmap(bitmap,
62 gfx::Rect(aperture_x, aperture_y, aperture_width, aperture_height)); 62 gfx::Rect(aperture_x, aperture_y, aperture_width, aperture_height));
63 63
64 new_layer = nine_patch_layer; 64 new_layer = nine_patch_layer;
65 } else { // Type "Layer" or "unknown" 65 } else { // Type "Layer" or "unknown"
66 new_layer = Layer::create(); 66 new_layer = Layer::Create();
67 } 67 }
68 new_layer->setAnchorPoint(gfx::Point()); 68 new_layer->SetAnchorPoint(gfx::Point());
69 new_layer->setPosition(gfx::PointF(position_x, position_y)); 69 new_layer->SetPosition(gfx::PointF(position_x, position_y));
70 new_layer->setBounds(gfx::Size(width, height)); 70 new_layer->SetBounds(gfx::Size(width, height));
71 new_layer->setIsDrawable(draws_content); 71 new_layer->SetIsDrawable(draws_content);
72 72
73 double opacity; 73 double opacity;
74 if (dict->GetDouble("Opacity", &opacity)) 74 if (dict->GetDouble("Opacity", &opacity))
75 new_layer->setOpacity(opacity); 75 new_layer->SetOpacity(opacity);
76 76
77 success &= dict->GetList("DrawTransform", &list); 77 success &= dict->GetList("DrawTransform", &list);
78 double transform[16]; 78 double transform[16];
79 for (int i = 0; i < 16; ++i) 79 for (int i = 0; i < 16; ++i)
80 success &= list->GetDouble(i, &transform[i]); 80 success &= list->GetDouble(i, &transform[i]);
81 81
82 gfx::Transform gfxTransform; 82 gfx::Transform gfxTransform;
83 gfxTransform.matrix().setColMajord(transform); 83 gfxTransform.matrix().setColMajord(transform);
84 new_layer->setTransform(gfxTransform); 84 new_layer->SetTransform(gfxTransform);
85 85
86 success &= dict->GetList("Children", &list); 86 success &= dict->GetList("Children", &list);
87 for (ListValue::const_iterator it = list->begin(); 87 for (ListValue::const_iterator it = list->begin();
88 it != list->end(); ++it) { 88 it != list->end(); ++it) {
89 new_layer->addChild(ParseTreeFromValue(*it, content_client)); 89 new_layer->AddChild(ParseTreeFromValue(*it, content_client));
90 } 90 }
91 91
92 if (!success) 92 if (!success)
93 return NULL; 93 return NULL;
94 94
95 return new_layer; 95 return new_layer;
96 } 96 }
97 97
98 } // namespace 98 } // namespace
99 99
100 scoped_refptr<Layer> ParseTreeFromJson(std::string json, 100 scoped_refptr<Layer> ParseTreeFromJson(std::string json,
101 ContentLayerClient* content_client) { 101 ContentLayerClient* content_client) {
102 scoped_ptr<base::Value> val = base::test::ParseJson(json); 102 scoped_ptr<base::Value> val = base::test::ParseJson(json);
103 return ParseTreeFromValue(val.get(), content_client); 103 return ParseTreeFromValue(val.get(), content_client);
104 } 104 }
105 105
106 } // namespace cc 106 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_scrollbar_layer.cc ('k') | cc/test/layer_tree_test_common.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698