Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / cc / trees / layer_tree_host_pixeltest_filters.cc
index 3d52efa..5303ed1 100644 (file)
@@ -111,17 +111,17 @@ TEST_F(LayerTreeHostFiltersPixelTest, BackgroundFilterBlurOffAxis) {
   background->AddChild(blur);
 
   background->SetShouldFlattenTransform(false);
-  background->SetIs3dSorted(true);
+  background->Set3dSortingContextId(1);
   green->SetShouldFlattenTransform(false);
-  green->SetIs3dSorted(true);
+  green->Set3dSortingContextId(1);
   gfx::Transform background_transform;
   background_transform.ApplyPerspectiveDepth(200.0);
   background->SetTransform(background_transform);
 
   blur->SetShouldFlattenTransform(false);
-  blur->SetIs3dSorted(true);
+  blur->Set3dSortingContextId(1);
   for (size_t i = 0; i < blur->children().size(); ++i)
-    blur->children()[i]->SetIs3dSorted(true);
+    blur->children()[i]->Set3dSortingContextId(1);
 
   gfx::Transform blur_transform;
   blur_transform.Translate(55.0, 65.0);
@@ -157,6 +157,80 @@ TEST_F(LayerTreeHostFiltersPixelTest, BackgroundFilterBlurOffAxis) {
                    "background_filter_blur_off_axis.png")));
 }
 
+class LayerTreeHostFiltersScaledPixelTest
+    : public LayerTreeHostFiltersPixelTest {
+  virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
+    // Required so that device scale is inherited by content scale.
+    settings->layer_transforms_should_scale_layer_contents = true;
+  }
+
+  virtual void SetupTree() OVERRIDE {
+    layer_tree_host()->SetDeviceScaleFactor(device_scale_factor_);
+    LayerTreePixelTest::SetupTree();
+  }
+
+ protected:
+  void RunPixelTestType(int content_size,
+                        float device_scale_factor,
+                        PixelTestType test_type) {
+    int half_content = content_size / 2;
+
+    scoped_refptr<SolidColorLayer> root = CreateSolidColorLayer(
+        gfx::Rect(0, 0, content_size, content_size), SK_ColorWHITE);
+
+    scoped_refptr<SolidColorLayer> background = CreateSolidColorLayer(
+        gfx::Rect(0, 0, content_size, content_size), SK_ColorGREEN);
+    root->AddChild(background);
+
+    // Add a blue layer that completely covers the green layer.
+    scoped_refptr<SolidColorLayer> foreground = CreateSolidColorLayer(
+        gfx::Rect(0, 0, content_size, content_size), SK_ColorBLUE);
+    background->AddChild(foreground);
+
+    // Add an alpha threshold filter to the blue layer which will filter out
+    // everything except the lower right corner.
+    FilterOperations filters;
+    SkRegion alpha_region;
+    alpha_region.setRect(
+        half_content, half_content, content_size, content_size);
+    filters.Append(
+        FilterOperation::CreateAlphaThresholdFilter(alpha_region, 1.f, 0.f));
+    foreground->SetFilters(filters);
+
+    device_scale_factor_ = device_scale_factor;
+    RunPixelTest(
+        test_type,
+        background,
+        base::FilePath(FILE_PATH_LITERAL("green_small_with_blue_corner.png")));
+  }
+
+  float device_scale_factor_;
+};
+
+TEST_F(LayerTreeHostFiltersScaledPixelTest, StandardDpi_GLBitmap) {
+  RunPixelTestType(100, 1.f, GL_WITH_BITMAP);
+}
+
+TEST_F(LayerTreeHostFiltersScaledPixelTest, StandardDpi_GLDefault) {
+  RunPixelTestType(100, 1.f, GL_WITH_DEFAULT);
+}
+
+TEST_F(LayerTreeHostFiltersScaledPixelTest, StandardDpi_Software) {
+  RunPixelTestType(100, 1.f, SOFTWARE_WITH_BITMAP);
+}
+
+TEST_F(LayerTreeHostFiltersScaledPixelTest, HiDpi_GLBitmap) {
+  RunPixelTestType(50, 2.f, GL_WITH_BITMAP);
+}
+
+TEST_F(LayerTreeHostFiltersScaledPixelTest, HiDpi_GLDefault) {
+  RunPixelTestType(50, 2.f, GL_WITH_DEFAULT);
+}
+
+TEST_F(LayerTreeHostFiltersScaledPixelTest, HiDpi_Software) {
+  RunPixelTestType(50, 2.f, SOFTWARE_WITH_BITMAP);
+}
+
 class ImageFilterClippedPixelTest : public LayerTreeHostFiltersPixelTest {
  protected:
   void RunPixelTestType(PixelTestType test_type) {
@@ -176,7 +250,7 @@ class ImageFilterClippedPixelTest : public LayerTreeHostFiltersPixelTest {
     // This filter does a red-blue swap, so the foreground becomes blue.
     matrix[2] = matrix[6] = matrix[10] = matrix[18] = SK_Scalar1;
     skia::RefPtr<SkColorFilter> colorFilter(
-        skia::AdoptRef(new SkColorMatrixFilter(matrix)));
+        skia::AdoptRef(SkColorMatrixFilter::Create(matrix)));
     // We filter only the bottom 200x100 pixels of the foreground.
     SkImageFilter::CropRect crop_rect(SkRect::MakeXYWH(0, 100, 200, 100));
     skia::RefPtr<SkImageFilter> filter = skia::AdoptRef(