blob: 8807fc3ad5b404ca05270ea97bae66d157ea9741 [file] [log] [blame]
* Copyright 2014 Google Inc. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* See the License for the specific language governing permissions and
* limitations under the License.
#include "base/memory/scoped_ptr.h"
#include "cobalt/render_tree/resource_provider.h"
#include "cobalt/renderer/backend/graphics_context.h"
#include "cobalt/renderer/backend/render_target.h"
#include "cobalt/renderer/rasterizer/rasterizer.h"
namespace cobalt {
namespace renderer {
namespace rasterizer {
namespace skia {
// This HardwareRasterizer class represents a rasterizer that will setup
// a Skia hardware rendering context. When Submit() is called, the passed in
// render tree will be rasterized using hardware-accelerated Skia. The
// HardwareRasterizer must be constructed on the same thread that Submit()
// is to be called on.
class HardwareRasterizer : public Rasterizer {
// The passed in render target will be used to determine the dimensions of
// the output. The graphics context will be used to issue commands to the GPU
// to blit the final output to the render target.
// The value of |skia_cache_size_in_bytes| dictates the maximum amount of
// memory that Skia will use to cache the results of certain effects that take
// a long time to render, such as shadows. The results will be reused across
// submissions.
// The value of |scratch_surface_cache_size_in_bytes| sets an upper limit on
// the number of bytes that can be consumed by the scratch surface cache,
// a facility that allows temporary surfaces to be reused within the
// rasterization of a single frame/submission.
// If |surface_cache_size| is non-zero, the rasterizer will set itself up with
// a surface cache such that expensive render tree nodes seen multiple times
// will get saved to offscreen surfaces.
explicit HardwareRasterizer(backend::GraphicsContext* graphics_context,
int skia_cache_size_in_bytes,
int scratch_surface_cache_size_in_bytes,
int surface_cache_size_in_bytes);
virtual ~HardwareRasterizer();
// Consume the render tree and output the results to the render target passed
// into the constructor.
void Submit(const scoped_refptr<render_tree::Node>& render_tree,
const scoped_refptr<backend::RenderTarget>& render_target,
int options) OVERRIDE;
render_tree::ResourceProvider* GetResourceProvider() OVERRIDE;
class Impl;
scoped_ptr<Impl> impl_;
} // namespace skia
} // namespace rasterizer
} // namespace renderer
} // namespace cobalt