#include "components/viz/service/display/software_renderer.h"
#include <memory>
#include <utility>
#include <vector>
#include "base/memory/raw_ptr.h"
#include "base/not_fatal_until.h"
#include "base/process/memory.h"
#include "base/trace_event/trace_event.h"
#include "build/build_config.h"
#include "cc/base/math_util.h"
#include "cc/paint/image_provider.h"
#include "cc/paint/render_surface_filters.h"
#include "components/viz/common/display/renderer_settings.h"
#include "components/viz/common/features.h"
#include "components/viz/common/frame_sinks/copy_output_request.h"
#include "components/viz/common/frame_sinks/copy_output_util.h"
#include "components/viz/common/quads/aggregated_render_pass_draw_quad.h"
#include "components/viz/common/quads/compositor_render_pass_draw_quad.h"
#include "components/viz/common/quads/debug_border_draw_quad.h"
#include "components/viz/common/quads/picture_draw_quad.h"
#include "components/viz/common/quads/solid_color_draw_quad.h"
#include "components/viz/common/quads/texture_draw_quad.h"
#include "components/viz/common/quads/tile_draw_quad.h"
#include "components/viz/common/skia_helper.h"
#include "components/viz/common/viz_utils.h"
#include "components/viz/service/debugger/viz_debugger.h"
#include "components/viz/service/display/output_surface.h"
#include "components/viz/service/display/output_surface_frame.h"
#include "components/viz/service/display/renderer_utils.h"
#include "components/viz/service/display/software_output_device.h"
#include "skia/ext/image_operations.h"
#include "skia/ext/legacy_display_globals.h"
#include "skia/ext/opacity_filter_canvas.h"
#include "third_party/skia/include/core/SkCanvas.h"
#include "third_party/skia/include/core/SkColor.h"
#include "third_party/skia/include/core/SkImage.h"
#include "third_party/skia/include/core/SkImageFilter.h"
#include "third_party/skia/include/core/SkMaskFilter.h"
#include "third_party/skia/include/core/SkMatrix.h"
#include "third_party/skia/include/core/SkPath.h"
#include "third_party/skia/include/core/SkPoint.h"
#include "third_party/skia/include/core/SkShader.h"
#include "third_party/skia/include/core/SkSwizzle.h"
#include "third_party/skia/include/effects/SkShaderMaskFilter.h"
#include "ui/gfx/geometry/axis_transform2d.h"
#include "ui/gfx/geometry/rect_conversions.h"
#include "ui/gfx/geometry/skia_conversions.h"
#include "ui/gfx/geometry/transform.h"
namespace viz {
namespace {
class AnimatedImagesProvider : public cc::ImageProvider { … };
}
SoftwareRenderer::SoftwareRenderer(
const RendererSettings* settings,
const DebugRendererSettings* debug_settings,
OutputSurface* output_surface,
DisplayResourceProviderSoftware* resource_provider,
OverlayProcessorInterface* overlay_processor)
: … { … }
SoftwareRenderer::~SoftwareRenderer() { … }
bool SoftwareRenderer::CanPartialSwap() { … }
void SoftwareRenderer::BeginDrawingFrame() { … }
void SoftwareRenderer::FinishDrawingFrame() { … }
void SoftwareRenderer::SwapBuffers(SwapFrameData swap_frame_data) { … }
void SoftwareRenderer::EnsureScissorTestDisabled() { … }
void SoftwareRenderer::SetScissorTestRect(const gfx::Rect& scissor_rect) { … }
void SoftwareRenderer::SetClipRect(const gfx::Rect& rect) { … }
void SoftwareRenderer::SetClipRRect(const gfx::RRectF& rrect) { … }
void SoftwareRenderer::ClearCanvas(SkColor color) { … }
void SoftwareRenderer::ClearFramebuffer() { … }
void SoftwareRenderer::BeginDrawingRenderPass(
const AggregatedRenderPass* render_pass,
bool needs_clear,
const gfx::Rect& render_pass_update_rect,
const gfx::Size& viewport_size) { … }
bool SoftwareRenderer::IsSoftwareResource(ResourceId resource_id) { … }
void SoftwareRenderer::DoDrawQuad(const DrawQuad* quad,
const gfx::QuadF* draw_region) { … }
void SoftwareRenderer::DrawDebugBorderQuad(const DebugBorderDrawQuad* quad) { … }
void SoftwareRenderer::DrawPictureQuad(const PictureDrawQuad* quad) { … }
void SoftwareRenderer::DrawSolidColorQuad(const SolidColorDrawQuad* quad) { … }
void SoftwareRenderer::DrawTextureQuad(const TextureDrawQuad* quad) { … }
DBG_FLAG_FBOOL("software.toggle.capture", software_toggle_capture)
void SoftwareRenderer::DrawTileQuad(const TileDrawQuad* quad) { … }
void SoftwareRenderer::DrawRenderPassQuad(
const AggregatedRenderPassDrawQuad* quad) { … }
void SoftwareRenderer::DrawUnsupportedQuad(const DrawQuad* quad) { … }
void SoftwareRenderer::CopyDrawnRenderPass(
const copy_output::RenderPassGeometry& geometry,
std::unique_ptr<CopyOutputRequest> request) { … }
void SoftwareRenderer::DidChangeVisibility() { … }
bool SoftwareRenderer::ShouldApplyBackdropFilters(
const cc::FilterOperations* backdrop_filters,
const AggregatedRenderPassDrawQuad* quad) const { … }
sk_sp<SkImage> SoftwareRenderer::ApplyImageFilter(
SkImageFilter* filter,
const AggregatedRenderPassDrawQuad* quad,
const SkBitmap& to_filter,
bool offset_expanded_bounds,
SkIRect* result_rect) const { … }
SkBitmap SoftwareRenderer::GetBackdropBitmap(
const gfx::Rect& bounding_rect) const { … }
gfx::Rect SoftwareRenderer::GetBackdropBoundingBoxForRenderPassQuad(
const AggregatedRenderPassDrawQuad* quad,
const cc::FilterOperations* backdrop_filters,
std::optional<gfx::RRectF> backdrop_filter_bounds_input,
gfx::Transform contents_device_transform,
gfx::Transform* backdrop_filter_bounds_transform,
std::optional<gfx::RRectF>* backdrop_filter_bounds,
gfx::Rect* unclipped_rect) const { … }
sk_sp<SkShader> SoftwareRenderer::GetBackdropFilterShader(
const AggregatedRenderPassDrawQuad* quad,
SkTileMode content_tile_mode) const { … }
void SoftwareRenderer::UpdateRenderPassTextures(
const AggregatedRenderPassList& render_passes_in_draw_order,
const base::flat_map<AggregatedRenderPassId, RenderPassRequirements>&
render_passes_in_frame) { … }
void SoftwareRenderer::AllocateRenderPassResourceIfNeeded(
const AggregatedRenderPassId& render_pass_id,
const RenderPassRequirements& requirements) { … }
bool SoftwareRenderer::IsRenderPassResourceAllocated(
const AggregatedRenderPassId& render_pass_id) const { … }
gfx::Size SoftwareRenderer::GetRenderPassBackingPixelSize(
const AggregatedRenderPassId& render_pass_id) { … }
void SoftwareRenderer::SetRenderPassBackingDrawnRect(
const AggregatedRenderPassId& render_pass_id,
const gfx::Rect& drawn_rect) { … }
gfx::Rect SoftwareRenderer::GetRenderPassBackingDrawnRect(
const AggregatedRenderPassId& render_pass_id) const { … }
}