Make oop_pixeltest.cc cover RasterDecoder
This CL updates oop_pixeltest.cc to test OOP-R on both GLES2Decoder and RasterDecoder. Once --enable-raster-decoder is always enabled for --enable-oop-rasterization we can simplify and only test RasterDecoder. Bug: 789238 Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel;master.tryserver.blink:linux_trusty_blink_rel Change-Id: I4a240d23805729607aaebf33a09e9b858b691bee Reviewed-on: https://chromium-review.googlesource.com/1019357 Commit-Queue: Jonathan Backer <backer@chromium.org> Reviewed-by: enne <enne@chromium.org> Cr-Commit-Position: refs/heads/master@{#552131}
This commit is contained in:

committed by
Commit Bot

parent
e1a4b9edab
commit
f0ec6de895
@ -2,6 +2,7 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include <tuple>
|
||||
#include <vector>
|
||||
|
||||
#include "base/command_line.h"
|
||||
@ -47,8 +48,10 @@ scoped_refptr<DisplayItemList> MakeNoopDisplayItemList() {
|
||||
return display_item_list;
|
||||
}
|
||||
|
||||
class OopPixelTest : public testing::Test {
|
||||
class OopPixelTestBase : public testing::Test {
|
||||
public:
|
||||
virtual bool UseRasterDecoder() = 0;
|
||||
|
||||
void SetUp() override {
|
||||
// Add an OOP rasterization command line flag so that we set
|
||||
// |chromium_raster_transport| features flag.
|
||||
@ -59,16 +62,23 @@ class OopPixelTest : public testing::Test {
|
||||
switches::kEnableOOPRasterization);
|
||||
}
|
||||
|
||||
context_provider_ =
|
||||
base::MakeRefCounted<TestInProcessContextProvider>(nullptr, true);
|
||||
raster_context_provider_ =
|
||||
base::MakeRefCounted<TestInProcessContextProvider>(
|
||||
nullptr, /*enable_oop_rasterization=*/true,
|
||||
/*enable_gles2_interface=*/!UseRasterDecoder());
|
||||
int max_texture_size =
|
||||
context_provider_->ContextCapabilities().max_texture_size;
|
||||
raster_context_provider_->ContextCapabilities().max_texture_size;
|
||||
oop_image_cache_.reset(new GpuImageDecodeCache(
|
||||
context_provider_.get(), true, kRGBA_8888_SkColorType, kWorkingSetSize,
|
||||
max_texture_size));
|
||||
raster_context_provider_.get(), true, kRGBA_8888_SkColorType,
|
||||
kWorkingSetSize, max_texture_size));
|
||||
|
||||
gles2_context_provider_ =
|
||||
base::MakeRefCounted<TestInProcessContextProvider>(
|
||||
nullptr, /*enable_oop_rasterization=*/false,
|
||||
/*enable_gles2_interface=*/true);
|
||||
gpu_image_cache_.reset(new GpuImageDecodeCache(
|
||||
context_provider_.get(), false, kRGBA_8888_SkColorType, kWorkingSetSize,
|
||||
max_texture_size));
|
||||
gles2_context_provider_.get(), false, kRGBA_8888_SkColorType,
|
||||
kWorkingSetSize, max_texture_size));
|
||||
}
|
||||
|
||||
class RasterOptions {
|
||||
@ -107,24 +117,25 @@ class OopPixelTest : public testing::Test {
|
||||
SkBitmap Raster(scoped_refptr<DisplayItemList> display_item_list,
|
||||
const RasterOptions& options) {
|
||||
TestInProcessContextProvider::ScopedRasterContextLock lock(
|
||||
context_provider_.get());
|
||||
raster_context_provider_.get());
|
||||
|
||||
PlaybackImageProvider image_provider(oop_image_cache_.get(),
|
||||
options.color_space,
|
||||
PlaybackImageProvider::Settings());
|
||||
|
||||
gpu::gles2::GLES2Interface* gl = context_provider_->ContextGL();
|
||||
gpu::gles2::GLES2Interface* gl = gles2_context_provider_->ContextGL();
|
||||
int width = options.resource_size.width();
|
||||
int height = options.resource_size.height();
|
||||
|
||||
// Create and allocate a texture on the raster interface.
|
||||
GLuint raster_texture_id;
|
||||
auto* raster_implementation = context_provider_->RasterInterface();
|
||||
|
||||
auto* raster_implementation = raster_context_provider_->RasterInterface();
|
||||
raster_texture_id = raster_implementation->CreateTexture(
|
||||
false, gfx::BufferUsage::GPU_READ, viz::ResourceFormat::RGBA_8888);
|
||||
raster_implementation->TexStorage2D(raster_texture_id, 1, width, height);
|
||||
raster_implementation->TexParameteri(raster_texture_id,
|
||||
GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
|
||||
EXPECT_EQ(raster_implementation->GetError(),
|
||||
static_cast<unsigned>(GL_NO_ERROR));
|
||||
@ -211,8 +222,8 @@ class OopPixelTest : public testing::Test {
|
||||
scoped_refptr<DisplayItemList> display_item_list,
|
||||
const RasterOptions& options) {
|
||||
TestInProcessContextProvider::ScopedRasterContextLock lock(
|
||||
context_provider_.get());
|
||||
context_provider_->GrContext()->resetContext();
|
||||
gles2_context_provider_.get());
|
||||
gles2_context_provider_->GrContext()->resetContext();
|
||||
|
||||
// Generate bitmap via the "in process" raster path. This verifies
|
||||
// that the preamble setup in RasterSource::PlaybackToCanvas matches
|
||||
@ -244,8 +255,8 @@ class OopPixelTest : public testing::Test {
|
||||
}
|
||||
SkImageInfo image_info = SkImageInfo::MakeN32Premul(
|
||||
options.resource_size.width(), options.resource_size.height());
|
||||
auto surface = SkSurface::MakeRenderTarget(context_provider_->GrContext(),
|
||||
SkBudgeted::kYes, image_info);
|
||||
auto surface = SkSurface::MakeRenderTarget(
|
||||
gles2_context_provider_->GrContext(), SkBudgeted::kYes, image_info);
|
||||
SkCanvas* canvas = surface->getCanvas();
|
||||
if (options.preclear)
|
||||
canvas->drawColor(options.preclear_color);
|
||||
@ -259,7 +270,7 @@ class OopPixelTest : public testing::Test {
|
||||
options.full_raster_rect, options.playback_rect, raster_transform,
|
||||
settings);
|
||||
surface->prepareForExternalIO();
|
||||
EXPECT_EQ(context_provider_->ContextGL()->GetError(),
|
||||
EXPECT_EQ(gles2_context_provider_->ContextGL()->GetError(),
|
||||
static_cast<unsigned>(GL_NO_ERROR));
|
||||
|
||||
SkBitmap bitmap;
|
||||
@ -269,7 +280,7 @@ class OopPixelTest : public testing::Test {
|
||||
bitmap.allocPixels(info, options.resource_size.width() * 4);
|
||||
bool success = surface->readPixels(bitmap, 0, 0);
|
||||
CHECK(success);
|
||||
EXPECT_EQ(context_provider_->ContextGL()->GetError(),
|
||||
EXPECT_EQ(gles2_context_provider_->ContextGL()->GetError(),
|
||||
static_cast<unsigned>(GL_NO_ERROR));
|
||||
return bitmap;
|
||||
}
|
||||
@ -293,7 +304,8 @@ class OopPixelTest : public testing::Test {
|
||||
|
||||
protected:
|
||||
enum { kWorkingSetSize = 64 * 1024 * 1024 };
|
||||
scoped_refptr<TestInProcessContextProvider> context_provider_;
|
||||
scoped_refptr<TestInProcessContextProvider> raster_context_provider_;
|
||||
scoped_refptr<TestInProcessContextProvider> gles2_context_provider_;
|
||||
std::unique_ptr<GpuImageDecodeCache> gpu_image_cache_;
|
||||
std::unique_ptr<GpuImageDecodeCache> oop_image_cache_;
|
||||
gl::DisableNullDrawGLBindings enable_pixel_output_;
|
||||
@ -301,18 +313,26 @@ class OopPixelTest : public testing::Test {
|
||||
int color_space_id_ = 0;
|
||||
};
|
||||
|
||||
class OopImagePixelTest : public OopPixelTest,
|
||||
public ::testing::WithParamInterface<bool> {
|
||||
class OopPixelTest : public OopPixelTestBase,
|
||||
public ::testing::WithParamInterface<bool> {
|
||||
public:
|
||||
bool UseTooLargeImage() { return GetParam(); }
|
||||
bool UseRasterDecoder() final { return GetParam(); }
|
||||
};
|
||||
|
||||
class OopImagePixelTest
|
||||
: public OopPixelTestBase,
|
||||
public ::testing::WithParamInterface<std::tuple<bool, bool>> {
|
||||
public:
|
||||
bool UseRasterDecoder() final { return std::get<0>(GetParam()); }
|
||||
bool UseTooLargeImage() { return std::get<1>(GetParam()); }
|
||||
gfx::Size GetImageSize() {
|
||||
const int kMaxSize = 20000;
|
||||
DCHECK_GT(kMaxSize, context_provider_->GrContext()->maxTextureSize());
|
||||
DCHECK_GT(kMaxSize, gles2_context_provider_->GrContext()->maxTextureSize());
|
||||
return UseTooLargeImage() ? gfx::Size(10, kMaxSize) : gfx::Size(10, 10);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_F(OopPixelTest, DrawColor) {
|
||||
TEST_P(OopPixelTest, DrawColor) {
|
||||
gfx::Rect rect(10, 10);
|
||||
auto display_item_list = base::MakeRefCounted<DisplayItemList>();
|
||||
display_item_list->StartPaint();
|
||||
@ -334,7 +354,7 @@ TEST_F(OopPixelTest, DrawColor) {
|
||||
ExpectEquals(actual_gpu, expected, "gpu");
|
||||
}
|
||||
|
||||
TEST_F(OopPixelTest, DrawColorWithTargetColorSpace) {
|
||||
TEST_P(OopPixelTest, DrawColorWithTargetColorSpace) {
|
||||
gfx::Rect rect(10, 10);
|
||||
auto display_item_list = base::MakeRefCounted<DisplayItemList>();
|
||||
display_item_list->StartPaint();
|
||||
@ -355,7 +375,7 @@ TEST_F(OopPixelTest, DrawColorWithTargetColorSpace) {
|
||||
EXPECT_EQ(SkColorSetARGB(255, 38, 15, 221), expected.getColor(0, 0));
|
||||
}
|
||||
|
||||
TEST_F(OopPixelTest, DrawRect) {
|
||||
TEST_P(OopPixelTest, DrawRect) {
|
||||
gfx::Rect rect(10, 10);
|
||||
auto color_paint = [](int r, int g, int b) {
|
||||
PaintFlags flags;
|
||||
@ -550,7 +570,7 @@ TEST_P(OopImagePixelTest, DrawImageWithSourceAndTargetColorSpace) {
|
||||
ExpectEquals(actual, expected);
|
||||
}
|
||||
|
||||
TEST_F(OopPixelTest, Preclear) {
|
||||
TEST_P(OopPixelTest, Preclear) {
|
||||
gfx::Rect rect(10, 10);
|
||||
auto display_item_list = base::MakeRefCounted<DisplayItemList>();
|
||||
display_item_list->Finalize();
|
||||
@ -571,7 +591,7 @@ TEST_F(OopPixelTest, Preclear) {
|
||||
ExpectEquals(actual, expected);
|
||||
}
|
||||
|
||||
TEST_F(OopPixelTest, ClearingOpaqueCorner) {
|
||||
TEST_P(OopPixelTest, ClearingOpaqueCorner) {
|
||||
// Verify that clears work properly for both the right and bottom sides
|
||||
// of an opaque corner tile.
|
||||
|
||||
@ -613,7 +633,7 @@ TEST_F(OopPixelTest, ClearingOpaqueCorner) {
|
||||
ExpectEquals(gpu_result, bitmap, "gpu");
|
||||
}
|
||||
|
||||
TEST_F(OopPixelTest, ClearingOpaqueCornerExactEdge) {
|
||||
TEST_P(OopPixelTest, ClearingOpaqueCornerExactEdge) {
|
||||
// Verify that clears work properly for both the right and bottom sides
|
||||
// of an opaque corner tile whose content rect exactly lines up with
|
||||
// the edge of the resource.
|
||||
@ -656,7 +676,7 @@ TEST_F(OopPixelTest, ClearingOpaqueCornerExactEdge) {
|
||||
ExpectEquals(gpu_result, bitmap, "gpu");
|
||||
}
|
||||
|
||||
TEST_F(OopPixelTest, ClearingOpaqueCornerPartialRaster) {
|
||||
TEST_P(OopPixelTest, ClearingOpaqueCornerPartialRaster) {
|
||||
// Verify that clears do nothing on an opaque corner tile whose
|
||||
// partial raster rect doesn't intersect the edge of the content.
|
||||
|
||||
@ -693,7 +713,7 @@ TEST_F(OopPixelTest, ClearingOpaqueCornerPartialRaster) {
|
||||
ExpectEquals(gpu_result, bitmap, "gpu");
|
||||
}
|
||||
|
||||
TEST_F(OopPixelTest, ClearingOpaqueRightEdge) {
|
||||
TEST_P(OopPixelTest, ClearingOpaqueRightEdge) {
|
||||
// Verify that a tile that intersects the right edge of content
|
||||
// but not the bottom only clears the right pixels.
|
||||
|
||||
@ -732,7 +752,7 @@ TEST_F(OopPixelTest, ClearingOpaqueRightEdge) {
|
||||
ExpectEquals(gpu_result, bitmap, "gpu");
|
||||
}
|
||||
|
||||
TEST_F(OopPixelTest, ClearingOpaqueBottomEdge) {
|
||||
TEST_P(OopPixelTest, ClearingOpaqueBottomEdge) {
|
||||
// Verify that a tile that intersects the bottom edge of content
|
||||
// but not the right only clears the bottom pixels.
|
||||
|
||||
@ -773,7 +793,7 @@ TEST_F(OopPixelTest, ClearingOpaqueBottomEdge) {
|
||||
ExpectEquals(gpu_result, bitmap, "gpu");
|
||||
}
|
||||
|
||||
TEST_F(OopPixelTest, ClearingOpaqueInternal) {
|
||||
TEST_P(OopPixelTest, ClearingOpaqueInternal) {
|
||||
// Verify that an internal opaque tile does no clearing.
|
||||
|
||||
RasterOptions options;
|
||||
@ -811,7 +831,7 @@ TEST_F(OopPixelTest, ClearingOpaqueInternal) {
|
||||
ExpectEquals(gpu_result, bitmap, "gpu");
|
||||
}
|
||||
|
||||
TEST_F(OopPixelTest, ClearingTransparentCorner) {
|
||||
TEST_P(OopPixelTest, ClearingTransparentCorner) {
|
||||
RasterOptions options;
|
||||
gfx::Point arbitrary_offset(5, 8);
|
||||
options.resource_size = gfx::Size(10, 10);
|
||||
@ -847,7 +867,7 @@ TEST_F(OopPixelTest, ClearingTransparentCorner) {
|
||||
ExpectEquals(gpu_result, bitmap, "gpu");
|
||||
}
|
||||
|
||||
TEST_F(OopPixelTest, ClearingTransparentInternalTile) {
|
||||
TEST_P(OopPixelTest, ClearingTransparentInternalTile) {
|
||||
// Content rect much larger than full raster rect or playback rect.
|
||||
// This should still clear the tile.
|
||||
RasterOptions options;
|
||||
@ -884,7 +904,7 @@ TEST_F(OopPixelTest, ClearingTransparentInternalTile) {
|
||||
ExpectEquals(gpu_result, bitmap, "gpu");
|
||||
}
|
||||
|
||||
TEST_F(OopPixelTest, ClearingTransparentCornerPartialRaster) {
|
||||
TEST_P(OopPixelTest, ClearingTransparentCornerPartialRaster) {
|
||||
RasterOptions options;
|
||||
options.resource_size = gfx::Size(10, 10);
|
||||
gfx::Point arbitrary_offset(30, 12);
|
||||
@ -927,7 +947,7 @@ TEST_F(OopPixelTest, ClearingTransparentCornerPartialRaster) {
|
||||
// Test various bitmap and playback rects in the raster options, to verify
|
||||
// that in process (RasterSource) and out of process (GLES2Implementation)
|
||||
// raster behave identically.
|
||||
TEST_F(OopPixelTest, DrawRectBasicRasterOptions) {
|
||||
TEST_P(OopPixelTest, DrawRectBasicRasterOptions) {
|
||||
PaintFlags flags;
|
||||
flags.setColor(SkColorSetARGB(255, 250, 10, 20));
|
||||
gfx::Rect draw_rect(3, 1, 8, 9);
|
||||
@ -960,7 +980,7 @@ TEST_F(OopPixelTest, DrawRectBasicRasterOptions) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(OopPixelTest, DrawRectScaleTransformOptions) {
|
||||
TEST_P(OopPixelTest, DrawRectScaleTransformOptions) {
|
||||
PaintFlags flags;
|
||||
// Use powers of two here to make floating point blending consistent.
|
||||
flags.setColor(SkColorSetARGB(128, 64, 128, 32));
|
||||
@ -991,7 +1011,7 @@ TEST_F(OopPixelTest, DrawRectScaleTransformOptions) {
|
||||
ExpectEquals(actual, expected);
|
||||
}
|
||||
|
||||
TEST_F(OopPixelTest, DrawRectQueryMiddleOfDisplayList) {
|
||||
TEST_P(OopPixelTest, DrawRectQueryMiddleOfDisplayList) {
|
||||
auto display_item_list = base::MakeRefCounted<DisplayItemList>();
|
||||
std::vector<SkColor> colors = {
|
||||
SkColorSetARGB(255, 0, 0, 255), SkColorSetARGB(255, 0, 255, 0),
|
||||
@ -1024,7 +1044,7 @@ TEST_F(OopPixelTest, DrawRectQueryMiddleOfDisplayList) {
|
||||
ExpectEquals(actual, expected);
|
||||
}
|
||||
|
||||
TEST_F(OopPixelTest, DrawRectColorSpace) {
|
||||
TEST_P(OopPixelTest, DrawRectColorSpace) {
|
||||
RasterOptions options;
|
||||
options.resource_size = gfx::Size(100, 100);
|
||||
options.content_size = options.resource_size;
|
||||
@ -1047,7 +1067,12 @@ TEST_F(OopPixelTest, DrawRectColorSpace) {
|
||||
ExpectEquals(actual, expected);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(P, OopImagePixelTest, ::testing::Values(false, true));
|
||||
INSTANTIATE_TEST_CASE_P(P, OopPixelTest, ::testing::Bool());
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(P,
|
||||
OopImagePixelTest,
|
||||
::testing::Combine(::testing::Bool(),
|
||||
::testing::Bool()));
|
||||
|
||||
} // namespace
|
||||
} // namespace cc
|
||||
|
@ -45,10 +45,12 @@ LayerTreePixelTest::CreateLayerTreeFrameSink(
|
||||
scoped_refptr<TestInProcessContextProvider> compositor_context_provider;
|
||||
scoped_refptr<TestInProcessContextProvider> worker_context_provider;
|
||||
if (test_type_ == PIXEL_TEST_GL) {
|
||||
compositor_context_provider =
|
||||
new TestInProcessContextProvider(nullptr, false);
|
||||
compositor_context_provider = new TestInProcessContextProvider(
|
||||
nullptr, /*enable_oop_rasterization=*/false,
|
||||
/*supports_gles2_interface=*/true);
|
||||
worker_context_provider = new TestInProcessContextProvider(
|
||||
compositor_context_provider.get(), false);
|
||||
compositor_context_provider.get(), /*enable_oop_rasterization=*/false,
|
||||
/*supports_gles2_interface=*/true);
|
||||
}
|
||||
constexpr bool disable_display_vsync = false;
|
||||
bool synchronous_composite =
|
||||
@ -78,7 +80,9 @@ LayerTreePixelTest::CreateDisplayOutputSurfaceOnThread(
|
||||
// mimic texture transport from the renderer process to the Display
|
||||
// compositor.
|
||||
auto display_context_provider =
|
||||
base::MakeRefCounted<TestInProcessContextProvider>(nullptr, false);
|
||||
base::MakeRefCounted<TestInProcessContextProvider>(
|
||||
nullptr, /*enable_oop_rasterization=*/false,
|
||||
/*support_gles2_interface=*/true);
|
||||
display_context_provider->BindToCurrentThread();
|
||||
|
||||
bool flipped_output_surface = false;
|
||||
|
@ -161,8 +161,9 @@ bool PixelTest::PixelsMatchReference(const base::FilePath& ref_file,
|
||||
void PixelTest::SetUpGLWithoutRenderer(bool flipped_output_surface) {
|
||||
enable_pixel_output_ = std::make_unique<gl::DisableNullDrawGLBindings>();
|
||||
|
||||
auto context_provider =
|
||||
base::MakeRefCounted<TestInProcessContextProvider>(nullptr, false);
|
||||
auto context_provider = base::MakeRefCounted<TestInProcessContextProvider>(
|
||||
nullptr, /*enable_oop_rasterization=*/false,
|
||||
/*support_gles2_interface=*/true);
|
||||
output_surface_ = std::make_unique<PixelTestOutputSurface>(
|
||||
std::move(context_provider), flipped_output_surface);
|
||||
output_surface_->BindToClient(output_surface_client_.get());
|
||||
@ -173,8 +174,9 @@ void PixelTest::SetUpGLWithoutRenderer(bool flipped_output_surface) {
|
||||
resource_provider_ = std::make_unique<DisplayResourceProvider>(
|
||||
output_surface_->context_provider(), shared_bitmap_manager_.get());
|
||||
|
||||
child_context_provider_ =
|
||||
base::MakeRefCounted<TestInProcessContextProvider>(nullptr, false);
|
||||
child_context_provider_ = base::MakeRefCounted<TestInProcessContextProvider>(
|
||||
nullptr, /*enable_oop_rasterization=*/false,
|
||||
/*support_gles2_interface=*/true);
|
||||
child_context_provider_->BindToCurrentThread();
|
||||
child_resource_provider_ = std::make_unique<LayerTreeResourceProvider>(
|
||||
child_context_provider_.get(), shared_bitmap_manager_.get(),
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "cc/test/test_in_process_context_provider.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <utility>
|
||||
|
||||
#include "base/lazy_instance.h"
|
||||
#include "base/macros.h"
|
||||
@ -17,6 +18,7 @@
|
||||
#include "gpu/command_buffer/client/shared_memory_limits.h"
|
||||
#include "gpu/command_buffer/common/context_creation_attribs.h"
|
||||
#include "gpu/ipc/gl_in_process_context.h"
|
||||
#include "gpu/ipc/raster_in_process_context.h"
|
||||
#include "gpu/skia_bindings/grcontext_for_gles2_interface.h"
|
||||
#include "third_party/khronos/GLES2/gl2.h"
|
||||
#include "third_party/khronos/GLES2/gl2ext.h"
|
||||
@ -61,20 +63,44 @@ std::unique_ptr<gpu::GLInProcessContext> CreateTestInProcessContext() {
|
||||
|
||||
TestInProcessContextProvider::TestInProcessContextProvider(
|
||||
TestInProcessContextProvider* shared_context,
|
||||
bool enable_oop_rasterization) {
|
||||
// TODO(enne): make this always support oop rasterization. Some tests
|
||||
// fail to create the context when oop rasterization is turned on.
|
||||
context_ = CreateTestInProcessContext(
|
||||
&gpu_memory_buffer_manager_, &image_factory_,
|
||||
(shared_context ? shared_context->context_.get() : nullptr),
|
||||
base::ThreadTaskRunnerHandle::Get(), enable_oop_rasterization);
|
||||
cache_controller_.reset(new viz::ContextCacheController(
|
||||
context_->GetImplementation(), base::ThreadTaskRunnerHandle::Get()));
|
||||
bool enable_oop_rasterization,
|
||||
bool support_gles2_interface) {
|
||||
if (support_gles2_interface) {
|
||||
// TODO(enne): make this always support oop rasterization. Some tests
|
||||
// fail to create the context when oop rasterization is turned on.
|
||||
gles2_context_ = CreateTestInProcessContext(
|
||||
&gpu_memory_buffer_manager_, &image_factory_,
|
||||
(shared_context ? shared_context->gles2_context_.get() : nullptr),
|
||||
base::ThreadTaskRunnerHandle::Get(), enable_oop_rasterization);
|
||||
cache_controller_.reset(
|
||||
new viz::ContextCacheController(gles2_context_->GetImplementation(),
|
||||
base::ThreadTaskRunnerHandle::Get()));
|
||||
|
||||
raster_implementation_ =
|
||||
std::make_unique<gpu::raster::RasterImplementationGLES>(
|
||||
context_->GetImplementation(), context_->GetImplementation(),
|
||||
context_->GetCapabilities());
|
||||
raster_implementation_gles2_ =
|
||||
std::make_unique<gpu::raster::RasterImplementationGLES>(
|
||||
gles2_context_->GetImplementation(),
|
||||
gles2_context_->GetImplementation(),
|
||||
gles2_context_->GetCapabilities());
|
||||
} else {
|
||||
gpu::ContextCreationAttribs attribs;
|
||||
attribs.bind_generates_resource = false;
|
||||
attribs.enable_oop_rasterization = enable_oop_rasterization;
|
||||
attribs.enable_raster_interface = true;
|
||||
attribs.enable_gles2_interface = false;
|
||||
attribs.enable_raster_decoder = true;
|
||||
|
||||
raster_context_.reset(new gpu::RasterInProcessContext);
|
||||
auto result = raster_context_->Initialize(
|
||||
/*service=*/nullptr, attribs, gpu::SharedMemoryLimits(),
|
||||
&gpu_memory_buffer_manager_, &image_factory_,
|
||||
/*gpu_channel_manager_delegate=*/nullptr,
|
||||
base::ThreadTaskRunnerHandle::Get());
|
||||
DCHECK_EQ(result, gpu::ContextResult::kSuccess);
|
||||
|
||||
cache_controller_.reset(
|
||||
new viz::ContextCacheController(raster_context_->GetContextSupport(),
|
||||
base::ThreadTaskRunnerHandle::Get()));
|
||||
}
|
||||
}
|
||||
|
||||
TestInProcessContextProvider::~TestInProcessContextProvider() = default;
|
||||
@ -92,21 +118,33 @@ gpu::ContextResult TestInProcessContextProvider::BindToCurrentThread() {
|
||||
}
|
||||
|
||||
gpu::gles2::GLES2Interface* TestInProcessContextProvider::ContextGL() {
|
||||
return context_->GetImplementation();
|
||||
return gles2_context_->GetImplementation();
|
||||
}
|
||||
|
||||
gpu::raster::RasterInterface* TestInProcessContextProvider::RasterInterface() {
|
||||
return raster_implementation_.get();
|
||||
if (raster_context_) {
|
||||
return raster_context_->GetImplementation();
|
||||
} else {
|
||||
return raster_implementation_gles2_.get();
|
||||
}
|
||||
}
|
||||
|
||||
gpu::ContextSupport* TestInProcessContextProvider::ContextSupport() {
|
||||
return context_->GetImplementation();
|
||||
if (gles2_context_) {
|
||||
return gles2_context_->GetImplementation();
|
||||
} else {
|
||||
return raster_context_->GetContextSupport();
|
||||
}
|
||||
}
|
||||
|
||||
class GrContext* TestInProcessContextProvider::GrContext() {
|
||||
if (gr_context_)
|
||||
return gr_context_->get();
|
||||
|
||||
if (!gles2_context_) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
size_t max_resource_cache_bytes;
|
||||
size_t max_glyph_cache_texture_bytes;
|
||||
skia_bindings::GrContextForGLES2Interface::DefaultCacheLimitsForTests(
|
||||
@ -128,7 +166,11 @@ base::Lock* TestInProcessContextProvider::GetLock() {
|
||||
|
||||
const gpu::Capabilities& TestInProcessContextProvider::ContextCapabilities()
|
||||
const {
|
||||
return context_->GetCapabilities();
|
||||
if (gles2_context_) {
|
||||
return gles2_context_->GetCapabilities();
|
||||
} else {
|
||||
return raster_context_->GetCapabilities();
|
||||
}
|
||||
}
|
||||
|
||||
const gpu::GpuFeatureInfo& TestInProcessContextProvider::GetGpuFeatureInfo()
|
||||
|
@ -21,6 +21,7 @@ class GrContext;
|
||||
|
||||
namespace gpu {
|
||||
class GLInProcessContext;
|
||||
class RasterInProcessContext;
|
||||
}
|
||||
|
||||
namespace skia_bindings {
|
||||
@ -41,9 +42,11 @@ class TestInProcessContextProvider
|
||||
public viz::ContextProvider,
|
||||
public viz::RasterContextProvider {
|
||||
public:
|
||||
explicit TestInProcessContextProvider(
|
||||
TestInProcessContextProvider* shared_context,
|
||||
bool enable_oop_rasterization);
|
||||
// TODO(backer): Once we only support OOP-R on Raster{Implementation,Decoder},
|
||||
// fold these two options into one.
|
||||
TestInProcessContextProvider(TestInProcessContextProvider* shared_context,
|
||||
bool enable_oop_rasterization,
|
||||
bool support_gles2_interface);
|
||||
|
||||
// viz::ContextProvider / viz::RasterContextProvider implementation.
|
||||
void AddRef() const override;
|
||||
@ -67,9 +70,15 @@ class TestInProcessContextProvider
|
||||
private:
|
||||
viz::TestGpuMemoryBufferManager gpu_memory_buffer_manager_;
|
||||
TestImageFactory image_factory_;
|
||||
std::unique_ptr<gpu::GLInProcessContext> context_;
|
||||
std::unique_ptr<gpu::raster::RasterInterface> raster_implementation_;
|
||||
|
||||
// Used if support_gles2_interface.
|
||||
std::unique_ptr<gpu::GLInProcessContext> gles2_context_;
|
||||
std::unique_ptr<gpu::raster::RasterInterface> raster_implementation_gles2_;
|
||||
std::unique_ptr<skia_bindings::GrContextForGLES2Interface> gr_context_;
|
||||
|
||||
// Used if !support_gles2_interface.
|
||||
std::unique_ptr<gpu::RasterInProcessContext> raster_context_;
|
||||
|
||||
std::unique_ptr<viz::ContextCacheController> cache_controller_;
|
||||
base::Lock context_lock_;
|
||||
gpu::GpuFeatureInfo gpu_feature_info_;
|
||||
|
@ -150,7 +150,9 @@ TEST_F(LayerTreeHostScrollbarsPixelTest, HugeTransformScale) {
|
||||
background->AddChild(layer);
|
||||
|
||||
scoped_refptr<TestInProcessContextProvider> context(
|
||||
new TestInProcessContextProvider(nullptr, false));
|
||||
new TestInProcessContextProvider(nullptr,
|
||||
/*enable_oop_rasterization=*/false,
|
||||
/*support_gles2_interface=*/true));
|
||||
context->BindToCurrentThread();
|
||||
int max_texture_size = 0;
|
||||
context->ContextGL()->GetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
|
||||
|
@ -1037,12 +1037,28 @@ void RasterImplementation::SetColorSpaceMetadata(GLuint texture_id,
|
||||
GLColorSpace color_space) {
|
||||
NOTIMPLEMENTED();
|
||||
}
|
||||
|
||||
void RasterImplementation::GenMailbox(GLbyte* mailbox) {
|
||||
NOTIMPLEMENTED();
|
||||
GPU_CLIENT_SINGLE_THREAD_CHECK();
|
||||
GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glGenMailboxCHROMIUM("
|
||||
<< static_cast<const void*>(mailbox) << ")");
|
||||
TRACE_EVENT0("gpu", "RasterImplementation::GenMailboxCHROMIUM");
|
||||
|
||||
gpu::Mailbox result = gpu::Mailbox::Generate();
|
||||
memcpy(mailbox, result.name, sizeof(result.name));
|
||||
}
|
||||
|
||||
void RasterImplementation::ProduceTextureDirect(GLuint texture,
|
||||
const GLbyte* mailbox) {
|
||||
NOTIMPLEMENTED();
|
||||
const GLbyte* data) {
|
||||
GPU_CLIENT_SINGLE_THREAD_CHECK();
|
||||
GPU_CLIENT_LOG("[" << GetLogPrefix() << "] glProduceTextureDirectCHROMIUM("
|
||||
<< static_cast<const void*>(data) << ")");
|
||||
const Mailbox& mailbox = *reinterpret_cast<const Mailbox*>(data);
|
||||
DCHECK(mailbox.Verify()) << "ProduceTextureDirectCHROMIUM was passed a "
|
||||
"mailbox that was not generated by "
|
||||
"GenMailboxCHROMIUM.";
|
||||
helper_->ProduceTextureDirectImmediate(texture, data);
|
||||
CheckGLError();
|
||||
}
|
||||
|
||||
GLuint RasterImplementation::CreateAndConsumeTexture(
|
||||
|
@ -1990,7 +1990,7 @@ void RasterDecoderImpl::TexStorage2D(TextureRef* texture_ref,
|
||||
texture_metadata.target());
|
||||
|
||||
unsigned int internal_format =
|
||||
viz::GLInternalFormat(texture_metadata.format());
|
||||
viz::TextureStorageFormat(texture_metadata.format());
|
||||
GLenum format =
|
||||
TextureManager::ExtractFormatFromStorageFormat(internal_format);
|
||||
GLenum type = TextureManager::ExtractTypeFromStorageFormat(internal_format);
|
||||
|
@ -94,6 +94,7 @@ ContextResult RasterInProcessContext::Initialize(
|
||||
GetCapabilities());
|
||||
helper_ = std::move(gles2_helper);
|
||||
} else {
|
||||
DCHECK(attribs.enable_raster_decoder);
|
||||
// Create the RasterCmdHelper, which writes the command buffer protocol.
|
||||
auto raster_helper =
|
||||
std::make_unique<raster::RasterCmdHelper>(command_buffer_.get());
|
||||
|
Reference in New Issue
Block a user