| OLD | NEW |
| 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 Loading... |
| 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 | |
| 67 scoped_refptr<NinePatchLayer> nine_patch_layer = NinePatchLayer::Create(); | 57 scoped_refptr<NinePatchLayer> nine_patch_layer = NinePatchLayer::Create(); |
| 68 | 58 |
| 69 SkBitmap bitmap; | 59 SkBitmap bitmap; |
| 70 bitmap.setConfig(SkBitmap::kARGB_8888_Config, image_width, image_height); | 60 bitmap.setConfig(SkBitmap::kARGB_8888_Config, image_width, image_height); |
| 71 bitmap.allocPixels(NULL, NULL); | 61 bitmap.allocPixels(NULL, NULL); |
| 72 bitmap.setImmutable(); | |
| 73 nine_patch_layer->SetBitmap(bitmap, | 62 nine_patch_layer->SetBitmap(bitmap, |
| 74 gfx::Rect(aperture_x, aperture_y, aperture_width, aperture_height)); | 63 gfx::Rect(aperture_x, aperture_y, aperture_width, aperture_height)); |
| 75 | 64 |
| 76 nine_patch_layer->SetBorder( | |
| 77 gfx::Rect(border_x, border_y, border_width, border_height)); | |
| 78 nine_patch_layer->SetFillCenter(fill_center); | |
| 79 | |
| 80 new_layer = nine_patch_layer; | 65 new_layer = nine_patch_layer; |
| 81 } else if (layer_type == "PictureLayer") { | 66 } else if (layer_type == "PictureLayer") { |
| 82 new_layer = PictureLayer::Create(content_client); | 67 new_layer = PictureLayer::Create(content_client); |
| 83 } else { // Type "Layer" or "unknown" | 68 } else { // Type "Layer" or "unknown" |
| 84 new_layer = Layer::Create(); | 69 new_layer = Layer::Create(); |
| 85 } | 70 } |
| 86 new_layer->SetAnchorPoint(gfx::Point()); | 71 new_layer->SetAnchorPoint(gfx::Point()); |
| 87 new_layer->SetPosition(gfx::PointF(position_x, position_y)); | 72 new_layer->SetPosition(gfx::PointF(position_x, position_y)); |
| 88 new_layer->SetBounds(gfx::Size(width, height)); | 73 new_layer->SetBounds(gfx::Size(width, height)); |
| 89 new_layer->SetIsDrawable(draws_content); | 74 new_layer->SetIsDrawable(draws_content); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 | 108 |
| 124 } // namespace | 109 } // namespace |
| 125 | 110 |
| 126 scoped_refptr<Layer> ParseTreeFromJson(std::string json, | 111 scoped_refptr<Layer> ParseTreeFromJson(std::string json, |
| 127 ContentLayerClient* content_client) { | 112 ContentLayerClient* content_client) { |
| 128 scoped_ptr<base::Value> val = base::test::ParseJson(json); | 113 scoped_ptr<base::Value> val = base::test::ParseJson(json); |
| 129 return ParseTreeFromValue(val.get(), content_client); | 114 return ParseTreeFromValue(val.get(), content_client); |
| 130 } | 115 } |
| 131 | 116 |
| 132 } // namespace cc | 117 } // namespace cc |
| OLD | NEW |