This source file includes following definitions.
- CheckDrawLayer
- TEST
#include "cc/layers/append_quads_data.h"
#include "cc/layers/heads_up_display_layer_impl.h"
#include "cc/test/fake_impl_proxy.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/fake_output_surface.h"
#include "cc/test/mock_quad_culler.h"
#include "cc/test/test_shared_bitmap_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cc {
namespace {
void CheckDrawLayer(HeadsUpDisplayLayerImpl* layer,
ResourceProvider* resource_provider,
DrawMode draw_mode) {
MockQuadCuller quad_culler;
AppendQuadsData data;
bool will_draw = layer->WillDraw(draw_mode, resource_provider);
if (will_draw)
layer->AppendQuads(&quad_culler, &data);
layer->UpdateHudTexture(draw_mode, resource_provider);
if (will_draw)
layer->DidDraw(resource_provider);
size_t expected_quad_list_size = will_draw ? 1 : 0;
EXPECT_EQ(expected_quad_list_size, quad_culler.quad_list().size());
}
TEST(HeadsUpDisplayLayerImplTest, ResourcelessSoftwareDrawAfterResourceLoss) {
FakeImplProxy proxy;
TestSharedBitmapManager shared_bitmap_manager;
FakeLayerTreeHostImpl host_impl(&proxy, &shared_bitmap_manager);
host_impl.CreatePendingTree();
host_impl.InitializeRenderer(
FakeOutputSurface::Create3d().PassAs<OutputSurface>());
scoped_ptr<HeadsUpDisplayLayerImpl> layer =
HeadsUpDisplayLayerImpl::Create(host_impl.pending_tree(), 1);
layer->SetContentBounds(gfx::Size(100, 100));
CheckDrawLayer(
layer.get(), host_impl.resource_provider(), DRAW_MODE_HARDWARE);
layer->ReleaseResources();
CheckDrawLayer(layer.get(),
host_impl.resource_provider(),
DRAW_MODE_RESOURCELESS_SOFTWARE);
}
}
}