Commit 66a41202 authored by danakj's avatar danakj Committed by Commit Bot

viz: Simplify ScopedRenderPassTexture interactions.

Pass in the ContextProvider instead of each capability individually. And in the
DirectRenderer classes, the FrameBuffer hint is always used so stop making it
conditional (this is a leftover from ResourceProvider code this was based on)
and just pass mipmap as a bool so that new bitflags can't be added without
child classes knowing about it. Last, pass RenderPassRequirements consistently
to both methods that receive them, instead of unpacking it for one of them, so
that the relationship is more clear in the APIs.

R=piman@chromium.org

Bug: 738190
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel
Change-Id: Ie53c2041183207561efae7d10c0c32e42daf1bd2
Reviewed-on: https://chromium-review.googlesource.com/843162
Commit-Queue: danakj <danakj@chromium.org>
Reviewed-by: default avatarAntoine Labour <piman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#526059}
parent 27545887
...@@ -194,7 +194,7 @@ void DirectRenderer::DecideRenderPassAllocationsForFrame( ...@@ -194,7 +194,7 @@ void DirectRenderer::DecideRenderPassAllocationsForFrame(
} }
} }
render_passes_in_frame[pass->id] = {RenderPassTextureSize(pass.get()), render_passes_in_frame[pass->id] = {RenderPassTextureSize(pass.get()),
RenderPassTextureHint(pass.get())}; pass->generate_mipmap};
} }
UpdateRenderPassTextures(render_passes_in_draw_order, render_passes_in_frame); UpdateRenderPassTextures(render_passes_in_draw_order, render_passes_in_frame);
} }
...@@ -625,8 +625,8 @@ void DirectRenderer::UseRenderPass(const RenderPass* render_pass) { ...@@ -625,8 +625,8 @@ void DirectRenderer::UseRenderPass(const RenderPass* render_pass) {
enlarged_size.Enlarge(enlarge_pass_texture_amount_.width(), enlarged_size.Enlarge(enlarge_pass_texture_amount_.width(),
enlarge_pass_texture_amount_.height()); enlarge_pass_texture_amount_.height());
AllocateRenderPassResourceIfNeeded(render_pass->id, enlarged_size, AllocateRenderPassResourceIfNeeded(
RenderPassTextureHint(render_pass)); render_pass->id, {enlarged_size, render_pass->generate_mipmap});
// TODO(crbug.com/582554): This change applies only when Vulkan is enabled and // TODO(crbug.com/582554): This change applies only when Vulkan is enabled and
// it will be removed once SkiaRenderer has complete support for Vulkan. // it will be removed once SkiaRenderer has complete support for Vulkan.
...@@ -662,17 +662,6 @@ gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) { ...@@ -662,17 +662,6 @@ gfx::Size DirectRenderer::RenderPassTextureSize(const RenderPass* render_pass) {
return render_pass->output_rect.size(); return render_pass->output_rect.size();
} }
// static
ResourceTextureHint DirectRenderer::RenderPassTextureHint(
const RenderPass* render_pass) {
// TODO(danakj): Pass these as 2 bools instead so subclasses don't have to
// worry about new hints being silently added to the field here.
ResourceTextureHint hint = ResourceTextureHint::kFramebuffer;
if (render_pass->generate_mipmap)
hint |= ResourceTextureHint::kMipmap;
return hint;
}
void DirectRenderer::SetCurrentFrameForTesting(const DrawingFrame& frame) { void DirectRenderer::SetCurrentFrameForTesting(const DrawingFrame& frame) {
current_frame_valid_ = true; current_frame_valid_ = true;
current_frame_ = frame; current_frame_ = frame;
......
...@@ -107,7 +107,7 @@ class VIZ_SERVICE_EXPORT DirectRenderer { ...@@ -107,7 +107,7 @@ class VIZ_SERVICE_EXPORT DirectRenderer {
struct RenderPassRequirements { struct RenderPassRequirements {
gfx::Size size; gfx::Size size;
ResourceTextureHint hint; bool mipmap = false;
}; };
static gfx::RectF QuadVertexRect(); static gfx::RectF QuadVertexRect();
...@@ -132,8 +132,6 @@ class VIZ_SERVICE_EXPORT DirectRenderer { ...@@ -132,8 +132,6 @@ class VIZ_SERVICE_EXPORT DirectRenderer {
void SetScissorTestRectInDrawSpace(const gfx::Rect& draw_space_rect); void SetScissorTestRectInDrawSpace(const gfx::Rect& draw_space_rect);
static gfx::Size RenderPassTextureSize(const RenderPass* render_pass); static gfx::Size RenderPassTextureSize(const RenderPass* render_pass);
static ResourceTextureHint RenderPassTextureHint(
const RenderPass* render_pass);
void FlushPolygons( void FlushPolygons(
base::circular_deque<std::unique_ptr<DrawPolygon>>* poly_list, base::circular_deque<std::unique_ptr<DrawPolygon>>* poly_list,
...@@ -165,8 +163,7 @@ class VIZ_SERVICE_EXPORT DirectRenderer { ...@@ -165,8 +163,7 @@ class VIZ_SERVICE_EXPORT DirectRenderer {
render_passes_in_frame) = 0; render_passes_in_frame) = 0;
virtual void AllocateRenderPassResourceIfNeeded( virtual void AllocateRenderPassResourceIfNeeded(
const RenderPassId& render_pass_id, const RenderPassId& render_pass_id,
const gfx::Size& enlarged_size, const RenderPassRequirements& requirements) = 0;
ResourceTextureHint texturehint) = 0;
virtual bool IsRenderPassResourceAllocated( virtual bool IsRenderPassResourceAllocated(
const RenderPassId& render_pass_id) const = 0; const RenderPassId& render_pass_id) const = 0;
virtual gfx::Size GetRenderPassTextureSize( virtual gfx::Size GetRenderPassTextureSize(
......
...@@ -3609,13 +3609,13 @@ void GLRenderer::UpdateRenderPassTextures( ...@@ -3609,13 +3609,13 @@ void GLRenderer::UpdateRenderPassTextures(
passes_to_delete.push_back(pair.first); passes_to_delete.push_back(pair.first);
continue; continue;
} }
gfx::Size required_size = render_pass_it->second.size; const RenderPassRequirements& requirements = render_pass_it->second;
ResourceTextureHint required_hint = render_pass_it->second.hint;
const ScopedRenderPassTexture& texture = pair.second; const ScopedRenderPassTexture& texture = pair.second;
bool size_appropriate = texture.size().width() >= required_size.width() && bool size_appropriate =
texture.size().height() >= required_size.height(); texture.size().width() >= requirements.size.width() &&
bool hint_appropriate = (texture.hint() & required_hint) == required_hint; texture.size().height() >= requirements.size.height();
if (!size_appropriate || !hint_appropriate) bool mipmap_appropriate = !requirements.mipmap || texture.mipmap();
if (!size_appropriate || !mipmap_appropriate)
passes_to_delete.push_back(pair.first); passes_to_delete.push_back(pair.first);
} }
// Delete RenderPass textures from the previous frame that will not be used // Delete RenderPass textures from the previous frame that will not be used
...@@ -3639,18 +3639,15 @@ ResourceFormat GLRenderer::BackbufferFormat() const { ...@@ -3639,18 +3639,15 @@ ResourceFormat GLRenderer::BackbufferFormat() const {
void GLRenderer::AllocateRenderPassResourceIfNeeded( void GLRenderer::AllocateRenderPassResourceIfNeeded(
const RenderPassId& render_pass_id, const RenderPassId& render_pass_id,
const gfx::Size& enlarged_size, const RenderPassRequirements& requirements) {
ResourceTextureHint texturehint) {
const auto& caps = output_surface_->context_provider()->ContextCapabilities();
auto contents_texture_it = render_pass_textures_.find(render_pass_id); auto contents_texture_it = render_pass_textures_.find(render_pass_id);
if (contents_texture_it != render_pass_textures_.end()) if (contents_texture_it != render_pass_textures_.end())
return; return;
ScopedRenderPassTexture contents_texture( ScopedRenderPassTexture contents_texture(
output_surface_->context_provider()->ContextGL(), enlarged_size, output_surface_->context_provider(), requirements.size,
texturehint, BackbufferFormat(), BackbufferFormat(), current_frame()->current_render_pass->color_space,
current_frame()->current_render_pass->color_space, caps.texture_usage, requirements.mipmap);
caps.texture_storage, caps.texture_npot);
render_pass_textures_[render_pass_id] = std::move(contents_texture); render_pass_textures_[render_pass_id] = std::move(contents_texture);
} }
......
...@@ -102,8 +102,7 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer { ...@@ -102,8 +102,7 @@ class VIZ_SERVICE_EXPORT GLRenderer : public DirectRenderer {
render_passes_in_frame) override; render_passes_in_frame) override;
void AllocateRenderPassResourceIfNeeded( void AllocateRenderPassResourceIfNeeded(
const RenderPassId& render_pass_id, const RenderPassId& render_pass_id,
const gfx::Size& enlarged_size, const RenderPassRequirements& requirements) override;
ResourceTextureHint texturehint) override;
bool IsRenderPassResourceAllocated( bool IsRenderPassResourceAllocated(
const RenderPassId& render_pass_id) const override; const RenderPassId& render_pass_id) const override;
gfx::Size GetRenderPassTextureSize( gfx::Size GetRenderPassTextureSize(
......
...@@ -6,56 +6,65 @@ ...@@ -6,56 +6,65 @@
#include "base/bits.h" #include "base/bits.h"
#include "base/logging.h" #include "base/logging.h"
#include "components/viz/common/gpu/context_provider.h"
#include "components/viz/common/resources/resource_format_utils.h" #include "components/viz/common/resources/resource_format_utils.h"
#include "gpu/GLES2/gl2extchromium.h" #include "gpu/GLES2/gl2extchromium.h"
#include "gpu/command_buffer/client/gles2_interface.h"
namespace viz { namespace viz {
ScopedRenderPassTexture::ScopedRenderPassTexture() = default;
ScopedRenderPassTexture::ScopedRenderPassTexture( ScopedRenderPassTexture::ScopedRenderPassTexture(
gpu::gles2::GLES2Interface* gl, ContextProvider* context_provider,
const gfx::Size& size, const gfx::Size& size,
ResourceTextureHint hint,
ResourceFormat format, ResourceFormat format,
const gfx::ColorSpace& color_space, const gfx::ColorSpace& color_space,
bool use_texture_usage_hint, bool mipmap)
bool use_texture_storage, : context_provider_(context_provider),
bool use_texture_npot) size_(size),
: gl_(gl), size_(size), hint_(hint), color_space_(color_space) { mipmap_(mipmap),
DCHECK(gl_); color_space_(color_space) {
gl_->GenTextures(1, &gl_id_); DCHECK(context_provider_);
gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
// Create and set texture properties. const gpu::Capabilities& caps = context_provider_->ContextCapabilities();
gl_->BindTexture(GL_TEXTURE_2D, gl_id_); gl->GenTextures(1, &gl_id_);
gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl->BindTexture(GL_TEXTURE_2D, gl_id_);
gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
if (use_texture_usage_hint && (hint_ & ResourceTextureHint::kFramebuffer)) { gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl_->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
// This texture will be bound as a framebuffer, so optimize for that.
if (caps.texture_usage) {
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE,
GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
} }
if (use_texture_storage) { if (caps.texture_storage) {
GLint levels = 1; GLint levels = 1;
if (use_texture_npot && (hint_ & ResourceTextureHint::kMipmap)) if (caps.texture_npot && mipmap_)
levels += base::bits::Log2Floor(std::max(size_.width(), size_.height())); levels += base::bits::Log2Floor(std::max(size_.width(), size_.height()));
gl_->TexStorage2DEXT(GL_TEXTURE_2D, levels, TextureStorageFormat(format), gl->TexStorage2DEXT(GL_TEXTURE_2D, levels, TextureStorageFormat(format),
size_.width(), size_.height()); size_.width(), size_.height());
} else { } else {
gl_->TexImage2D(GL_TEXTURE_2D, 0, GLInternalFormat(format), size_.width(), gl->TexImage2D(GL_TEXTURE_2D, 0, GLInternalFormat(format), size_.width(),
size_.height(), 0, GLDataFormat(format), GLDataType(format), size_.height(), 0, GLDataFormat(format), GLDataType(format),
nullptr); nullptr);
} }
} }
ScopedRenderPassTexture::ScopedRenderPassTexture() = default; ScopedRenderPassTexture::~ScopedRenderPassTexture() {
Free();
}
ScopedRenderPassTexture::ScopedRenderPassTexture( ScopedRenderPassTexture::ScopedRenderPassTexture(
ScopedRenderPassTexture&& other) { ScopedRenderPassTexture&& other) {
gl_ = other.gl_; context_provider_ = other.context_provider_;
size_ = other.size_; size_ = other.size_;
hint_ = other.hint_; mipmap_ = other.mipmap_;
color_space_ = other.color_space_; color_space_ = other.color_space_;
gl_id_ = other.gl_id_; gl_id_ = other.gl_id_;
...@@ -63,17 +72,13 @@ ScopedRenderPassTexture::ScopedRenderPassTexture( ...@@ -63,17 +72,13 @@ ScopedRenderPassTexture::ScopedRenderPassTexture(
other.gl_id_ = 0; other.gl_id_ = 0;
} }
ScopedRenderPassTexture::~ScopedRenderPassTexture() {
Free();
}
ScopedRenderPassTexture& ScopedRenderPassTexture::operator=( ScopedRenderPassTexture& ScopedRenderPassTexture::operator=(
ScopedRenderPassTexture&& other) { ScopedRenderPassTexture&& other) {
if (this != &other) { if (this != &other) {
Free(); Free();
gl_ = other.gl_; context_provider_ = other.context_provider_;
size_ = other.size_; size_ = other.size_;
hint_ = other.hint_; mipmap_ = other.mipmap_;
color_space_ = other.color_space_; color_space_ = other.color_space_;
gl_id_ = other.gl_id_; gl_id_ = other.gl_id_;
...@@ -86,7 +91,8 @@ ScopedRenderPassTexture& ScopedRenderPassTexture::operator=( ...@@ -86,7 +91,8 @@ ScopedRenderPassTexture& ScopedRenderPassTexture::operator=(
void ScopedRenderPassTexture::Free() { void ScopedRenderPassTexture::Free() {
if (!gl_id_) if (!gl_id_)
return; return;
gl_->DeleteTextures(1, &gl_id_); gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
gl->DeleteTextures(1, &gl_id_);
gl_id_ = 0; gl_id_ = 0;
} }
......
...@@ -9,48 +9,45 @@ ...@@ -9,48 +9,45 @@
#include "components/viz/common/resources/resource_format.h" #include "components/viz/common/resources/resource_format.h"
#include "components/viz/common/resources/resource_texture_hint.h" #include "components/viz/common/resources/resource_texture_hint.h"
#include "components/viz/service/viz_service_export.h" #include "components/viz/service/viz_service_export.h"
#include "gpu/command_buffer/client/gles2_interface.h"
#include "third_party/khronos/GLES2/gl2.h" #include "third_party/khronos/GLES2/gl2.h"
#include "ui/gfx/color_space.h" #include "ui/gfx/color_space.h"
#include "ui/gfx/geometry/size.h" #include "ui/gfx/geometry/size.h"
namespace viz { namespace viz {
class ContextProvider;
// ScopedRenderPassTexture is resource used inside the same GL context and will // ScopedRenderPassTexture is resource used inside the same GL context and will
// not being sent into another process. So no need to create fence and mailbox // not being sent into another process. So no need to create fence and mailbox
// for these resources. // for these resources.
class VIZ_SERVICE_EXPORT ScopedRenderPassTexture { class VIZ_SERVICE_EXPORT ScopedRenderPassTexture {
public: public:
explicit ScopedRenderPassTexture(gpu::gles2::GLES2Interface* gl,
const gfx::Size& size,
ResourceTextureHint hint,
ResourceFormat format,
const gfx::ColorSpace& color_space,
bool use_texture_usage_hint,
bool use_texture_storage,
bool use_texture_npot);
ScopedRenderPassTexture(); ScopedRenderPassTexture();
ScopedRenderPassTexture(ContextProvider* context_provider,
const gfx::Size& size,
ResourceFormat format,
const gfx::ColorSpace& color_space,
bool mipmap);
~ScopedRenderPassTexture();
ScopedRenderPassTexture(ScopedRenderPassTexture&& other); ScopedRenderPassTexture(ScopedRenderPassTexture&& other);
ScopedRenderPassTexture& operator=(ScopedRenderPassTexture&& other); ScopedRenderPassTexture& operator=(ScopedRenderPassTexture&& other);
~ScopedRenderPassTexture();
GLuint id() const { return gl_id_; } GLuint id() const { return gl_id_; }
const gfx::Size& size() const { return size_; } const gfx::Size& size() const { return size_; }
ResourceTextureHint hint() const { return hint_; } bool mipmap() const { return mipmap_; }
const gfx::ColorSpace& color_space() const { return color_space_; } const gfx::ColorSpace& color_space() const { return color_space_; }
private: private:
void Free(); void Free();
gpu::gles2::GLES2Interface* gl_; ContextProvider* context_provider_ = nullptr;
// The GL texture id. // The GL texture id.
GLuint gl_id_ = 0; GLuint gl_id_ = 0;
// Size of the resource in pixels. // Size of the resource in pixels.
gfx::Size size_; gfx::Size size_;
// A hint for texture-backed resources about how the resource will be used, // When true, and immutable textures are used, this specifies to
// that dictates how it should be allocated/used. // generate mipmaps at powers of 2.
ResourceTextureHint hint_; bool mipmap_ = false;
// TODO(xing.xu): Remove this and set the color space when we draw the // TODO(xing.xu): Remove this and set the color space when we draw the
// RenderPassDrawQuad. // RenderPassDrawQuad.
gfx::ColorSpace color_space_; gfx::ColorSpace color_space_;
......
...@@ -767,15 +767,12 @@ void SkiaRenderer::UpdateRenderPassTextures( ...@@ -767,15 +767,12 @@ void SkiaRenderer::UpdateRenderPassTextures(
continue; continue;
} }
gfx::Size required_size = render_pass_it->second.size; const RenderPassRequirements& requirements = render_pass_it->second;
ResourceTextureHint required_hint = render_pass_it->second.hint;
const RenderPassBacking& backing = pair.second; const RenderPassBacking& backing = pair.second;
bool size_appropriate = backing.size.width() >= required_size.width() && bool size_appropriate = backing.size.width() >= requirements.size.width() &&
backing.size.height() >= required_size.height(); backing.size.height() >= requirements.size.height();
bool hint_appropriate = bool mipmap_appropriate = !requirements.mipmap || backing.mipmap;
(backing.usage_hint & required_hint) == required_hint; if (!size_appropriate || !mipmap_appropriate)
if (!size_appropriate || !hint_appropriate)
passes_to_delete.push_back(pair.first); passes_to_delete.push_back(pair.first);
} }
...@@ -794,8 +791,7 @@ void SkiaRenderer::UpdateRenderPassTextures( ...@@ -794,8 +791,7 @@ void SkiaRenderer::UpdateRenderPassTextures(
void SkiaRenderer::AllocateRenderPassResourceIfNeeded( void SkiaRenderer::AllocateRenderPassResourceIfNeeded(
const RenderPassId& render_pass_id, const RenderPassId& render_pass_id,
const gfx::Size& enlarged_size, const RenderPassRequirements& requirements) {
ResourceTextureHint texture_hint) {
#if BUILDFLAG(ENABLE_VULKAN) #if BUILDFLAG(ENABLE_VULKAN)
NOTIMPLEMENTED(); NOTIMPLEMENTED();
return; return;
...@@ -816,11 +812,11 @@ void SkiaRenderer::AllocateRenderPassResourceIfNeeded( ...@@ -816,11 +812,11 @@ void SkiaRenderer::AllocateRenderPassResourceIfNeeded(
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// This texture will be bound as a framebuffer, so optimize for that.
if (caps.texture_usage) { if (caps.texture_usage) {
if (texture_hint & ResourceTextureHint::kFramebuffer) { gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE,
gl->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_USAGE_ANGLE, GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
GL_FRAMEBUFFER_ATTACHMENT_ANGLE);
}
} }
ResourceFormat backbuffer_format; ResourceFormat backbuffer_format;
...@@ -843,26 +839,24 @@ void SkiaRenderer::AllocateRenderPassResourceIfNeeded( ...@@ -843,26 +839,24 @@ void SkiaRenderer::AllocateRenderPassResourceIfNeeded(
// If |texture_npot| is availble, and mipmaps are desired, we generate a // If |texture_npot| is availble, and mipmaps are desired, we generate a
// mipmap for each power of 2 size. This is only done when using // mipmap for each power of 2 size. This is only done when using
// TexStorage2DEXT. // TexStorage2DEXT.
if (caps.texture_npot) { if (caps.texture_npot && requirements.mipmap) {
if (texture_hint & ResourceTextureHint::kMipmap) { levels += base::bits::Log2Floor(
levels += base::bits::Log2Floor( std::max(requirements.size.width(), requirements.size.height()));
std::max(enlarged_size.width(), enlarged_size.height()));
}
} }
gl->TexStorage2DEXT(GL_TEXTURE_2D, levels, gl->TexStorage2DEXT(GL_TEXTURE_2D, levels,
TextureStorageFormat(backbuffer_format), TextureStorageFormat(backbuffer_format),
enlarged_size.width(), enlarged_size.height()); requirements.size.width(), requirements.size.height());
} else { } else {
gl->TexImage2D(GL_TEXTURE_2D, 0, GLInternalFormat(backbuffer_format), gl->TexImage2D(GL_TEXTURE_2D, 0, GLInternalFormat(backbuffer_format),
enlarged_size.width(), enlarged_size.height(), 0, requirements.size.width(), requirements.size.height(), 0,
GLDataFormat(backbuffer_format), GLDataFormat(backbuffer_format),
GLDataType(backbuffer_format), nullptr); GLDataType(backbuffer_format), nullptr);
} }
RenderPassBacking& backing = render_pass_backings_[render_pass_id]; RenderPassBacking& backing = render_pass_backings_[render_pass_id];
backing.gl_id = texture_id; backing.gl_id = texture_id;
backing.size = enlarged_size; backing.size = requirements.size;
backing.usage_hint = texture_hint; backing.mipmap = requirements.mipmap;
backing.format = backbuffer_format; backing.format = backbuffer_format;
backing.color_space = current_frame()->current_render_pass->color_space; backing.color_space = current_frame()->current_render_pass->color_space;
gl->BindTexture(GL_TEXTURE_2D, 0); gl->BindTexture(GL_TEXTURE_2D, 0);
......
...@@ -48,8 +48,7 @@ class VIZ_SERVICE_EXPORT SkiaRenderer : public DirectRenderer { ...@@ -48,8 +48,7 @@ class VIZ_SERVICE_EXPORT SkiaRenderer : public DirectRenderer {
render_passes_in_frame) override; render_passes_in_frame) override;
void AllocateRenderPassResourceIfNeeded( void AllocateRenderPassResourceIfNeeded(
const RenderPassId& render_pass_id, const RenderPassId& render_pass_id,
const gfx::Size& enlarged_size, const RenderPassRequirements& requirements) override;
ResourceTextureHint texture_hint) override;
bool IsRenderPassResourceAllocated( bool IsRenderPassResourceAllocated(
const RenderPassId& render_pass_id) const override; const RenderPassId& render_pass_id) const override;
gfx::Size GetRenderPassTextureSize( gfx::Size GetRenderPassTextureSize(
...@@ -104,7 +103,7 @@ class VIZ_SERVICE_EXPORT SkiaRenderer : public DirectRenderer { ...@@ -104,7 +103,7 @@ class VIZ_SERVICE_EXPORT SkiaRenderer : public DirectRenderer {
struct RenderPassBacking { struct RenderPassBacking {
uint32_t gl_id; uint32_t gl_id;
gfx::Size size; gfx::Size size;
ResourceTextureHint usage_hint; bool mipmap;
ResourceFormat format; ResourceFormat format;
gfx::ColorSpace color_space; gfx::ColorSpace color_space;
}; };
......
...@@ -813,21 +813,22 @@ void SoftwareRenderer::UpdateRenderPassTextures( ...@@ -813,21 +813,22 @@ void SoftwareRenderer::UpdateRenderPassTextures(
void SoftwareRenderer::AllocateRenderPassResourceIfNeeded( void SoftwareRenderer::AllocateRenderPassResourceIfNeeded(
const RenderPassId& render_pass_id, const RenderPassId& render_pass_id,
const gfx::Size& enlarged_size, const RenderPassRequirements& requirements) {
ResourceTextureHint texture_hint) {
auto it = render_pass_bitmaps_.find(render_pass_id); auto it = render_pass_bitmaps_.find(render_pass_id);
if (it != render_pass_bitmaps_.end()) if (it != render_pass_bitmaps_.end())
return; return;
// The |texture_hint| is only used for gpu-based rendering, so not used here. // The |requirements.mipmap| is only used for gpu-based rendering, so not used
// here.
// //
// ColorSpace correctness for software compositing is a performance nightmare, // ColorSpace correctness for software compositing is a performance nightmare,
// so we don't do it. If we did, then the color space of the current frame's // so we don't do it. If we did, then the color space of the current frame's
// |current_render_pass| should be stored somewhere, but we should not set it // |current_render_pass| should be stored somewhere, but we should not set it
// on the bitmap itself. Instead, we'd use it with a SkColorSpaceXformCanvas // on the bitmap itself. Instead, we'd use it with a SkColorSpaceXformCanvas
// that wraps the SkCanvas drawing into the bitmap. // that wraps the SkCanvas drawing into the bitmap.
SkImageInfo info = SkImageInfo::MakeN32( SkImageInfo info =
enlarged_size.width(), enlarged_size.height(), kPremul_SkAlphaType); SkImageInfo::MakeN32(requirements.size.width(),
requirements.size.height(), kPremul_SkAlphaType);
SkBitmap bitmap; SkBitmap bitmap;
bitmap.allocPixels(info); bitmap.allocPixels(info);
render_pass_bitmaps_.emplace(render_pass_id, std::move(bitmap)); render_pass_bitmaps_.emplace(render_pass_id, std::move(bitmap));
......
...@@ -46,8 +46,7 @@ class VIZ_SERVICE_EXPORT SoftwareRenderer : public DirectRenderer { ...@@ -46,8 +46,7 @@ class VIZ_SERVICE_EXPORT SoftwareRenderer : public DirectRenderer {
render_passes_in_frame) override; render_passes_in_frame) override;
void AllocateRenderPassResourceIfNeeded( void AllocateRenderPassResourceIfNeeded(
const RenderPassId& render_pass_id, const RenderPassId& render_pass_id,
const gfx::Size& enlarged_size, const RenderPassRequirements& requirements) override;
ResourceTextureHint texturehint) override;
bool IsRenderPassResourceAllocated( bool IsRenderPassResourceAllocated(
const RenderPassId& render_pass_id) const override; const RenderPassId& render_pass_id) const override;
gfx::Size GetRenderPassTextureSize( gfx::Size GetRenderPassTextureSize(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment