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

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

Issue 22870016: Update the nine patch layer to use UI resources (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 7 years, 3 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/fake_scoped_ui_resource.cc ('k') | cc/trees/layer_tree_host.h » ('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/layers/content_layer.h" 9 #include "cc/layers/content_layer.h"
10 #include "cc/layers/layer.h" 10 #include "cc/layers/layer.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 success &= list->GetInteger(0, &aperture_x); 47 success &= list->GetInteger(0, &aperture_x);
48 success &= list->GetInteger(1, &aperture_y); 48 success &= list->GetInteger(1, &aperture_y);
49 success &= list->GetInteger(2, &aperture_width); 49 success &= list->GetInteger(2, &aperture_width);
50 success &= list->GetInteger(3, &aperture_height); 50 success &= list->GetInteger(3, &aperture_height);
51 51
52 success &= dict->GetList("ImageBounds", &list); 52 success &= dict->GetList("ImageBounds", &list);
53 int image_width, image_height; 53 int image_width, image_height;
54 success &= list->GetInteger(0, &image_width); 54 success &= list->GetInteger(0, &image_width);
55 success &= list->GetInteger(1, &image_height); 55 success &= list->GetInteger(1, &image_height);
56 56
57 success &= dict->GetList("Border", &list);
58 int border_x, border_y, border_width, border_height;
59 success &= list->GetInteger(0, &border_x);
60 success &= list->GetInteger(1, &border_y);
61 success &= list->GetInteger(2, &border_width);
62 success &= list->GetInteger(3, &border_height);
63
64 bool fill_center;
65 success &= dict->GetBoolean("FillCenter", &fill_center);
66
57 scoped_refptr<NinePatchLayer> nine_patch_layer = NinePatchLayer::Create(); 67 scoped_refptr<NinePatchLayer> nine_patch_layer = NinePatchLayer::Create();
58 68
59 SkBitmap bitmap; 69 SkBitmap bitmap;
60 bitmap.setConfig(SkBitmap::kARGB_8888_Config, image_width, image_height); 70 bitmap.setConfig(SkBitmap::kARGB_8888_Config, image_width, image_height);
61 bitmap.allocPixels(NULL, NULL); 71 bitmap.allocPixels(NULL, NULL);
72 bitmap.setImmutable();
62 nine_patch_layer->SetBitmap(bitmap, 73 nine_patch_layer->SetBitmap(bitmap,
63 gfx::Rect(aperture_x, aperture_y, aperture_width, aperture_height)); 74 gfx::Rect(aperture_x, aperture_y, aperture_width, aperture_height));
64 75
76 nine_patch_layer->SetBorder(
77 gfx::Rect(border_x, border_y, border_width, border_height));
78 nine_patch_layer->SetFillCenter(fill_center);
79
65 new_layer = nine_patch_layer; 80 new_layer = nine_patch_layer;
66 } else if (layer_type == "PictureLayer") { 81 } else if (layer_type == "PictureLayer") {
67 new_layer = PictureLayer::Create(content_client); 82 new_layer = PictureLayer::Create(content_client);
68 } else { // Type "Layer" or "unknown" 83 } else { // Type "Layer" or "unknown"
69 new_layer = Layer::Create(); 84 new_layer = Layer::Create();
70 } 85 }
71 new_layer->SetAnchorPoint(gfx::Point()); 86 new_layer->SetAnchorPoint(gfx::Point());
72 new_layer->SetPosition(gfx::PointF(position_x, position_y)); 87 new_layer->SetPosition(gfx::PointF(position_x, position_y));
73 new_layer->SetBounds(gfx::Size(width, height)); 88 new_layer->SetBounds(gfx::Size(width, height));
74 new_layer->SetIsDrawable(draws_content); 89 new_layer->SetIsDrawable(draws_content);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 123
109 } // namespace 124 } // namespace
110 125
111 scoped_refptr<Layer> ParseTreeFromJson(std::string json, 126 scoped_refptr<Layer> ParseTreeFromJson(std::string json,
112 ContentLayerClient* content_client) { 127 ContentLayerClient* content_client) {
113 scoped_ptr<base::Value> val = base::test::ParseJson(json); 128 scoped_ptr<base::Value> val = base::test::ParseJson(json);
114 return ParseTreeFromValue(val.get(), content_client); 129 return ParseTreeFromValue(val.get(), content_client);
115 } 130 }
116 131
117 } // namespace cc 132 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/fake_scoped_ui_resource.cc ('k') | cc/trees/layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698