Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / cc / layers / tiled_layer.cc
index 56df6f7..1f30b45 100644 (file)
@@ -10,6 +10,7 @@
 #include "base/auto_reset.h"
 #include "base/basictypes.h"
 #include "build/build_config.h"
+#include "cc/base/simple_enclosed_region.h"
 #include "cc/layers/layer_impl.h"
 #include "cc/layers/tiled_layer_impl.h"
 #include "cc/resources/layer_updater.h"
@@ -142,40 +143,38 @@ void TiledLayer::UpdateTileSizeAndTilingOption() {
 }
 
 void TiledLayer::UpdateBounds() {
-  gfx::Rect old_tiling_rect = tiler_->tiling_rect();
-  gfx::Rect new_tiling_rect = gfx::Rect(content_bounds());
-  if (old_tiling_rect == new_tiling_rect)
+  gfx::Size old_tiling_size = tiler_->tiling_size();
+  gfx::Size new_tiling_size = content_bounds();
+  if (old_tiling_size == new_tiling_size)
     return;
-  tiler_->SetTilingRect(new_tiling_rect);
+  tiler_->SetTilingSize(new_tiling_size);
 
   // Invalidate any areas that the new bounds exposes.
-  Region old_region = old_tiling_rect;
-  Region new_region = new_tiling_rect;
-  new_tiling_rect.Subtract(old_tiling_rect);
-  for (Region::Iterator new_rects(new_tiling_rect); new_rects.has_rect();
+  Region new_region =
+      SubtractRegions(gfx::Rect(new_tiling_size), gfx::Rect(old_tiling_size));
+  for (Region::Iterator new_rects(new_region); new_rects.has_rect();
        new_rects.next())
     InvalidateContentRect(new_rects.rect());
+  UpdateDrawsContent(HasDrawableContent());
 }
 
 void TiledLayer::SetTileSize(const gfx::Size& size) {
   tiler_->SetTileSize(size);
+  UpdateDrawsContent(HasDrawableContent());
 }
 
 void TiledLayer::SetBorderTexelOption(
     LayerTilingData::BorderTexelOption border_texel_option) {
   tiler_->SetBorderTexelOption(border_texel_option);
+  UpdateDrawsContent(HasDrawableContent());
 }
 
-bool TiledLayer::DrawsContent() const {
-  if (!ContentsScalingLayer::DrawsContent())
-    return false;
-
+bool TiledLayer::HasDrawableContent() const {
   bool has_more_than_one_tile =
-      tiler_->num_tiles_x() > 1 || tiler_->num_tiles_y() > 1;
-  if (tiling_option_ == NEVER_TILE && has_more_than_one_tile)
-    return false;
+      (tiler_->num_tiles_x() > 1) || (tiler_->num_tiles_y() > 1);
 
-  return true;
+  return !(tiling_option_ == NEVER_TILE && has_more_than_one_tile) &&
+         ContentsScalingLayer::HasDrawableContent();
 }
 
 void TiledLayer::ReduceMemoryUsage() {
@@ -222,7 +221,6 @@ void TiledLayer::PushPropertiesTo(LayerImpl* layer) {
         i,
         j,
         tile->managed_resource()->resource_id(),
-        tile->opaque_rect(),
         tile->managed_resource()->contents_swizzled());
   }
   for (std::vector<UpdatableTile*>::const_iterator iter = invalid_tiles.begin();
@@ -370,8 +368,8 @@ void TiledLayer::MarkOcclusionsAndRequestTextures(
       gfx::Rect visible_tile_rect = gfx::IntersectRects(
           tiler_->tile_bounds(i, j), visible_content_rect());
       if (!draw_transform_is_animating() && occlusion &&
-          occlusion->Occluded(
-              render_target(), visible_tile_rect, draw_transform())) {
+          occlusion->GetCurrentOcclusionForLayer(draw_transform())
+              .IsOccluded(visible_tile_rect)) {
         tile->occluded = true;
         occluded_tile_count++;
       } else {
@@ -464,12 +462,8 @@ void TiledLayer::UpdateTileTextures(const gfx::Rect& update_rect,
                                     const OcclusionTracker<Layer>* occlusion) {
   // The update_rect should be in layer space. So we have to convert the
   // paint_rect from content space to layer space.
-  float width_scale =
-      paint_properties().bounds.width() /
-      static_cast<float>(content_bounds().width());
-  float height_scale =
-      paint_properties().bounds.height() /
-      static_cast<float>(content_bounds().height());
+  float width_scale = 1 / draw_properties().contents_scale_x;
+  float height_scale = 1 / draw_properties().contents_scale_y;
   update_rect_ = gfx::ScaleRect(update_rect, width_scale, height_scale);
 
   // Calling PrepareToUpdate() calls into WebKit to paint, which may have the
@@ -478,12 +472,11 @@ void TiledLayer::UpdateTileTextures(const gfx::Rect& update_rect,
   // the SkCanvas until the paint finishes, so we grab a local reference here to
   // hold the updater alive until the paint completes.
   scoped_refptr<LayerUpdater> protector(Updater());
-  gfx::Rect painted_opaque_rect;
-  Updater()->PrepareToUpdate(paint_rect,
+  Updater()->PrepareToUpdate(content_bounds(),
+                             paint_rect,
                              tiler_->tile_size(),
                              1.f / width_scale,
-                             1.f / height_scale,
-                             &painted_opaque_rect);
+                             1.f / height_scale);
 
   for (int j = top; j <= bottom; ++j) {
     for (int i = left; i <= right; ++i) {
@@ -501,27 +494,6 @@ void TiledLayer::UpdateTileTextures(const gfx::Rect& update_rect,
       if (dirty_rect.IsEmpty())
         continue;
 
-      // Save what was painted opaque in the tile. Keep the old area if the
-      // paint didn't touch it, and didn't paint some other part of the tile
-      // opaque.
-      gfx::Rect tile_painted_rect = gfx::IntersectRects(tile_rect, paint_rect);
-      gfx::Rect tile_painted_opaque_rect =
-          gfx::IntersectRects(tile_rect, painted_opaque_rect);
-      if (!tile_painted_rect.IsEmpty()) {
-        gfx::Rect paint_inside_tile_opaque_rect =
-            gfx::IntersectRects(tile->opaque_rect(), tile_painted_rect);
-        bool paint_inside_tile_opaque_rect_is_non_opaque =
-            !paint_inside_tile_opaque_rect.IsEmpty() &&
-            !tile_painted_opaque_rect.Contains(paint_inside_tile_opaque_rect);
-        bool opaque_paint_not_inside_tile_opaque_rect =
-            !tile_painted_opaque_rect.IsEmpty() &&
-            !tile->opaque_rect().Contains(tile_painted_opaque_rect);
-
-        if (paint_inside_tile_opaque_rect_is_non_opaque ||
-            opaque_paint_not_inside_tile_opaque_rect)
-          tile->set_opaque_rect(tile_painted_opaque_rect);
-      }
-
       // source_rect starts as a full-sized tile with border texels included.
       gfx::Rect source_rect = tiler_->TileRect(tile);
       source_rect.Intersect(dirty_rect);
@@ -641,12 +613,10 @@ void TiledLayer::SetTexturePriorities(const PriorityCalculator& priority_calc) {
   }
 }
 
-Region TiledLayer::VisibleContentOpaqueRegion() const {
+SimpleEnclosedRegion TiledLayer::VisibleContentOpaqueRegion() const {
   if (skips_draw_)
-    return Region();
-  if (contents_opaque())
-    return visible_content_rect();
-  return tiler_->OpaqueRegionInContentRect(visible_content_rect());
+    return SimpleEnclosedRegion();
+  return Layer::VisibleContentOpaqueRegion();
 }
 
 void TiledLayer::ResetUpdateState() {