Skip to content

Commit

Permalink
cc: Implement a display-list-based RecordingSource and RasterSource
Browse files Browse the repository at this point in the history
This defines a RecordingSource that records into a display list. This also
defines a corresponding RasterSource.

Bug=None

Review URL: https://codereview.chromium.org/753263002

Cr-Commit-Position: refs/heads/master@{#305982}
  • Loading branch information
alijuma authored and Commit bot committed Nov 27, 2014
1 parent 222b9c0 commit 5e77f7d
Show file tree
Hide file tree
Showing 52 changed files with 1,940 additions and 58 deletions.
21 changes: 21 additions & 0 deletions cc/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,24 @@ component("cc") {
"resources/bitmap_raster_worker_pool.h",
"resources/bitmap_skpicture_content_layer_updater.cc",
"resources/bitmap_skpicture_content_layer_updater.h",
"resources/clip_display_item.cc",
"resources/clip_display_item.h",
"resources/content_layer_updater.cc",
"resources/content_layer_updater.h",
"resources/display_item.cc",
"resources/display_item.h",
"resources/display_item_list.cc",
"resources/display_item_list.h",
"resources/display_list_raster_source.cc",
"resources/display_list_raster_source.h",
"resources/display_list_recording_source.cc",
"resources/display_list_recording_source.h",
"resources/drawing_display_item.cc",
"resources/drawing_display_item.h",
"resources/eviction_tile_priority_queue.cc",
"resources/eviction_tile_priority_queue.h",
"resources/filter_display_item.cc",
"resources/filter_display_item.h",
"resources/gpu_raster_worker_pool.cc",
"resources/gpu_raster_worker_pool.h",
"resources/image_layer_updater.cc",
Expand Down Expand Up @@ -373,6 +387,8 @@ component("cc") {
"resources/raster_buffer.cc",
"resources/raster_buffer.h",
"resources/raster_source.h",
"resources/raster_source_helper.cc",
"resources/raster_source_helper.h",
"resources/raster_tile_priority_queue.cc",
"resources/raster_tile_priority_queue.h",
"resources/raster_worker_pool.cc",
Expand Down Expand Up @@ -428,6 +444,10 @@ component("cc") {
"resources/tiling_set_eviction_queue.h",
"resources/transferable_resource.cc",
"resources/transferable_resource.h",
"resources/transform_display_item.cc",
"resources/transform_display_item.h",
"resources/transparency_display_item.cc",
"resources/transparency_display_item.h",
"resources/ui_resource_bitmap.cc",
"resources/ui_resource_bitmap.h",
"resources/ui_resource_client.h",
Expand Down Expand Up @@ -738,6 +758,7 @@ test("cc_unittests") {
"quads/draw_quad_unittest.cc",
"quads/list_container_unittest.cc",
"quads/render_pass_unittest.cc",
"resources/display_item_list_unittest.cc",
"resources/layer_quad_unittest.cc",
"resources/picture_layer_tiling_set_unittest.cc",
"resources/picture_layer_tiling_unittest.cc",
Expand Down
2 changes: 2 additions & 0 deletions cc/blink/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ component("blink") {
"web_compositor_support_impl.h",
"web_content_layer_impl.cc",
"web_content_layer_impl.h",
"web_display_item_list_impl.cc",
"web_display_item_list_impl.h",
"web_external_bitmap_impl.cc",
"web_external_bitmap_impl.h",
"web_external_texture_layer_impl.cc",
Expand Down
2 changes: 2 additions & 0 deletions cc/blink/cc_blink.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
'web_compositor_support_impl.h',
'web_content_layer_impl.cc',
'web_content_layer_impl.h',
'web_display_item_list_impl.cc',
'web_display_item_list_impl.h',
'web_external_bitmap_impl.cc',
'web_external_bitmap_impl.h',
'web_external_texture_layer_impl.cc',
Expand Down
10 changes: 10 additions & 0 deletions cc/blink/web_compositor_support_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "cc/animation/transform_operations.h"
#include "cc/blink/web_animation_impl.h"
#include "cc/blink/web_content_layer_impl.h"
#include "cc/blink/web_display_item_list_impl.h"
#include "cc/blink/web_external_texture_layer_impl.h"
#include "cc/blink/web_filter_animation_curve_impl.h"
#include "cc/blink/web_filter_operations_impl.h"
Expand All @@ -27,6 +28,9 @@ using blink::WebCompositorAnimation;
using blink::WebCompositorAnimationCurve;
using blink::WebContentLayer;
using blink::WebContentLayerClient;
#if WEB_DISPLAY_ITEM_LIST_IS_DEFINED
using blink::WebDisplayItemList;
#endif
using blink::WebExternalTextureLayer;
using blink::WebExternalTextureLayerClient;
using blink::WebFilterAnimationCurve;
Expand Down Expand Up @@ -91,6 +95,12 @@ WebScrollbarLayer* WebCompositorSupportImpl::createSolidColorScrollbarLayer(
is_left_side_vertical_scrollbar);
}

#if WEB_DISPLAY_ITEM_LIST_IS_DEFINED
WebDisplayItemList* WebCompositorSupportImpl::createDisplayItemList() {
return new WebDisplayItemListImpl();
}
#endif

WebCompositorAnimation* WebCompositorSupportImpl::createAnimation(
const blink::WebCompositorAnimationCurve& curve,
blink::WebCompositorAnimation::TargetProperty target,
Expand Down
4 changes: 4 additions & 0 deletions cc/blink/web_compositor_support_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "cc/blink/cc_blink_export.h"
#include "third_party/WebKit/public/platform/WebCompositorAnimationCurve.h"
#include "third_party/WebKit/public/platform/WebCompositorSupport.h"
#include "third_party/WebKit/public/platform/WebContentLayerClient.h"
#include "third_party/WebKit/public/platform/WebLayer.h"
#include "third_party/WebKit/public/platform/WebTransformOperations.h"

Expand Down Expand Up @@ -41,6 +42,9 @@ class CC_BLINK_EXPORT WebCompositorSupportImpl
int thumb_thickness,
int track_start,
bool is_left_side_vertical_scrollbar);
#if WEB_DISPLAY_ITEM_LIST_IS_DEFINED
virtual blink::WebDisplayItemList* createDisplayItemList();
#endif
virtual blink::WebCompositorAnimation* createAnimation(
const blink::WebCompositorAnimationCurve& curve,
blink::WebCompositorAnimation::TargetProperty target,
Expand Down
19 changes: 19 additions & 0 deletions cc/blink/web_content_layer_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "cc/blink/web_content_layer_impl.h"

#include "cc/blink/web_display_item_list_impl.h"
#include "cc/layers/content_layer.h"
#include "cc/layers/picture_layer.h"
#include "third_party/WebKit/public/platform/WebContentLayerClient.h"
Expand Down Expand Up @@ -63,6 +64,24 @@ void WebContentLayerImpl::PaintContents(
: blink::WebContentLayerClient::GraphicsContextDisabled);
}

scoped_refptr<cc::DisplayItemList>
WebContentLayerImpl::PaintContentsToDisplayList(
const gfx::Rect& clip,
ContentLayerClient::GraphicsContextStatus graphics_context_status) {
if (!client_)
return cc::DisplayItemList::Create();

WebDisplayItemListImpl list;
#if WEB_DISPLAY_ITEM_LIST_IS_DEFINED
client_->paintContents(
&list, clip, can_use_lcd_text_,
graphics_context_status == ContentLayerClient::GRAPHICS_CONTEXT_ENABLED
? blink::WebContentLayerClient::GraphicsContextEnabled
: blink::WebContentLayerClient::GraphicsContextDisabled);
#endif
return list.ToDisplayItemList();
}

bool WebContentLayerImpl::FillsBoundsCompletely() const {
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions cc/blink/web_content_layer_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class WebContentLayerImpl : public blink::WebContentLayer,
const gfx::Rect& clip,
ContentLayerClient::GraphicsContextStatus
graphics_context_status) override;
scoped_refptr<cc::DisplayItemList> PaintContentsToDisplayList(
const gfx::Rect& clip,
GraphicsContextStatus graphics_context_status) override;
bool FillsBoundsCompletely() const override;

scoped_ptr<WebLayerImpl> layer_;
Expand Down
90 changes: 90 additions & 0 deletions cc/blink/web_display_item_list_impl.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "cc/blink/web_display_item_list_impl.h"

#include <vector>

#include "cc/blink/web_blend_mode.h"
#include "cc/resources/clip_display_item.h"
#include "cc/resources/drawing_display_item.h"
#include "cc/resources/filter_display_item.h"
#include "cc/resources/transform_display_item.h"
#include "cc/resources/transparency_display_item.h"
#include "skia/ext/refptr.h"
#include "third_party/WebKit/public/platform/WebFloatRect.h"
#include "third_party/WebKit/public/platform/WebRect.h"
#include "third_party/skia/include/core/SkImageFilter.h"
#include "third_party/skia/include/core/SkPicture.h"
#include "third_party/skia/include/utils/SkMatrix44.h"
#include "ui/gfx/transform.h"

namespace cc_blink {

WebDisplayItemListImpl::WebDisplayItemListImpl()
: display_item_list_(cc::DisplayItemList::Create()) {
}

scoped_refptr<cc::DisplayItemList> WebDisplayItemListImpl::ToDisplayItemList() {
return display_item_list_;
}

void WebDisplayItemListImpl::appendDrawingItem(
SkPicture* picture,
const blink::WebFloatPoint& location) {
display_item_list_->AppendItem(
cc::DrawingDisplayItem::Create(skia::SharePtr(picture), location));
}

void WebDisplayItemListImpl::appendClipItem(
const blink::WebRect& clip_rect,
const blink::WebVector<SkRRect>& rounded_clip_rects) {
std::vector<SkRRect> rounded_rects;
for (size_t i = 0; i < rounded_clip_rects.size(); ++i) {
rounded_rects.push_back(rounded_clip_rects[i]);
}
display_item_list_->AppendItem(
cc::ClipDisplayItem::Create(clip_rect, rounded_rects));
}

void WebDisplayItemListImpl::appendEndClipItem() {
display_item_list_->AppendItem(cc::EndClipDisplayItem::Create());
}

void WebDisplayItemListImpl::appendTransformItem(const SkMatrix44& matrix) {
gfx::Transform transform;
transform.matrix() = matrix;
display_item_list_->AppendItem(cc::TransformDisplayItem::Create(transform));
}

void WebDisplayItemListImpl::appendTransparencyItem(
float opacity,
blink::WebBlendMode blend_mode) {
display_item_list_->AppendItem(cc::TransparencyDisplayItem::Create(
opacity, BlendModeToSkia(blend_mode)));
}

void WebDisplayItemListImpl::appendEndTransformItem() {
display_item_list_->AppendItem(cc::EndTransformDisplayItem::Create());
}

void WebDisplayItemListImpl::appendEndTransparencyItem() {
display_item_list_->AppendItem(cc::EndTransparencyDisplayItem::Create());
}

void WebDisplayItemListImpl::appendFilterItem(
SkImageFilter* filter,
const blink::WebFloatRect& bounds) {
display_item_list_->AppendItem(
cc::FilterDisplayItem::Create(skia::SharePtr(filter), bounds));
}

void WebDisplayItemListImpl::appendEndFilterItem() {
display_item_list_->AppendItem(cc::EndFilterDisplayItem::Create());
}

WebDisplayItemListImpl::~WebDisplayItemListImpl() {
}

} // namespace cc_blink
63 changes: 63 additions & 0 deletions cc/blink/web_display_item_list_impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CC_BLINK_WEB_DISPLAY_ITEM_LIST_IMPL_H_
#define CC_BLINK_WEB_DISPLAY_ITEM_LIST_IMPL_H_

#include "base/memory/ref_counted.h"
#include "cc/blink/cc_blink_export.h"
#include "cc/resources/display_item_list.h"
#include "third_party/WebKit/public/platform/WebBlendMode.h"
#include "third_party/WebKit/public/platform/WebContentLayerClient.h"
#include "third_party/WebKit/public/platform/WebFloatPoint.h"
#include "third_party/WebKit/public/platform/WebVector.h"

#if WEB_DISPLAY_ITEM_LIST_IS_DEFINED
#include "third_party/WebKit/public/platform/WebDisplayItemList.h"
#endif

class SkImageFilter;
class SkMatrix44;
class SkPicture;
class SkRRect;

namespace cc_blink {

#if WEB_DISPLAY_ITEM_LIST_IS_DEFINED
class WebDisplayItemListImpl : public blink::WebDisplayItemList {
#else
class WebDisplayItemListImpl {
#endif

public:
CC_BLINK_EXPORT WebDisplayItemListImpl();
virtual ~WebDisplayItemListImpl();

scoped_refptr<cc::DisplayItemList> ToDisplayItemList();

// blink::WebDisplayItemList implementation.
virtual void appendDrawingItem(SkPicture* picture,
const blink::WebFloatPoint& location);
virtual void appendClipItem(
const blink::WebRect& clip_rect,
const blink::WebVector<SkRRect>& rounded_clip_rects);
virtual void appendEndClipItem();
virtual void appendTransformItem(const SkMatrix44& matrix);
virtual void appendEndTransformItem();
virtual void appendTransparencyItem(float opacity,
blink::WebBlendMode blend_mode);
virtual void appendEndTransparencyItem();
virtual void appendFilterItem(SkImageFilter* filter,
const blink::WebFloatRect& bounds);
virtual void appendEndFilterItem();

private:
scoped_refptr<cc::DisplayItemList> display_item_list_;

DISALLOW_COPY_AND_ASSIGN(WebDisplayItemListImpl);
};

} // namespace cc_blink

#endif // CC_BLINK_WEB_DISPLAY_ITEM_LIST_IMPL_H_
20 changes: 20 additions & 0 deletions cc/cc.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -358,10 +358,24 @@
'resources/bitmap_raster_worker_pool.h',
'resources/bitmap_skpicture_content_layer_updater.cc',
'resources/bitmap_skpicture_content_layer_updater.h',
'resources/clip_display_item.cc',
'resources/clip_display_item.h',
'resources/content_layer_updater.cc',
'resources/content_layer_updater.h',
'resources/display_item.cc',
'resources/display_item.h',
'resources/display_item_list.cc',
'resources/display_item_list.h',
'resources/display_list_raster_source.cc',
'resources/display_list_raster_source.h',
'resources/display_list_recording_source.cc',
'resources/display_list_recording_source.h',
'resources/drawing_display_item.cc',
'resources/drawing_display_item.h',
'resources/eviction_tile_priority_queue.cc',
'resources/eviction_tile_priority_queue.h',
'resources/filter_display_item.cc',
'resources/filter_display_item.h',
'resources/gpu_raster_worker_pool.cc',
'resources/gpu_raster_worker_pool.h',
'resources/image_layer_updater.cc',
Expand Down Expand Up @@ -401,6 +415,8 @@
'resources/raster_buffer.cc',
'resources/raster_buffer.h',
'resources/raster_source.h',
'resources/raster_source_helper.cc',
'resources/raster_source_helper.h',
'resources/raster_tile_priority_queue.cc',
'resources/raster_tile_priority_queue.h',
'resources/raster_worker_pool.cc',
Expand Down Expand Up @@ -457,6 +473,10 @@
'resources/tiling_set_eviction_queue.h',
'resources/transferable_resource.cc',
'resources/transferable_resource.h',
'resources/transform_display_item.cc',
'resources/transform_display_item.h',
'resources/transparency_display_item.cc',
'resources/transparency_display_item.h',
'resources/ui_resource_bitmap.cc',
'resources/ui_resource_bitmap.h',
'resources/ui_resource_client.h',
Expand Down
1 change: 1 addition & 0 deletions cc/cc_tests.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
'quads/draw_quad_unittest.cc',
'quads/list_container_unittest.cc',
'quads/render_pass_unittest.cc',
'resources/display_item_list_unittest.cc',
'resources/layer_quad_unittest.cc',
'resources/picture_layer_tiling_set_unittest.cc',
'resources/picture_layer_tiling_unittest.cc',
Expand Down
5 changes: 5 additions & 0 deletions cc/layers/content_layer_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define CC_LAYERS_CONTENT_LAYER_CLIENT_H_

#include "cc/base/cc_export.h"
#include "cc/resources/display_item_list.h"

class SkCanvas;

Expand All @@ -27,6 +28,10 @@ class CC_EXPORT ContentLayerClient {
const gfx::Rect& clip,
GraphicsContextStatus gc_status) = 0;

virtual scoped_refptr<DisplayItemList> PaintContentsToDisplayList(
const gfx::Rect& clip,
GraphicsContextStatus gc_status) = 0;

// If true the layer may skip clearing the background before rasterizing,
// because it will cover any uncleared data with content.
virtual bool FillsBoundsCompletely() const = 0;
Expand Down
Loading

0 comments on commit 5e77f7d

Please sign in to comment.