diff options
author | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-10 23:05:01 +0000 |
---|---|---|
committer | danakj@chromium.org <danakj@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-12-10 23:05:01 +0000 |
commit | e51444acccf0aeeeed78d0a9795016e26013e1a1 (patch) | |
tree | 358fba3fd6a996a2de9814bd5fd78ab204b5cd7a /cc | |
parent | a269ade545f74e075b8fff7ca5b7f2edf32369d0 (diff) | |
download | chromium_src-e51444acccf0aeeeed78d0a9795016e26013e1a1.zip chromium_src-e51444acccf0aeeeed78d0a9795016e26013e1a1.tar.gz chromium_src-e51444acccf0aeeeed78d0a9795016e26013e1a1.tar.bz2 |
cc: Add PRESUBMIT rule to ban using cc:: inside of namespace cc {...}
This also makes cc/ PRESUBMIT clean for the new check.
The most invasive changes were:
1. Moving the cc/test/paths.h enum into a CCPaths class (named with
CC prefix to clarify this path is for CC since the enum is extending
an enum from base/.
2. Merge ResourcePool::Resource up into ScopedResource which was the
same thing basically.
R=enne
BUG=
Review URL: https://codereview.chromium.org/109263003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239904 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc')
54 files changed, 373 insertions, 352 deletions
diff --git a/cc/PRESUBMIT.py b/cc/PRESUBMIT.py index daa5246..5b8100b 100644 --- a/cc/PRESUBMIT.py +++ b/cc/PRESUBMIT.py @@ -152,6 +152,73 @@ def CheckTodos(input_api, output_api): items=errors)] return [] +def FindUnquotedQuote(contents, pos): + match = re.search(r"(?<!\\)(?P<quote>\")", contents[pos:]) + return -1 if not match else match.start("quote") + pos + +def FindNamespaceInBlock(pos, namespace, contents, whitelist=[]): + open_brace = -1 + close_brace = -1 + quote = -1 + name = -1 + brace_count = 1 + quote_count = 0 + while pos < len(contents) and brace_count > 0: + if open_brace < pos: open_brace = contents.find("{", pos) + if close_brace < pos: close_brace = contents.find("}", pos) + if quote < pos: quote = FindUnquotedQuote(contents, pos) + if name < pos: name = contents.find(("%s::" % namespace), pos) + + if name < 0: + return False # The namespace is not used at all. + if open_brace < 0: + open_brace = len(contents) + if close_brace < 0: + close_brace = len(contents) + if quote < 0: + quote = len(contents) + + next = min(open_brace, min(close_brace, min(quote, name))) + + if next == open_brace: + brace_count += 1 + elif next == close_brace: + brace_count -= 1 + elif next == quote: + quote_count = 0 if quote_count else 1 + elif next == name and not quote_count: + in_whitelist = False + for w in whitelist: + if re.match(w, contents[next:]): + in_whitelist = True + break + if not in_whitelist: + return True + pos = next + 1 + return False + +# Checks for the use of cc:: within the cc namespace, which is usually +# redundant. +def CheckNamespace(input_api, output_api): + errors = [] + + source_file_filter = lambda x: x + for f in input_api.AffectedSourceFiles(source_file_filter): + contents = input_api.ReadFile(f, 'rb') + match = re.search(r'namespace\s*cc\s*{', contents) + if match: + whitelist = [ + r"cc::remove_if\b", + ] + if FindNamespaceInBlock(match.end(), 'cc', contents, whitelist=whitelist): + errors.append(f.LocalPath()) + + if errors: + return [output_api.PresubmitError( + 'Do not use cc:: inside of the cc namespace.', + items=errors)] + return [] + def CheckChangeOnUpload(input_api, output_api): results = [] @@ -160,6 +227,7 @@ def CheckChangeOnUpload(input_api, output_api): results += CheckPassByValue(input_api, output_api) results += CheckChangeLintsClean(input_api, output_api) results += CheckTodos(input_api, output_api) + results += CheckNamespace(input_api, output_api) return results def GetPreferredTrySlaves(project, change): @@ -169,4 +237,4 @@ def GetPreferredTrySlaves(project, change): 'linux_gpu', 'mac_gpu', 'mac_gpu_retina', - ] + ] diff --git a/cc/animation/layer_animation_controller.cc b/cc/animation/layer_animation_controller.cc index 43d680b..e1ab646 100644 --- a/cc/animation/layer_animation_controller.cc +++ b/cc/animation/layer_animation_controller.cc @@ -85,12 +85,12 @@ void LayerAnimationController::RemoveAnimation( int animation_id, Animation::TargetProperty target_property) { ScopedPtrVector<Animation>& animations = active_animations_; - animations.erase(cc::remove_if(&animations, - animations.begin(), - animations.end(), - HasAnimationIdAndProperty(animation_id, - target_property)), - animations.end()); + animations.erase( + cc::remove_if(&animations, + animations.begin(), + animations.end(), + HasAnimationIdAndProperty(animation_id, target_property)), + animations.end()); UpdateActivation(NormalActivation); } diff --git a/cc/animation/layer_animation_controller_unittest.cc b/cc/animation/layer_animation_controller_unittest.cc index 47c714f..f7918cd 100644 --- a/cc/animation/layer_animation_controller_unittest.cc +++ b/cc/animation/layer_animation_controller_unittest.cc @@ -425,11 +425,11 @@ TEST(LayerAnimationControllerTest, TrivialTransformOnImpl) { // Create simple Transform animation. TransformOperations operations; - curve->AddKeyframe(TransformKeyframe::Create( - 0, operations, scoped_ptr<cc::TimingFunction>())); + curve->AddKeyframe( + TransformKeyframe::Create(0, operations, scoped_ptr<TimingFunction>())); operations.AppendTranslate(delta_x, delta_y, 0); - curve->AddKeyframe(TransformKeyframe::Create( - 1, operations, scoped_ptr<cc::TimingFunction>())); + curve->AddKeyframe( + TransformKeyframe::Create(1, operations, scoped_ptr<TimingFunction>())); scoped_ptr<Animation> animation(Animation::Create( curve.PassAs<AnimationCurve>(), 1, 0, Animation::Transform)); @@ -475,12 +475,12 @@ TEST(LayerAnimationControllerTest, FilterTransition) { FilterOperations start_filters; start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); - curve->AddKeyframe(FilterKeyframe::Create( - 0, start_filters, scoped_ptr<cc::TimingFunction>())); + curve->AddKeyframe( + FilterKeyframe::Create(0, start_filters, scoped_ptr<TimingFunction>())); FilterOperations end_filters; end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); - curve->AddKeyframe(FilterKeyframe::Create( - 1, end_filters, scoped_ptr<cc::TimingFunction>())); + curve->AddKeyframe( + FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>())); scoped_ptr<Animation> animation(Animation::Create( curve.PassAs<AnimationCurve>(), 1, 0, Animation::Filter)); @@ -524,12 +524,12 @@ TEST(LayerAnimationControllerTest, FilterTransitionOnImplOnly) { // Create simple Filter animation. FilterOperations start_filters; start_filters.Append(FilterOperation::CreateBrightnessFilter(1.f)); - curve->AddKeyframe(FilterKeyframe::Create( - 0, start_filters, scoped_ptr<cc::TimingFunction>())); + curve->AddKeyframe( + FilterKeyframe::Create(0, start_filters, scoped_ptr<TimingFunction>())); FilterOperations end_filters; end_filters.Append(FilterOperation::CreateBrightnessFilter(2.f)); - curve->AddKeyframe(FilterKeyframe::Create( - 1, end_filters, scoped_ptr<cc::TimingFunction>())); + curve->AddKeyframe( + FilterKeyframe::Create(1, end_filters, scoped_ptr<TimingFunction>())); scoped_ptr<Animation> animation(Animation::Create( curve.PassAs<AnimationCurve>(), 1, 0, Animation::Filter)); @@ -1415,16 +1415,16 @@ TEST(LayerAnimationControllerTest, AnimatedBounds) { EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 13.f, 19.f, 20.f).ToString(), bounds.ToString()); - controller_impl->GetAnimation(1, Animation::Transform)->SetRunState( - cc::Animation::Finished, 0.0); + controller_impl->GetAnimation(1, Animation::Transform) + ->SetRunState(Animation::Finished, 0.0); // Only the unfinished animation should affect the animated bounds. EXPECT_TRUE(controller_impl->AnimatedBoundsForBox(box, &bounds)); EXPECT_EQ(gfx::BoxF(1.f, 2.f, -4.f, 7.f, 16.f, 20.f).ToString(), bounds.ToString()); - controller_impl->GetAnimation(2, Animation::Transform)->SetRunState( - cc::Animation::Finished, 0.0); + controller_impl->GetAnimation(2, Animation::Transform) + ->SetRunState(Animation::Finished, 0.0); // There are no longer any running animations. EXPECT_TRUE(controller_impl->AnimatedBoundsForBox(box, &bounds)); diff --git a/cc/base/switches.cc b/cc/base/switches.cc index d3d2d1d..ddba9cb 100644 --- a/cc/base/switches.cc +++ b/cc/base/switches.cc @@ -153,9 +153,9 @@ const char kDisableCompositorTouchHitTesting[] = bool IsLCDTextEnabled() { const CommandLine* command_line = CommandLine::ForCurrentProcess(); - if (command_line->HasSwitch(cc::switches::kDisableLCDText)) + if (command_line->HasSwitch(switches::kDisableLCDText)) return false; - else if (command_line->HasSwitch(cc::switches::kEnableLCDText)) + else if (command_line->HasSwitch(switches::kEnableLCDText)) return true; #if defined(OS_ANDROID) @@ -169,9 +169,9 @@ namespace { bool CheckImplSidePaintingStatus() { const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - if (command_line.HasSwitch(cc::switches::kDisableImplSidePainting)) + if (command_line.HasSwitch(switches::kDisableImplSidePainting)) return false; - else if (command_line.HasSwitch(cc::switches::kEnableImplSidePainting)) + else if (command_line.HasSwitch(switches::kEnableImplSidePainting)) return true; #if defined(OS_ANDROID) @@ -183,7 +183,7 @@ bool CheckImplSidePaintingStatus() { bool CheckGPURasterizationStatus() { const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - return command_line.HasSwitch(cc::switches::kEnableGPURasterization); + return command_line.HasSwitch(switches::kEnableGPURasterization); } } // namespace @@ -201,9 +201,9 @@ bool IsGPURasterizationEnabled() { bool IsMapImageEnabled() { const CommandLine& command_line = *CommandLine::ForCurrentProcess(); - if (command_line.HasSwitch(cc::switches::kDisableMapImage)) + if (command_line.HasSwitch(switches::kDisableMapImage)) return false; - else if (command_line.HasSwitch(cc::switches::kEnableMapImage)) + else if (command_line.HasSwitch(switches::kEnableMapImage)) return true; return false; diff --git a/cc/layers/heads_up_display_layer_impl.cc b/cc/layers/heads_up_display_layer_impl.cc index 61489ee..da47840 100644 --- a/cc/layers/heads_up_display_layer_impl.cc +++ b/cc/layers/heads_up_display_layer_impl.cc @@ -86,7 +86,7 @@ bool HeadsUpDisplayLayerImpl::WillDraw(DrawMode draw_mode, return false; if (!hud_resource_) - hud_resource_ = ScopedResource::create(resource_provider); + hud_resource_ = ScopedResource::Create(resource_provider); // TODO(danakj): The HUD could swap between two textures instead of creating a // texture every frame in ubercompositor. diff --git a/cc/layers/texture_layer_impl.cc b/cc/layers/texture_layer_impl.cc index 119ae91..96b44c7 100644 --- a/cc/layers/texture_layer_impl.cc +++ b/cc/layers/texture_layer_impl.cc @@ -105,7 +105,7 @@ bool TextureLayerImpl::WillDraw(DrawMode draw_mode, // Have to upload a copy to a texture for it to be used in a // hardware draw. if (!texture_copy_) - texture_copy_ = ScopedResource::create(resource_provider); + texture_copy_ = ScopedResource::Create(resource_provider); if (texture_copy_->size() != texture_mailbox_.shared_memory_size() || resource_provider->InUseByConsumer(texture_copy_->id())) texture_copy_->Free(); diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc index 5b3955e..3ae0c29 100644 --- a/cc/layers/texture_layer_unittest.cc +++ b/cc/layers/texture_layer_unittest.cc @@ -1538,7 +1538,7 @@ class TextureLayerChangeInvisibleTest return texture_; } virtual bool PrepareTextureMailbox( - cc::TextureMailbox* mailbox, + TextureMailbox* mailbox, scoped_ptr<SingleReleaseCallback>* release_callback, bool use_shared_memory) OVERRIDE { return false; @@ -1807,7 +1807,7 @@ class TextureLayerChangeInvisibleMailboxTest } virtual bool PrepareTextureMailbox( - cc::TextureMailbox* mailbox, + TextureMailbox* mailbox, scoped_ptr<SingleReleaseCallback>* release_callback, bool use_shared_memory) OVERRIDE { ++prepare_called_; diff --git a/cc/output/context_provider.h b/cc/output/context_provider.h index 54e75e9..0b6d482 100644 --- a/cc/output/context_provider.h +++ b/cc/output/context_provider.h @@ -80,7 +80,7 @@ class ContextProvider : public base::RefCountedThreadSafe<ContextProvider> { // Sets a callback to be called when the memory policy changes. This should be // called from the same thread that the context is bound to. - typedef base::Callback<void(const cc::ManagedMemoryPolicy& policy)> + typedef base::Callback<void(const ManagedMemoryPolicy& policy)> MemoryPolicyChangedCallback; virtual void SetMemoryPolicyChangedCallback( const MemoryPolicyChangedCallback& memory_policy_changed_callback) = 0; diff --git a/cc/output/direct_renderer.cc b/cc/output/direct_renderer.cc index 37f8247..84788c5 100644 --- a/cc/output/direct_renderer.cc +++ b/cc/output/direct_renderer.cc @@ -185,7 +185,7 @@ void DirectRenderer::DecideRenderPassAllocationsForFrame( for (size_t i = 0; i < render_passes_in_draw_order.size(); ++i) { if (!render_pass_textures_.contains(render_passes_in_draw_order[i]->id)) { scoped_ptr<ScopedResource> texture = - ScopedResource::create(resource_provider_); + ScopedResource::Create(resource_provider_); render_pass_textures_.set(render_passes_in_draw_order[i]->id, texture.Pass()); } @@ -401,19 +401,16 @@ bool DirectRenderer::UseRenderPass(DrawingFrame* frame, return true; } - if (!resource_provider_) - return false; - ScopedResource* texture = render_pass_textures_.get(render_pass->id); DCHECK(texture); gfx::Size size = RenderPassTextureSize(render_pass); size.Enlarge(enlarge_pass_texture_amount_.x(), enlarge_pass_texture_amount_.y()); - if (!texture->id() && - !texture->Allocate( - size, ResourceProvider::TextureUsageFramebuffer, RGBA_8888)) - return false; + if (!texture->id()) + texture->Allocate( + size, ResourceProvider::TextureUsageFramebuffer, RGBA_8888); + DCHECK(texture->id()); return BindFramebufferToTexture(frame, texture, render_pass->output_rect); } diff --git a/cc/output/gl_renderer.cc b/cc/output/gl_renderer.cc index 054fa3a..51141da 100644 --- a/cc/output/gl_renderer.cc +++ b/cc/output/gl_renderer.cc @@ -711,16 +711,13 @@ scoped_ptr<ScopedResource> GLRenderer::GetBackgroundWithFilters( MoveFromDrawToWindowSpace(frame->current_render_pass->output_rect)); scoped_ptr<ScopedResource> device_background_texture = - ScopedResource::create(resource_provider_); + ScopedResource::Create(resource_provider_); // The TextureUsageFramebuffer hint makes ResourceProvider avoid immutable // storage allocation (texStorage2DEXT) for this texture. copyTexImage2D fails // when called on a texture having immutable storage. - if (!device_background_texture->Allocate( - window_rect.size(), - ResourceProvider::TextureUsageFramebuffer, - RGBA_8888)) { - return scoped_ptr<ScopedResource>(); - } else { + device_background_texture->Allocate( + window_rect.size(), ResourceProvider::TextureUsageFramebuffer, RGBA_8888); + { ResourceProvider::ScopedWriteLockGL lock(resource_provider_, device_background_texture->id()); GetFramebufferTexture(lock.texture_id(), @@ -755,11 +752,9 @@ scoped_ptr<ScopedResource> GLRenderer::GetBackgroundWithFilters( } scoped_ptr<ScopedResource> background_texture = - ScopedResource::create(resource_provider_); - if (!background_texture->Allocate(quad->rect.size(), - ResourceProvider::TextureUsageFramebuffer, - RGBA_8888)) - return scoped_ptr<ScopedResource>(); + ScopedResource::Create(resource_provider_); + background_texture->Allocate( + quad->rect.size(), ResourceProvider::TextureUsageFramebuffer, RGBA_8888); const RenderPass* target_render_pass = frame->current_render_pass; bool using_background_texture = diff --git a/cc/output/gl_renderer_unittest.cc b/cc/output/gl_renderer_unittest.cc index c9b6cca..e8e0ae8 100644 --- a/cc/output/gl_renderer_unittest.cc +++ b/cc/output/gl_renderer_unittest.cc @@ -878,7 +878,7 @@ TEST_F(GLRendererTest, ActiveTextureState) { // During initialization we are allowed to set any texture parameters. EXPECT_CALL(*context, texParameteri(_, _, _)).Times(AnyNumber()); - cc::RenderPass::Id id(1, 1); + RenderPass::Id id(1, 1); TestRenderPass* root_pass = AddRenderPass( &render_passes_in_draw_order_, id, gfx::Rect(100, 100), gfx::Transform()); root_pass->AppendOneOfEveryQuadType(resource_provider.get(), @@ -1388,7 +1388,7 @@ TEST_F(GLRendererShaderTest, DrawRenderPassQuadShaderPermutations) { RenderPass::Id root_pass_id(1, 0); TestRenderPass* root_pass; - cc::ResourceProvider::ResourceId mask = resource_provider_->CreateResource( + ResourceProvider::ResourceId mask = resource_provider_->CreateResource( gfx::Size(20, 12), GL_CLAMP_TO_EDGE, ResourceProvider::TextureUsageAny, diff --git a/cc/output/output_surface.cc b/cc/output/output_surface.cc index c2f89e2..f63ff29 100644 --- a/cc/output/output_surface.cc +++ b/cc/output/output_surface.cc @@ -56,8 +56,7 @@ OutputSurface::OutputSurface(scoped_refptr<ContextProvider> context_provider) weak_ptr_factory_(this), gpu_latency_history_(kGpuLatencyHistorySize) {} -OutputSurface::OutputSurface( - scoped_ptr<cc::SoftwareOutputDevice> software_device) +OutputSurface::OutputSurface(scoped_ptr<SoftwareOutputDevice> software_device) : software_device_(software_device.Pass()), device_scale_factor_(-1), max_frames_pending_(0), @@ -70,9 +69,8 @@ OutputSurface::OutputSurface( weak_ptr_factory_(this), gpu_latency_history_(kGpuLatencyHistorySize) {} -OutputSurface::OutputSurface( - scoped_refptr<ContextProvider> context_provider, - scoped_ptr<cc::SoftwareOutputDevice> software_device) +OutputSurface::OutputSurface(scoped_refptr<ContextProvider> context_provider, + scoped_ptr<SoftwareOutputDevice> software_device) : context_provider_(context_provider), software_device_(software_device.Pass()), device_scale_factor_(-1), @@ -263,7 +261,7 @@ bool OutputSurface::HasExternalStencilTest() const { bool OutputSurface::ForcedDrawToSoftwareDevice() const { return false; } -bool OutputSurface::BindToClient(cc::OutputSurfaceClient* client) { +bool OutputSurface::BindToClient(OutputSurfaceClient* client) { DCHECK(client); client_ = client; bool success = true; @@ -382,7 +380,7 @@ void OutputSurface::BindFramebuffer() { context_provider_->Context3d()->bindFramebuffer(GL_FRAMEBUFFER, 0); } -void OutputSurface::SwapBuffers(cc::CompositorFrame* frame) { +void OutputSurface::SwapBuffers(CompositorFrame* frame) { if (frame->software_frame_data) { PostSwapBuffersComplete(); DidSwapBuffers(); diff --git a/cc/output/output_surface.h b/cc/output/output_surface.h index 2d5dda8..0d7d4e7 100644 --- a/cc/output/output_surface.h +++ b/cc/output/output_surface.h @@ -49,10 +49,10 @@ class CC_EXPORT OutputSurface : public FrameRateControllerClient { explicit OutputSurface(scoped_refptr<ContextProvider> context_provider); - explicit OutputSurface(scoped_ptr<cc::SoftwareOutputDevice> software_device); + explicit OutputSurface(scoped_ptr<SoftwareOutputDevice> software_device); OutputSurface(scoped_refptr<ContextProvider> context_provider, - scoped_ptr<cc::SoftwareOutputDevice> software_device); + scoped_ptr<SoftwareOutputDevice> software_device); virtual ~OutputSurface(); @@ -151,9 +151,9 @@ class CC_EXPORT OutputSurface : public FrameRateControllerClient { void PostSwapBuffersComplete(); - struct cc::OutputSurface::Capabilities capabilities_; + struct OutputSurface::Capabilities capabilities_; scoped_refptr<ContextProvider> context_provider_; - scoped_ptr<cc::SoftwareOutputDevice> software_device_; + scoped_ptr<SoftwareOutputDevice> software_device_; gfx::Size surface_size_; float device_scale_factor_; diff --git a/cc/output/output_surface_unittest.cc b/cc/output/output_surface_unittest.cc index 85d586a..551ec59 100644 --- a/cc/output/output_surface_unittest.cc +++ b/cc/output/output_surface_unittest.cc @@ -27,14 +27,13 @@ class TestOutputSurface : public OutputSurface { retroactive_begin_impl_frame_deadline_enabled_(false), override_retroactive_period_(false) {} - explicit TestOutputSurface( - scoped_ptr<cc::SoftwareOutputDevice> software_device) + explicit TestOutputSurface(scoped_ptr<SoftwareOutputDevice> software_device) : OutputSurface(software_device.Pass()), retroactive_begin_impl_frame_deadline_enabled_(false), override_retroactive_period_(false) {} TestOutputSurface(scoped_refptr<ContextProvider> context_provider, - scoped_ptr<cc::SoftwareOutputDevice> software_device) + scoped_ptr<SoftwareOutputDevice> software_device) : OutputSurface(context_provider, software_device.Pass()), retroactive_begin_impl_frame_deadline_enabled_(false), override_retroactive_period_(false) {} diff --git a/cc/output/renderer_pixeltest.cc b/cc/output/renderer_pixeltest.cc index 4aa0901..24c6126 100644 --- a/cc/output/renderer_pixeltest.cc +++ b/cc/output/renderer_pixeltest.cc @@ -455,7 +455,7 @@ class VideoGLRendererPixelTest : public GLRendererPixelTest { gfx::Vector2d()); } - scoped_ptr<YUVVideoDrawQuad> yuv_quad = cc::YUVVideoDrawQuad::Create(); + scoped_ptr<YUVVideoDrawQuad> yuv_quad = YUVVideoDrawQuad::Create(); yuv_quad->SetNew(shared_state, rect, opaque_rect, gfx::Size(), y_resource, u_resource, v_resource, a_resource); return yuv_quad.Pass(); diff --git a/cc/resources/managed_tile_state.h b/cc/resources/managed_tile_state.h index 587a09a..dc6f6d6 100644 --- a/cc/resources/managed_tile_state.h +++ b/cc/resources/managed_tile_state.h @@ -10,6 +10,7 @@ #include "cc/resources/raster_worker_pool.h" #include "cc/resources/resource_pool.h" #include "cc/resources/resource_provider.h" +#include "cc/resources/scoped_resource.h" namespace cc { @@ -111,7 +112,7 @@ class CC_EXPORT ManagedTileState { Mode mode_; SkColor solid_color_; bool has_text_; - scoped_ptr<ResourcePool::Resource> resource_; + scoped_ptr<ScopedResource> resource_; RasterWorkerPool::RasterTask raster_task_; }; diff --git a/cc/resources/prioritized_resource_unittest.cc b/cc/resources/prioritized_resource_unittest.cc index 84e687c..7619dcc 100644 --- a/cc/resources/prioritized_resource_unittest.cc +++ b/cc/resources/prioritized_resource_unittest.cc @@ -8,6 +8,7 @@ #include "cc/resources/prioritized_resource_manager.h" #include "cc/resources/resource.h" +#include "cc/resources/resource_provider.h" #include "cc/test/fake_output_surface.h" #include "cc/test/fake_output_surface_client.h" #include "cc/test/fake_proxy.h" @@ -56,7 +57,7 @@ class PrioritizedResourceTest : public testing::Test { impl_thread_and_main_thread_blocked(&proxy_); bool success = texture->can_acquire_backing_texture(); if (success) - texture->AcquireBackingTexture(ResourceProvider()); + texture->AcquireBackingTexture(resource_provider()); return success; } @@ -73,7 +74,7 @@ class PrioritizedResourceTest : public testing::Test { resource_manager->PushTexturePrioritiesToBackings(); } - cc::ResourceProvider* ResourceProvider() { return resource_provider_.get(); } + ResourceProvider* resource_provider() { return resource_provider_.get(); } void ResourceManagerAssertInvariants( PrioritizedResourceManager* resource_manager) { @@ -109,8 +110,8 @@ class PrioritizedResourceTest : public testing::Test { const gfx::Size texture_size_; const ResourceFormat texture_format_; FakeOutputSurfaceClient output_surface_client_; - scoped_ptr<cc::OutputSurface> output_surface_; - scoped_ptr<cc::ResourceProvider> resource_provider_; + scoped_ptr<OutputSurface> output_surface_; + scoped_ptr<ResourceProvider> resource_provider_; }; namespace { @@ -158,7 +159,7 @@ TEST_F(PrioritizedResourceTest, RequestTextureExceedingMaxLimit) { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ClearAllMemory(ResourceProvider()); + resource_manager->ClearAllMemory(resource_provider()); } TEST_F(PrioritizedResourceTest, ChangeMemoryLimits) { @@ -182,7 +183,7 @@ TEST_F(PrioritizedResourceTest, ChangeMemoryLimits) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ReduceMemory(ResourceProvider()); + resource_manager->ReduceMemory(resource_provider()); } EXPECT_EQ(TexturesMemorySize(8), resource_manager->MemoryAboveCutoffBytes()); @@ -197,7 +198,7 @@ TEST_F(PrioritizedResourceTest, ChangeMemoryLimits) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ReduceMemory(ResourceProvider()); + resource_manager->ReduceMemory(resource_provider()); } EXPECT_EQ(TexturesMemorySize(5), resource_manager->MemoryAboveCutoffBytes()); @@ -214,7 +215,7 @@ TEST_F(PrioritizedResourceTest, ChangeMemoryLimits) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ReduceMemory(ResourceProvider()); + resource_manager->ReduceMemory(resource_provider()); } EXPECT_EQ(TexturesMemorySize(4), resource_manager->MemoryAboveCutoffBytes()); @@ -225,7 +226,7 @@ TEST_F(PrioritizedResourceTest, ChangeMemoryLimits) { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ClearAllMemory(ResourceProvider()); + resource_manager->ClearAllMemory(resource_provider()); } TEST_F(PrioritizedResourceTest, ReduceWastedMemory) { @@ -263,7 +264,7 @@ TEST_F(PrioritizedResourceTest, ReduceWastedMemory) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ReduceMemory(ResourceProvider()); + resource_manager->ReduceMemory(resource_provider()); } // 20 textures have backings allocated. @@ -275,8 +276,8 @@ TEST_F(PrioritizedResourceTest, ReduceWastedMemory) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->UpdateBackingsState(ResourceProvider()); - resource_manager->ReduceWastedMemory(ResourceProvider()); + resource_manager->UpdateBackingsState(resource_provider()); + resource_manager->ReduceWastedMemory(resource_provider()); } EXPECT_EQ(TexturesMemorySize(20), resource_manager->MemoryUseBytes()); @@ -288,14 +289,14 @@ TEST_F(PrioritizedResourceTest, ReduceWastedMemory) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->UpdateBackingsState(ResourceProvider()); - resource_manager->ReduceWastedMemory(ResourceProvider()); + resource_manager->UpdateBackingsState(resource_provider()); + resource_manager->ReduceWastedMemory(resource_provider()); } EXPECT_GT(TexturesMemorySize(20), resource_manager->MemoryUseBytes()); DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ClearAllMemory(ResourceProvider()); + resource_manager->ClearAllMemory(resource_provider()); } TEST_F(PrioritizedResourceTest, InUseNotWastedMemory) { @@ -333,7 +334,7 @@ TEST_F(PrioritizedResourceTest, InUseNotWastedMemory) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ReduceMemory(ResourceProvider()); + resource_manager->ReduceMemory(resource_provider()); } // 20 textures have backings allocated. @@ -355,8 +356,8 @@ TEST_F(PrioritizedResourceTest, InUseNotWastedMemory) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->UpdateBackingsState(ResourceProvider()); - resource_manager->ReduceWastedMemory(ResourceProvider()); + resource_manager->UpdateBackingsState(resource_provider()); + resource_manager->ReduceWastedMemory(resource_provider()); } EXPECT_EQ(TexturesMemorySize(20), resource_manager->MemoryUseBytes()); @@ -368,14 +369,14 @@ TEST_F(PrioritizedResourceTest, InUseNotWastedMemory) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->UpdateBackingsState(ResourceProvider()); - resource_manager->ReduceWastedMemory(ResourceProvider()); + resource_manager->UpdateBackingsState(resource_provider()); + resource_manager->ReduceWastedMemory(resource_provider()); } EXPECT_GT(TexturesMemorySize(20), resource_manager->MemoryUseBytes()); DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ClearAllMemory(ResourceProvider()); + resource_manager->ClearAllMemory(resource_provider()); } TEST_F(PrioritizedResourceTest, ChangePriorityCutoff) { @@ -402,7 +403,7 @@ TEST_F(PrioritizedResourceTest, ChangePriorityCutoff) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ReduceMemory(ResourceProvider()); + resource_manager->ReduceMemory(resource_provider()); } EXPECT_EQ(TexturesMemorySize(6), resource_manager->MemoryAboveCutoffBytes()); EXPECT_LE(resource_manager->MemoryUseBytes(), @@ -416,7 +417,7 @@ TEST_F(PrioritizedResourceTest, ChangePriorityCutoff) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ReduceMemory(ResourceProvider()); + resource_manager->ReduceMemory(resource_provider()); } EXPECT_EQ(TexturesMemorySize(4), resource_manager->MemoryAboveCutoffBytes()); @@ -426,10 +427,10 @@ TEST_F(PrioritizedResourceTest, ChangePriorityCutoff) { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); resource_manager->ReduceMemoryOnImplThread( - TexturesMemorySize(8), 104, ResourceProvider()); + TexturesMemorySize(8), 104, resource_provider()); EXPECT_EQ(0u, EvictedBackingCount(resource_manager.get())); resource_manager->ReduceMemoryOnImplThread( - TexturesMemorySize(8), 103, ResourceProvider()); + TexturesMemorySize(8), 103, resource_provider()); EXPECT_EQ(1u, EvictedBackingCount(resource_manager.get())); } resource_manager->UnlinkAndClearEvictedBackings(); @@ -442,13 +443,13 @@ TEST_F(PrioritizedResourceTest, ChangePriorityCutoff) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ReduceMemory(ResourceProvider()); + resource_manager->ReduceMemory(resource_provider()); } EXPECT_EQ(TexturesMemorySize(4), resource_manager->MemoryAboveCutoffBytes()); DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ClearAllMemory(ResourceProvider()); + resource_manager->ClearAllMemory(resource_provider()); } TEST_F(PrioritizedResourceTest, EvictingTexturesInParent) { @@ -482,7 +483,7 @@ TEST_F(PrioritizedResourceTest, EvictingTexturesInParent) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ReduceMemory(ResourceProvider()); + resource_manager->ReduceMemory(resource_provider()); } EXPECT_EQ(TexturesMemorySize(8), resource_manager->MemoryAboveCutoffBytes()); @@ -494,7 +495,7 @@ TEST_F(PrioritizedResourceTest, EvictingTexturesInParent) { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); resource_manager->ReduceMemoryOnImplThread( - TexturesMemorySize(4), 200, ResourceProvider()); + TexturesMemorySize(4), 200, resource_provider()); EXPECT_EQ(4u, EvictedBackingCount(resource_manager.get())); @@ -535,7 +536,7 @@ TEST_F(PrioritizedResourceTest, EvictingTexturesInParent) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ReduceMemory(ResourceProvider()); + resource_manager->ReduceMemory(resource_provider()); } EXPECT_EQ(TexturesMemorySize(8), resource_manager->MemoryAboveCutoffBytes()); @@ -565,7 +566,7 @@ TEST_F(PrioritizedResourceTest, EvictingTexturesInParent) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->UpdateBackingsState(ResourceProvider()); + resource_manager->UpdateBackingsState(resource_provider()); } // Evict four textures. It would be the last four again, except that 2 of them @@ -574,7 +575,7 @@ TEST_F(PrioritizedResourceTest, EvictingTexturesInParent) { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); resource_manager->ReduceMemoryOnImplThread( - TexturesMemorySize(4), 200, ResourceProvider()); + TexturesMemorySize(4), 200, resource_provider()); EXPECT_EQ(4u, EvictedBackingCount(resource_manager.get())); // The last 2 backings remain this time. @@ -591,7 +592,7 @@ TEST_F(PrioritizedResourceTest, EvictingTexturesInParent) { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ClearAllMemory(ResourceProvider()); + resource_manager->ClearAllMemory(resource_provider()); } TEST_F(PrioritizedResourceTest, ResourceManagerPartialUpdateTextures) { @@ -654,7 +655,7 @@ TEST_F(PrioritizedResourceTest, ResourceManagerPartialUpdateTextures) { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ClearAllMemory(ResourceProvider()); + resource_manager->ClearAllMemory(resource_provider()); } TEST_F(PrioritizedResourceTest, ResourceManagerPrioritiesAreEqual) { @@ -699,7 +700,7 @@ TEST_F(PrioritizedResourceTest, ResourceManagerPrioritiesAreEqual) { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ClearAllMemory(ResourceProvider()); + resource_manager->ClearAllMemory(resource_provider()); } TEST_F(PrioritizedResourceTest, ResourceManagerDestroyedFirst) { @@ -719,7 +720,7 @@ TEST_F(PrioritizedResourceTest, ResourceManagerDestroyedFirst) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ClearAllMemory(ResourceProvider()); + resource_manager->ClearAllMemory(resource_provider()); } resource_manager.reset(); @@ -749,7 +750,7 @@ TEST_F(PrioritizedResourceTest, TextureMovedToNewManager) { { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager_one->ClearAllMemory(ResourceProvider()); + resource_manager_one->ClearAllMemory(resource_provider()); } resource_manager_one.reset(); @@ -766,7 +767,7 @@ TEST_F(PrioritizedResourceTest, TextureMovedToNewManager) { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager_two->ClearAllMemory(ResourceProvider()); + resource_manager_two->ClearAllMemory(resource_provider()); } TEST_F(PrioritizedResourceTest, @@ -823,7 +824,7 @@ TEST_F(PrioritizedResourceTest, DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ClearAllMemory(ResourceProvider()); + resource_manager->ClearAllMemory(resource_provider()); } TEST_F(PrioritizedResourceTest, @@ -871,7 +872,7 @@ TEST_F(PrioritizedResourceTest, DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ClearAllMemory(ResourceProvider()); + resource_manager->ClearAllMemory(resource_provider()); } TEST_F(PrioritizedResourceTest, @@ -923,7 +924,7 @@ TEST_F(PrioritizedResourceTest, DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ClearAllMemory(ResourceProvider()); + resource_manager->ClearAllMemory(resource_provider()); } TEST_F(PrioritizedResourceTest, RequestLateBackingsSorting) { @@ -975,7 +976,7 @@ TEST_F(PrioritizedResourceTest, RequestLateBackingsSorting) { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ClearAllMemory(ResourceProvider()); + resource_manager->ClearAllMemory(resource_provider()); } TEST_F(PrioritizedResourceTest, ClearUploadsToEvictedResources) { @@ -1017,12 +1018,12 @@ TEST_F(PrioritizedResourceTest, ClearUploadsToEvictedResources) { resource_manager->ReduceMemoryOnImplThread( TexturesMemorySize(1), PriorityCalculator::AllowEverythingCutoff(), - ResourceProvider()); + resource_provider()); queue.ClearUploadsToEvictedResources(); EXPECT_EQ(1u, queue.FullUploadSize()); resource_manager->ReduceMemoryOnImplThread( - 0, PriorityCalculator::AllowEverythingCutoff(), ResourceProvider()); + 0, PriorityCalculator::AllowEverythingCutoff(), resource_provider()); queue.ClearUploadsToEvictedResources(); EXPECT_EQ(0u, queue.FullUploadSize()); } @@ -1103,7 +1104,7 @@ TEST_F(PrioritizedResourceTest, UsageStatistics) { DebugScopedSetImplThreadAndMainThreadBlocked impl_thread_and_main_thread_blocked(&proxy_); - resource_manager->ClearAllMemory(ResourceProvider()); + resource_manager->ClearAllMemory(resource_provider()); } } // namespace diff --git a/cc/resources/raster_worker_pool_unittest.cc b/cc/resources/raster_worker_pool_unittest.cc index 255f41c..716edf6 100644 --- a/cc/resources/raster_worker_pool_unittest.cc +++ b/cc/resources/raster_worker_pool_unittest.cc @@ -159,7 +159,7 @@ class RasterWorkerPoolTest : public testing::Test, const gfx::Size size(1, 1); scoped_ptr<ScopedResource> resource( - ScopedResource::create(resource_provider())); + ScopedResource::Create(resource_provider())); resource->Allocate(size, ResourceProvider::TextureUsageAny, RGBA_8888); const Resource* const_resource = resource.get(); diff --git a/cc/resources/resource_pool.cc b/cc/resources/resource_pool.cc index 254837f..6abfd7c 100644 --- a/cc/resources/resource_pool.cc +++ b/cc/resources/resource_pool.cc @@ -5,31 +5,10 @@ #include "cc/resources/resource_pool.h" #include "cc/resources/resource_provider.h" +#include "cc/resources/scoped_resource.h" namespace cc { -ResourcePool::Resource::Resource(cc::ResourceProvider* resource_provider, - gfx::Size size, - GLenum target, - ResourceFormat format) - : cc::Resource(resource_provider->CreateManagedResource( - size, - target, - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - format), - size, - format), - resource_provider_(resource_provider) { - DCHECK(id()); -} - -ResourcePool::Resource::~Resource() { - DCHECK(id()); - DCHECK(resource_provider_); - resource_provider_->DeleteResource(id()); -} - ResourcePool::ResourcePool(ResourceProvider* resource_provider, GLenum target, ResourceFormat format) @@ -57,11 +36,10 @@ ResourcePool::~ResourcePool() { DCHECK_EQ(0u, resource_count_); } -scoped_ptr<ResourcePool::Resource> ResourcePool::AcquireResource( - gfx::Size size) { +scoped_ptr<ScopedResource> ResourcePool::AcquireResource(gfx::Size size) { for (ResourceList::iterator it = unused_resources_.begin(); it != unused_resources_.end(); ++it) { - Resource* resource = *it; + ScopedResource* resource = *it; DCHECK(resource_provider_->CanLockForWrite(resource->id())); if (resource->size() != size) @@ -73,8 +51,9 @@ scoped_ptr<ResourcePool::Resource> ResourcePool::AcquireResource( } // Create new resource. - Resource* resource = new Resource( - resource_provider_, size, target_, format_); + scoped_ptr<ScopedResource> resource = + ScopedResource::Create(resource_provider_); + resource->AllocateManaged(size, target_, format_); // Extend all read locks on all resources until the resource is // finished being used, such that we know when resources are @@ -83,11 +62,10 @@ scoped_ptr<ResourcePool::Resource> ResourcePool::AcquireResource( memory_usage_bytes_ += resource->bytes(); ++resource_count_; - return make_scoped_ptr(resource); + return resource.Pass(); } -void ResourcePool::ReleaseResource( - scoped_ptr<ResourcePool::Resource> resource) { +void ResourcePool::ReleaseResource(scoped_ptr<ScopedResource> resource) { busy_resources_.push_back(resource.release()); } @@ -114,7 +92,7 @@ void ResourcePool::ReduceResourceUsage() { // can't be locked for write might also not be truly free-able. // We can free the resource here but it doesn't mean that the // memory is necessarily returned to the OS. - Resource* resource = unused_resources_.front(); + ScopedResource* resource = unused_resources_.front(); unused_resources_.pop_front(); memory_usage_bytes_ -= resource->bytes(); unused_memory_usage_bytes_ -= resource->bytes(); @@ -137,7 +115,7 @@ void ResourcePool::CheckBusyResources() { ResourceList::iterator it = busy_resources_.begin(); while (it != busy_resources_.end()) { - Resource* resource = *it; + ScopedResource* resource = *it; if (resource_provider_->CanLockForWrite(resource->id())) { DidFinishUsingResource(resource); @@ -148,7 +126,7 @@ void ResourcePool::CheckBusyResources() { } } -void ResourcePool::DidFinishUsingResource(ResourcePool::Resource* resource) { +void ResourcePool::DidFinishUsingResource(ScopedResource* resource) { unused_memory_usage_bytes_ += resource->bytes(); unused_resources_.push_back(resource); } diff --git a/cc/resources/resource_pool.h b/cc/resources/resource_pool.h index 74175ed..3c6b23f 100644 --- a/cc/resources/resource_pool.h +++ b/cc/resources/resource_pool.h @@ -14,23 +14,10 @@ #include "cc/resources/resource_format.h" namespace cc { +class ScopedResource; class CC_EXPORT ResourcePool { public: - class CC_EXPORT Resource : public cc::Resource { - public: - Resource(ResourceProvider* resource_provider, - gfx::Size size, - GLenum target, - ResourceFormat format); - ~Resource(); - - private: - ResourceProvider* resource_provider_; - - DISALLOW_COPY_AND_ASSIGN(Resource); - }; - static scoped_ptr<ResourcePool> Create(ResourceProvider* resource_provider, GLenum target, ResourceFormat format) { @@ -41,8 +28,8 @@ class CC_EXPORT ResourcePool { virtual ~ResourcePool(); - scoped_ptr<ResourcePool::Resource> AcquireResource(gfx::Size size); - void ReleaseResource(scoped_ptr<ResourcePool::Resource>); + scoped_ptr<ScopedResource> AcquireResource(gfx::Size size); + void ReleaseResource(scoped_ptr<ScopedResource>); void SetResourceUsageLimits(size_t max_memory_usage_bytes, size_t max_unused_memory_usage_bytes, @@ -69,7 +56,7 @@ class CC_EXPORT ResourcePool { bool ResourceUsageTooHigh(); private: - void DidFinishUsingResource(ResourcePool::Resource* resource); + void DidFinishUsingResource(ScopedResource* resource); ResourceProvider* resource_provider_; const GLenum target_; @@ -81,7 +68,7 @@ class CC_EXPORT ResourcePool { size_t unused_memory_usage_bytes_; size_t resource_count_; - typedef std::list<Resource*> ResourceList; + typedef std::list<ScopedResource*> ResourceList; ResourceList unused_resources_; ResourceList busy_resources_; diff --git a/cc/resources/scoped_resource.cc b/cc/resources/scoped_resource.cc index 5fcaaca..99f93c9 100644 --- a/cc/resources/scoped_resource.cc +++ b/cc/resources/scoped_resource.cc @@ -15,7 +15,7 @@ ScopedResource::~ScopedResource() { Free(); } -bool ScopedResource::Allocate(gfx::Size size, +void ScopedResource::Allocate(gfx::Size size, ResourceProvider::TextureUsageHint hint, ResourceFormat format) { DCHECK(!id()); @@ -28,8 +28,25 @@ bool ScopedResource::Allocate(gfx::Size size, #ifndef NDEBUG allocate_thread_id_ = base::PlatformThread::CurrentId(); #endif +} - return id() != 0; +void ScopedResource::AllocateManaged(gfx::Size size, + GLenum target, + ResourceFormat format) { + DCHECK(!id()); + DCHECK(!size.IsEmpty()); + + set_dimensions(size, format); + set_id(resource_provider_->CreateManagedResource( + size, + target, + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureUsageAny, + format)); + +#ifndef NDEBUG + allocate_thread_id_ = base::PlatformThread::CurrentId(); +#endif } void ScopedResource::Free() { diff --git a/cc/resources/scoped_resource.h b/cc/resources/scoped_resource.h index 8e316eb..63f2cd4 100644 --- a/cc/resources/scoped_resource.h +++ b/cc/resources/scoped_resource.h @@ -19,15 +19,16 @@ namespace cc { class CC_EXPORT ScopedResource : public Resource { public: - static scoped_ptr<ScopedResource> create( + static scoped_ptr<ScopedResource> Create( ResourceProvider* resource_provider) { return make_scoped_ptr(new ScopedResource(resource_provider)); } virtual ~ScopedResource(); - bool Allocate(gfx::Size size, + void Allocate(gfx::Size size, ResourceProvider::TextureUsageHint hint, - ResourceFormat texture_format); + ResourceFormat format); + void AllocateManaged(gfx::Size size, GLenum target, ResourceFormat format); void Free(); void Leak(); diff --git a/cc/resources/scoped_resource_unittest.cc b/cc/resources/scoped_resource_unittest.cc index a68e60e..93ad320 100644 --- a/cc/resources/scoped_resource_unittest.cc +++ b/cc/resources/scoped_resource_unittest.cc @@ -21,7 +21,7 @@ TEST(ScopedResourceTest, NewScopedResource) { scoped_ptr<ResourceProvider> resource_provider( ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); scoped_ptr<ScopedResource> texture = - ScopedResource::create(resource_provider.get()); + ScopedResource::Create(resource_provider.get()); // New scoped textures do not hold a texture yet. EXPECT_EQ(0u, texture->id()); @@ -39,7 +39,7 @@ TEST(ScopedResourceTest, CreateScopedResource) { scoped_ptr<ResourceProvider> resource_provider( ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); scoped_ptr<ScopedResource> texture = - ScopedResource::create(resource_provider.get()); + ScopedResource::Create(resource_provider.get()); texture->Allocate(gfx::Size(30, 30), ResourceProvider::TextureUsageAny, RGBA_8888); @@ -62,7 +62,7 @@ TEST(ScopedResourceTest, ScopedResourceIsDeleted) { ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); { scoped_ptr<ScopedResource> texture = - ScopedResource::create(resource_provider.get()); + ScopedResource::Create(resource_provider.get()); EXPECT_EQ(0u, resource_provider->num_resources()); texture->Allocate(gfx::Size(30, 30), @@ -75,7 +75,7 @@ TEST(ScopedResourceTest, ScopedResourceIsDeleted) { EXPECT_EQ(0u, resource_provider->num_resources()); { scoped_ptr<ScopedResource> texture = - ScopedResource::create(resource_provider.get()); + ScopedResource::Create(resource_provider.get()); EXPECT_EQ(0u, resource_provider->num_resources()); texture->Allocate(gfx::Size(30, 30), ResourceProvider::TextureUsageAny, @@ -96,7 +96,7 @@ TEST(ScopedResourceTest, LeakScopedResource) { ResourceProvider::Create(output_surface.get(), NULL, 0, false, 1)); { scoped_ptr<ScopedResource> texture = - ScopedResource::create(resource_provider.get()); + ScopedResource::Create(resource_provider.get()); EXPECT_EQ(0u, resource_provider->num_resources()); texture->Allocate(gfx::Size(30, 30), diff --git a/cc/resources/tile_manager.cc b/cc/resources/tile_manager.cc index f8d897b..17f4525 100644 --- a/cc/resources/tile_manager.cc +++ b/cc/resources/tile_manager.cc @@ -872,9 +872,9 @@ RasterWorkerPool::Task TileManager::CreateImageDecodeTask( RasterWorkerPool::RasterTask TileManager::CreateRasterTask(Tile* tile) { ManagedTileState& mts = tile->managed_state(); - scoped_ptr<ResourcePool::Resource> resource = + scoped_ptr<ScopedResource> resource = resource_pool_->AcquireResource(tile->tile_size_.size()); - const Resource* const_resource = resource.get(); + const ScopedResource* const_resource = resource.get(); // Create and queue all image decode tasks that this tile depends on. RasterWorkerPool::Task::Set decode_tasks; @@ -944,7 +944,7 @@ void TileManager::OnImageDecodeTaskCompleted( void TileManager::OnRasterTaskCompleted( Tile::Id tile_id, - scoped_ptr<ResourcePool::Resource> resource, + scoped_ptr<ScopedResource> resource, RasterMode raster_mode, const PicturePileImpl::Analysis& analysis, bool was_canceled) { diff --git a/cc/resources/tile_manager.h b/cc/resources/tile_manager.h index e708cdf..98a66f8 100644 --- a/cc/resources/tile_manager.h +++ b/cc/resources/tile_manager.h @@ -169,12 +169,11 @@ class CC_EXPORT TileManager : public RasterWorkerPoolClient, int layer_id, skia::LazyPixelRef* pixel_ref, bool was_canceled); - void OnRasterTaskCompleted( - Tile::Id tile, - scoped_ptr<ResourcePool::Resource> resource, - RasterMode raster_mode, - const PicturePileImpl::Analysis& analysis, - bool was_canceled); + void OnRasterTaskCompleted(Tile::Id tile, + scoped_ptr<ScopedResource> resource, + RasterMode raster_mode, + const PicturePileImpl::Analysis& analysis, + bool was_canceled); inline size_t BytesConsumedIfAllocated(const Tile* tile) const { return Resource::MemorySizeBytes(tile->size(), diff --git a/cc/scheduler/frame_rate_controller_unittest.cc b/cc/scheduler/frame_rate_controller_unittest.cc index ea5f52f..e7d7580 100644 --- a/cc/scheduler/frame_rate_controller_unittest.cc +++ b/cc/scheduler/frame_rate_controller_unittest.cc @@ -11,7 +11,7 @@ namespace cc { namespace { -class FakeFrameRateControllerClient : public cc::FrameRateControllerClient { +class FakeFrameRateControllerClient : public FrameRateControllerClient { public: FakeFrameRateControllerClient() { Reset(); } diff --git a/cc/scheduler/scheduler_unittest.cc b/cc/scheduler/scheduler_unittest.cc index 2b35731..6f5eb2c 100644 --- a/cc/scheduler/scheduler_unittest.cc +++ b/cc/scheduler/scheduler_unittest.cc @@ -1273,7 +1273,7 @@ TEST(SchedulerTest, PollForCommitCompletion) { // Does three iterations to make sure that the timer is properly repeating. for (int i = 0; i < 3; ++i) { // Wait for 2x the frame interval to match - // cc::Scheduler::advance_commit_state_timer_'s rate. + // Scheduler::advance_commit_state_timer_'s rate. SpinForMillis(interval * 2); EXPECT_GT(client.num_actions_(), actions_so_far); EXPECT_STREQ(client.Action(client.num_actions_() - 1), diff --git a/cc/test/animation_test_common.cc b/cc/test/animation_test_common.cc index e6c6773..01e33bb 100644 --- a/cc/test/animation_test_common.cc +++ b/cc/test/animation_test_common.cc @@ -36,9 +36,8 @@ int AddOpacityTransition(Target* target, func = EaseTimingFunction::Create(); if (duration > 0.0) curve->AddKeyframe(FloatKeyframe::Create(0.0, start_opacity, func.Pass())); - curve->AddKeyframe(FloatKeyframe::Create(duration, - end_opacity, - scoped_ptr<cc::TimingFunction>())); + curve->AddKeyframe(FloatKeyframe::Create( + duration, end_opacity, scoped_ptr<TimingFunction>())); int id = AnimationIdProvider::NextAnimationId(); @@ -65,17 +64,13 @@ int AddAnimatedTransform(Target* target, TransformOperations start_operations; start_operations.AppendTranslate(delta_x, delta_y, 0.0); curve->AddKeyframe(TransformKeyframe::Create( - 0.0, - start_operations, - scoped_ptr<cc::TimingFunction>())); + 0.0, start_operations, scoped_ptr<TimingFunction>())); } TransformOperations operations; operations.AppendTranslate(delta_x, delta_y, 0.0); curve->AddKeyframe(TransformKeyframe::Create( - duration, - operations, - scoped_ptr<cc::TimingFunction>())); + duration, operations, scoped_ptr<TimingFunction>())); int id = AnimationIdProvider::NextAnimationId(); @@ -103,13 +98,13 @@ int AddAnimatedFilter(Target* target, start_filters.Append( FilterOperation::CreateBrightnessFilter(start_brightness)); curve->AddKeyframe(FilterKeyframe::Create( - 0.0, start_filters, scoped_ptr<cc::TimingFunction>())); + 0.0, start_filters, scoped_ptr<TimingFunction>())); } FilterOperations filters; filters.Append(FilterOperation::CreateBrightnessFilter(end_brightness)); - curve->AddKeyframe(FilterKeyframe::Create( - duration, filters, scoped_ptr<cc::TimingFunction>())); + curve->AddKeyframe( + FilterKeyframe::Create(duration, filters, scoped_ptr<TimingFunction>())); int id = AnimationIdProvider::NextAnimationId(); @@ -140,9 +135,8 @@ float FakeFloatAnimationCurve::GetValue(double now) const { return 0.0f; } -scoped_ptr<cc::AnimationCurve> FakeFloatAnimationCurve::Clone() const { - return make_scoped_ptr( - new FakeFloatAnimationCurve).PassAs<cc::AnimationCurve>(); +scoped_ptr<AnimationCurve> FakeFloatAnimationCurve::Clone() const { + return make_scoped_ptr(new FakeFloatAnimationCurve).PassAs<AnimationCurve>(); } FakeTransformTransition::FakeTransformTransition(double duration) @@ -163,9 +157,9 @@ bool FakeTransformTransition::AnimatedBoundsForBox(const gfx::BoxF& box, return false; } -scoped_ptr<cc::AnimationCurve> FakeTransformTransition::Clone() const { - return make_scoped_ptr( - new FakeTransformTransition(*this)).PassAs<cc::AnimationCurve>(); +scoped_ptr<AnimationCurve> FakeTransformTransition::Clone() const { + return make_scoped_ptr(new FakeTransformTransition(*this)) + .PassAs<AnimationCurve>(); } @@ -227,12 +221,12 @@ gfx::Vector2dF FakeLayerAnimationValueProvider::ScrollOffsetForAnimation() return scroll_offset_; } -scoped_ptr<cc::AnimationCurve> FakeFloatTransition::Clone() const { - return make_scoped_ptr( - new FakeFloatTransition(*this)).PassAs<cc::AnimationCurve>(); +scoped_ptr<AnimationCurve> FakeFloatTransition::Clone() const { + return make_scoped_ptr(new FakeFloatTransition(*this)) + .PassAs<AnimationCurve>(); } -int AddOpacityTransitionToController(cc::LayerAnimationController* controller, +int AddOpacityTransitionToController(LayerAnimationController* controller, double duration, float start_opacity, float end_opacity, @@ -244,7 +238,7 @@ int AddOpacityTransitionToController(cc::LayerAnimationController* controller, use_timing_function); } -int AddAnimatedTransformToController(cc::LayerAnimationController* controller, +int AddAnimatedTransformToController(LayerAnimationController* controller, double duration, int delta_x, int delta_y) { @@ -254,7 +248,7 @@ int AddAnimatedTransformToController(cc::LayerAnimationController* controller, delta_y); } -int AddAnimatedFilterToController(cc::LayerAnimationController* controller, +int AddAnimatedFilterToController(LayerAnimationController* controller, double duration, float start_brightness, float end_brightness) { @@ -262,7 +256,7 @@ int AddAnimatedFilterToController(cc::LayerAnimationController* controller, controller, duration, start_brightness, end_brightness); } -int AddOpacityTransitionToLayer(cc::Layer* layer, +int AddOpacityTransitionToLayer(Layer* layer, double duration, float start_opacity, float end_opacity, @@ -274,7 +268,7 @@ int AddOpacityTransitionToLayer(cc::Layer* layer, use_timing_function); } -int AddOpacityTransitionToLayer(cc::LayerImpl* layer, +int AddOpacityTransitionToLayer(LayerImpl* layer, double duration, float start_opacity, float end_opacity, @@ -286,14 +280,14 @@ int AddOpacityTransitionToLayer(cc::LayerImpl* layer, use_timing_function); } -int AddAnimatedTransformToLayer(cc::Layer* layer, +int AddAnimatedTransformToLayer(Layer* layer, double duration, int delta_x, int delta_y) { return AddAnimatedTransform(layer, duration, delta_x, delta_y); } -int AddAnimatedTransformToLayer(cc::LayerImpl* layer, +int AddAnimatedTransformToLayer(LayerImpl* layer, double duration, int delta_x, int delta_y) { @@ -303,14 +297,14 @@ int AddAnimatedTransformToLayer(cc::LayerImpl* layer, delta_y); } -int AddAnimatedFilterToLayer(cc::Layer* layer, +int AddAnimatedFilterToLayer(Layer* layer, double duration, float start_brightness, float end_brightness) { return AddAnimatedFilter(layer, duration, start_brightness, end_brightness); } -int AddAnimatedFilterToLayer(cc::LayerImpl* layer, +int AddAnimatedFilterToLayer(LayerImpl* layer, double duration, float start_brightness, float end_brightness) { diff --git a/cc/test/cc_test_suite.cc b/cc/test/cc_test_suite.cc index 4fa6565..8b3228a 100644 --- a/cc/test/cc_test_suite.cc +++ b/cc/test/cc_test_suite.cc @@ -21,7 +21,7 @@ CCTestSuite::~CCTestSuite() {} void CCTestSuite::Initialize() { base::TestSuite::Initialize(); - RegisterPathProvider(); + CCPaths::RegisterPathProvider(); message_loop_.reset(new base::MessageLoop); diff --git a/cc/test/fake_content_layer_client.h b/cc/test/fake_content_layer_client.h index 6afa5b6..fbbebd8 100644 --- a/cc/test/fake_content_layer_client.h +++ b/cc/test/fake_content_layer_client.h @@ -16,7 +16,7 @@ namespace cc { -class FakeContentLayerClient : public cc::ContentLayerClient { +class FakeContentLayerClient : public ContentLayerClient { public: struct BitmapData { SkBitmap bitmap; diff --git a/cc/test/fake_output_surface.cc b/cc/test/fake_output_surface.cc index a2d67f7..e72253c 100644 --- a/cc/test/fake_output_surface.cc +++ b/cc/test/fake_output_surface.cc @@ -144,7 +144,7 @@ bool FakeOutputSurface::HasExternalStencilTest() const { } void FakeOutputSurface::SetMemoryPolicyToSetAtBind( - scoped_ptr<cc::ManagedMemoryPolicy> memory_policy_to_set_at_bind) { + scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind) { memory_policy_to_set_at_bind_.swap(memory_policy_to_set_at_bind); } diff --git a/cc/test/fake_output_surface.h b/cc/test/fake_output_surface.h index 0a85f4d..c458dc6 100644 --- a/cc/test/fake_output_surface.h +++ b/cc/test/fake_output_surface.h @@ -124,7 +124,7 @@ class FakeOutputSurface : public OutputSurface { } void SetMemoryPolicyToSetAtBind( - scoped_ptr<cc::ManagedMemoryPolicy> memory_policy_to_set_at_bind); + scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind); protected: FakeOutputSurface( @@ -150,7 +150,7 @@ class FakeOutputSurface : public OutputSurface { bool has_external_stencil_test_; TransferableResourceArray resources_held_by_parent_; base::WeakPtrFactory<FakeOutputSurface> fake_weak_ptr_factory_; - scoped_ptr<cc::ManagedMemoryPolicy> memory_policy_to_set_at_bind_; + scoped_ptr<ManagedMemoryPolicy> memory_policy_to_set_at_bind_; }; static inline scoped_ptr<OutputSurface> CreateFakeOutputSurface() { diff --git a/cc/test/geometry_test_utils.h b/cc/test/geometry_test_utils.h index 12ca18d..d8829e0 100644 --- a/cc/test/geometry_test_utils.h +++ b/cc/test/geometry_test_utils.h @@ -84,10 +84,10 @@ void ExpectTransformationMatrixEq(const gfx::Transform& expected, const gfx::Transform& actual); #define EXPECT_TRANSFORMATION_MATRIX_EQ(expected, actual) \ -do { \ - SCOPED_TRACE(""); \ - cc::ExpectTransformationMatrixEq(expected, actual); \ -} while (false) + do { \ + SCOPED_TRACE(""); \ + ExpectTransformationMatrixEq(expected, actual); \ + } while (false) // Should be used in test code only, for convenience. Production code should use // the gfx::Transform::GetInverse() API. diff --git a/cc/test/layer_test_common.cc b/cc/test/layer_test_common.cc index fcd09d4..3ccd0a4 100644 --- a/cc/test/layer_test_common.cc +++ b/cc/test/layer_test_common.cc @@ -32,15 +32,14 @@ static bool CanRectFBeSafelyRoundedToRect(gfx::RectF r) { return false; } -void LayerTestCommon::VerifyQuadsExactlyCoverRect(const cc::QuadList& quads, +void LayerTestCommon::VerifyQuadsExactlyCoverRect(const QuadList& quads, gfx::Rect rect) { - cc::Region remaining = rect; + Region remaining = rect; for (size_t i = 0; i < quads.size(); ++i) { - cc::DrawQuad* quad = quads[i]; + DrawQuad* quad = quads[i]; gfx::RectF quad_rectf = - cc::MathUtil::MapClippedRect(quad->quadTransform(), - gfx::RectF(quad->rect)); + MathUtil::MapClippedRect(quad->quadTransform(), gfx::RectF(quad->rect)); // Before testing for exact coverage in the integer world, assert that // rounding will not round the rect incorrectly. diff --git a/cc/test/layer_test_common.h b/cc/test/layer_test_common.h index 0021398..cc7a18e 100644 --- a/cc/test/layer_test_common.h +++ b/cc/test/layer_test_common.h @@ -28,7 +28,7 @@ class LayerTestCommon { public: static const char* quad_string; - static void VerifyQuadsExactlyCoverRect(const cc::QuadList& quads, + static void VerifyQuadsExactlyCoverRect(const QuadList& quads, gfx::Rect rect); }; diff --git a/cc/test/layer_tree_json_parser.cc b/cc/test/layer_tree_json_parser.cc index 9a1b198..d120067 100644 --- a/cc/test/layer_tree_json_parser.cc +++ b/cc/test/layer_tree_json_parser.cc @@ -110,7 +110,7 @@ scoped_refptr<Layer> ParseTreeFromValue(base::Value* val, if (dict->HasKey("TouchRegion")) { success &= dict->GetList("TouchRegion", &list); - cc::Region touch_region; + Region touch_region; for (size_t i = 0; i < list->GetSize(); ) { int rect_x, rect_y, rect_width, rect_height; success &= list->GetInteger(i++, &rect_x); diff --git a/cc/test/layer_tree_json_parser_unittest.cc b/cc/test/layer_tree_json_parser_unittest.cc index 4261a71..3fd6725 100644 --- a/cc/test/layer_tree_json_parser_unittest.cc +++ b/cc/test/layer_tree_json_parser_unittest.cc @@ -99,7 +99,7 @@ TEST_F(LayerTreeJsonParserSanityCheck, EventHandlerRegions) { root_impl->SetBounds(gfx::Size(100, 100)); touch_layer->SetBounds(gfx::Size(50, 50)); - cc::Region touch_region; + Region touch_region; touch_region.Union(gfx::Rect(10, 10, 20, 30)); touch_region.Union(gfx::Rect(40, 10, 20, 20)); touch_layer->SetTouchEventHandlerRegion(touch_region); diff --git a/cc/test/layer_tree_pixel_test.cc b/cc/test/layer_tree_pixel_test.cc index 5388cba..e41a038 100644 --- a/cc/test/layer_tree_pixel_test.cc +++ b/cc/test/layer_tree_pixel_test.cc @@ -65,8 +65,7 @@ scoped_ptr<OutputSurface> LayerTreePixelTest::CreateOutputSurface( return output_surface.PassAs<OutputSurface>(); } -scoped_refptr<cc::ContextProvider> -LayerTreePixelTest::OffscreenContextProvider() { +scoped_refptr<ContextProvider> LayerTreePixelTest::OffscreenContextProvider() { scoped_refptr<webkit::gpu::ContextProviderInProcess> provider = webkit::gpu::ContextProviderInProcess::CreateOffscreen(); CHECK(provider.get()); @@ -108,7 +107,7 @@ void LayerTreePixelTest::BeginTest() { void LayerTreePixelTest::AfterTest() { base::FilePath test_data_dir; - EXPECT_TRUE(PathService::Get(cc::DIR_TEST_DATA, &test_data_dir)); + EXPECT_TRUE(PathService::Get(CCPaths::DIR_TEST_DATA, &test_data_dir)); base::FilePath ref_file_path = test_data_dir.Append(ref_file_); CommandLine* cmd = CommandLine::ForCurrentProcess(); diff --git a/cc/test/paths.cc b/cc/test/paths.cc index a54d551..f3ede27 100644 --- a/cc/test/paths.cc +++ b/cc/test/paths.cc @@ -16,7 +16,7 @@ bool PathProvider(int key, base::FilePath* result) { // The following are only valid in the development environment, and // will fail if executed from an installed executable (because the // generated path won't exist). - case DIR_TEST_DATA: + case CCPaths::DIR_TEST_DATA: if (!PathService::Get(base::DIR_SOURCE_ROOT, &cur)) return false; cur = cur.Append(FILE_PATH_LITERAL("cc")); @@ -35,7 +35,7 @@ bool PathProvider(int key, base::FilePath* result) { // This cannot be done as a static initializer sadly since Visual Studio will // eliminate this object file if there is no direct entry point into it. -void RegisterPathProvider() { +void CCPaths::RegisterPathProvider() { PathService::RegisterProvider(PathProvider, PATH_START, PATH_END); } diff --git a/cc/test/paths.h b/cc/test/paths.h index 07b7a64..f48177e 100644 --- a/cc/test/paths.h +++ b/cc/test/paths.h @@ -7,18 +7,20 @@ namespace cc { -enum { - PATH_START = 5000, - - // Valid only in development and testing environments. - DIR_TEST_DATA, - - PATH_END +class CCPaths { + public: + enum { + PATH_START = 5000, + + // Valid only in development and testing environments. + DIR_TEST_DATA, + PATH_END + }; + + // Call once to register the provider for the path keys defined above. + static void RegisterPathProvider(); }; -// Call once to register the provider for the path keys defined above. -void RegisterPathProvider(); - } // namespace cc #endif // CC_TEST_PATHS_H_ diff --git a/cc/test/pixel_test.cc b/cc/test/pixel_test.cc index 414a325..78cdd69 100644 --- a/cc/test/pixel_test.cc +++ b/cc/test/pixel_test.cc @@ -104,7 +104,7 @@ void PixelTest::ReadbackResult(base::Closure quit_run_loop, bool PixelTest::PixelsMatchReference(const base::FilePath& ref_file, const PixelComparator& comparator) { base::FilePath test_data_dir; - if (!PathService::Get(cc::DIR_TEST_DATA, &test_data_dir)) + if (!PathService::Get(CCPaths::DIR_TEST_DATA, &test_data_dir)) return false; // If this is false, we didn't set up a readback on a render pass. diff --git a/cc/test/pixel_test_output_surface.cc b/cc/test/pixel_test_output_surface.cc index 1ea89e2..e3f62bd 100644 --- a/cc/test/pixel_test_output_surface.cc +++ b/cc/test/pixel_test_output_surface.cc @@ -14,7 +14,7 @@ PixelTestOutputSurface::PixelTestOutputSurface( : OutputSurface(context_provider), external_stencil_test_(false) {} PixelTestOutputSurface::PixelTestOutputSurface( - scoped_ptr<cc::SoftwareOutputDevice> software_device) + scoped_ptr<SoftwareOutputDevice> software_device) : OutputSurface(software_device.Pass()), external_stencil_test_(false) {} void PixelTestOutputSurface::Reshape(gfx::Size size, float scale_factor) { diff --git a/cc/test/pixel_test_output_surface.h b/cc/test/pixel_test_output_surface.h index 2aca4f2..2a4573a 100644 --- a/cc/test/pixel_test_output_surface.h +++ b/cc/test/pixel_test_output_surface.h @@ -14,7 +14,7 @@ class PixelTestOutputSurface : public OutputSurface { explicit PixelTestOutputSurface( scoped_refptr<ContextProvider> context_provider); explicit PixelTestOutputSurface( - scoped_ptr<cc::SoftwareOutputDevice> software_device); + scoped_ptr<SoftwareOutputDevice> software_device); virtual void Reshape(gfx::Size size, float scale_factor) OVERRIDE; virtual bool HasExternalStencilTest() const OVERRIDE; diff --git a/cc/test/render_pass_test_common.cc b/cc/test/render_pass_test_common.cc index 4b69a7e..72467dd 100644 --- a/cc/test/render_pass_test_common.cc +++ b/cc/test/render_pass_test_common.cc @@ -19,12 +19,11 @@ namespace cc { -void TestRenderPass::AppendQuad(scoped_ptr<cc::DrawQuad> quad) { +void TestRenderPass::AppendQuad(scoped_ptr<DrawQuad> quad) { quad_list.push_back(quad.Pass()); } -void TestRenderPass::AppendSharedQuadState( - scoped_ptr<cc::SharedQuadState> state) { +void TestRenderPass::AppendSharedQuadState(scoped_ptr<SharedQuadState> state) { shared_quad_state_list.push_back(state.Pass()); } @@ -34,57 +33,50 @@ void TestRenderPass::AppendOneOfEveryQuadType( gfx::Rect rect(0, 0, 100, 100); gfx::Rect opaque_rect(10, 10, 80, 80); const float vertex_opacity[] = {1.0f, 1.0f, 1.0f, 1.0f}; - cc::ResourceProvider::ResourceId resource1 = - resource_provider->CreateResource( - gfx::Size(45, 5), - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - resource_provider->best_texture_format()); + ResourceProvider::ResourceId resource1 = resource_provider->CreateResource( + gfx::Size(45, 5), + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureUsageAny, + resource_provider->best_texture_format()); resource_provider->AllocateForTesting(resource1); - cc::ResourceProvider::ResourceId resource2 = - resource_provider->CreateResource( - gfx::Size(346, 61), - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - resource_provider->best_texture_format()); + ResourceProvider::ResourceId resource2 = resource_provider->CreateResource( + gfx::Size(346, 61), + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureUsageAny, + resource_provider->best_texture_format()); resource_provider->AllocateForTesting(resource2); - cc::ResourceProvider::ResourceId resource3 = - resource_provider->CreateResource( - gfx::Size(12, 134), - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - resource_provider->best_texture_format()); + ResourceProvider::ResourceId resource3 = resource_provider->CreateResource( + gfx::Size(12, 134), + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureUsageAny, + resource_provider->best_texture_format()); resource_provider->AllocateForTesting(resource3); - cc::ResourceProvider::ResourceId resource4 = - resource_provider->CreateResource( - gfx::Size(56, 12), - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - resource_provider->best_texture_format()); + ResourceProvider::ResourceId resource4 = resource_provider->CreateResource( + gfx::Size(56, 12), + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureUsageAny, + resource_provider->best_texture_format()); resource_provider->AllocateForTesting(resource4); - cc::ResourceProvider::ResourceId resource5 = - resource_provider->CreateResource( - gfx::Size(73, 26), - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - resource_provider->best_texture_format()); + ResourceProvider::ResourceId resource5 = resource_provider->CreateResource( + gfx::Size(73, 26), + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureUsageAny, + resource_provider->best_texture_format()); resource_provider->AllocateForTesting(resource5); - cc::ResourceProvider::ResourceId resource6 = - resource_provider->CreateResource( - gfx::Size(64, 92), - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - resource_provider->best_texture_format()); + ResourceProvider::ResourceId resource6 = resource_provider->CreateResource( + gfx::Size(64, 92), + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureUsageAny, + resource_provider->best_texture_format()); resource_provider->AllocateForTesting(resource6); - cc::ResourceProvider::ResourceId resource7 = - resource_provider->CreateResource( - gfx::Size(9, 14), - GL_CLAMP_TO_EDGE, - ResourceProvider::TextureUsageAny, - resource_provider->best_texture_format()); + ResourceProvider::ResourceId resource7 = resource_provider->CreateResource( + gfx::Size(9, 14), + GL_CLAMP_TO_EDGE, + ResourceProvider::TextureUsageAny, + resource_provider->best_texture_format()); resource_provider->AllocateForTesting(resource7); - scoped_ptr<cc::SharedQuadState> shared_state = cc::SharedQuadState::Create(); + scoped_ptr<SharedQuadState> shared_state = SharedQuadState::Create(); shared_state->SetAll(gfx::Transform(), rect.size(), rect, @@ -93,34 +85,33 @@ void TestRenderPass::AppendOneOfEveryQuadType( 1, SkXfermode::kSrcOver_Mode); - scoped_ptr<cc::CheckerboardDrawQuad> checkerboard_quad = - cc::CheckerboardDrawQuad::Create(); + scoped_ptr<CheckerboardDrawQuad> checkerboard_quad = + CheckerboardDrawQuad::Create(); checkerboard_quad->SetNew(shared_state.get(), rect, SK_ColorRED); AppendQuad(checkerboard_quad.PassAs<DrawQuad>()); - scoped_ptr<cc::DebugBorderDrawQuad> debug_border_quad = - cc::DebugBorderDrawQuad::Create(); + scoped_ptr<DebugBorderDrawQuad> debug_border_quad = + DebugBorderDrawQuad::Create(); debug_border_quad->SetNew(shared_state.get(), rect, SK_ColorRED, 1); AppendQuad(debug_border_quad.PassAs<DrawQuad>()); - scoped_ptr<cc::IOSurfaceDrawQuad> io_surface_quad = - cc::IOSurfaceDrawQuad::Create(); + scoped_ptr<IOSurfaceDrawQuad> io_surface_quad = IOSurfaceDrawQuad::Create(); io_surface_quad->SetNew(shared_state.get(), rect, opaque_rect, gfx::Size(50, 50), resource7, - cc::IOSurfaceDrawQuad::FLIPPED); + IOSurfaceDrawQuad::FLIPPED); AppendQuad(io_surface_quad.PassAs<DrawQuad>()); if (child_pass.layer_id) { - scoped_ptr<cc::RenderPassDrawQuad> render_pass_quad = - cc::RenderPassDrawQuad::Create(); + scoped_ptr<RenderPassDrawQuad> render_pass_quad = + RenderPassDrawQuad::Create(); render_pass_quad->SetNew(shared_state.get(), rect, child_pass, @@ -132,8 +123,8 @@ void TestRenderPass::AppendOneOfEveryQuadType( FilterOperations()); AppendQuad(render_pass_quad.PassAs<DrawQuad>()); - scoped_ptr<cc::RenderPassDrawQuad> render_pass_replica_quad = - cc::RenderPassDrawQuad::Create(); + scoped_ptr<RenderPassDrawQuad> render_pass_replica_quad = + RenderPassDrawQuad::Create(); render_pass_replica_quad->SetNew(shared_state.get(), rect, child_pass, @@ -146,16 +137,16 @@ void TestRenderPass::AppendOneOfEveryQuadType( AppendQuad(render_pass_replica_quad.PassAs<DrawQuad>()); } - scoped_ptr<cc::SolidColorDrawQuad> solid_color_quad = - cc::SolidColorDrawQuad::Create(); + scoped_ptr<SolidColorDrawQuad> solid_color_quad = + SolidColorDrawQuad::Create(); solid_color_quad->SetNew(shared_state.get(), rect, SK_ColorRED, false); AppendQuad(solid_color_quad.PassAs<DrawQuad>()); - scoped_ptr<cc::StreamVideoDrawQuad> stream_video_quad = - cc::StreamVideoDrawQuad::Create(); + scoped_ptr<StreamVideoDrawQuad> stream_video_quad = + StreamVideoDrawQuad::Create(); stream_video_quad->SetNew(shared_state.get(), rect, opaque_rect, @@ -163,8 +154,7 @@ void TestRenderPass::AppendOneOfEveryQuadType( gfx::Transform()); AppendQuad(stream_video_quad.PassAs<DrawQuad>()); - scoped_ptr<cc::TextureDrawQuad> texture_quad = - cc::TextureDrawQuad::Create(); + scoped_ptr<TextureDrawQuad> texture_quad = TextureDrawQuad::Create(); texture_quad->SetNew(shared_state.get(), rect, opaque_rect, @@ -177,8 +167,7 @@ void TestRenderPass::AppendOneOfEveryQuadType( false); AppendQuad(texture_quad.PassAs<DrawQuad>()); - scoped_ptr<cc::TileDrawQuad> scaled_tile_quad = - cc::TileDrawQuad::Create(); + scoped_ptr<TileDrawQuad> scaled_tile_quad = TileDrawQuad::Create(); scaled_tile_quad->SetNew(shared_state.get(), rect, opaque_rect, @@ -188,13 +177,12 @@ void TestRenderPass::AppendOneOfEveryQuadType( false); AppendQuad(scaled_tile_quad.PassAs<DrawQuad>()); - scoped_ptr<cc::SharedQuadState> transformed_state = shared_state->Copy(); + scoped_ptr<SharedQuadState> transformed_state = shared_state->Copy(); gfx::Transform rotation; rotation.Rotate(45); transformed_state->content_to_target_transform = transformed_state->content_to_target_transform * rotation; - scoped_ptr<cc::TileDrawQuad> transformed_tile_quad = - cc::TileDrawQuad::Create(); + scoped_ptr<TileDrawQuad> transformed_tile_quad = TileDrawQuad::Create(); transformed_tile_quad->SetNew(transformed_state.get(), rect, opaque_rect, @@ -204,7 +192,7 @@ void TestRenderPass::AppendOneOfEveryQuadType( false); AppendQuad(transformed_tile_quad.PassAs<DrawQuad>()); - scoped_ptr<cc::SharedQuadState> shared_state2 = cc::SharedQuadState::Create(); + scoped_ptr<SharedQuadState> shared_state2 = SharedQuadState::Create(); shared_state->SetAll(gfx::Transform(), rect.size(), rect, @@ -213,7 +201,7 @@ void TestRenderPass::AppendOneOfEveryQuadType( 1, SkXfermode::kSrcOver_Mode); - scoped_ptr<cc::TileDrawQuad> tile_quad = cc::TileDrawQuad::Create(); + scoped_ptr<TileDrawQuad> tile_quad = TileDrawQuad::Create(); tile_quad->SetNew(shared_state2.get(), rect, opaque_rect, @@ -233,8 +221,7 @@ void TestRenderPass::AppendOneOfEveryQuadType( resource_provider->best_texture_format()); resource_provider->AllocateForTesting(plane_resources[i]); } - scoped_ptr<cc::YUVVideoDrawQuad> yuv_quad = - cc::YUVVideoDrawQuad::Create(); + scoped_ptr<YUVVideoDrawQuad> yuv_quad = YUVVideoDrawQuad::Create(); yuv_quad->SetNew(shared_state2.get(), rect, opaque_rect, diff --git a/cc/test/scheduler_test_common.h b/cc/test/scheduler_test_common.h index 4236fff..46e6012 100644 --- a/cc/test/scheduler_test_common.h +++ b/cc/test/scheduler_test_common.h @@ -14,7 +14,7 @@ namespace cc { -class FakeTimeSourceClient : public cc::TimeSourceClient { +class FakeTimeSourceClient : public TimeSourceClient { public: FakeTimeSourceClient() { Reset(); } void Reset() { tick_called_ = false; } @@ -27,7 +27,7 @@ class FakeTimeSourceClient : public cc::TimeSourceClient { bool tick_called_; }; -class FakeDelayBasedTimeSource : public cc::DelayBasedTimeSource { +class FakeDelayBasedTimeSource : public DelayBasedTimeSource { public: static scoped_refptr<FakeDelayBasedTimeSource> Create( base::TimeDelta interval, base::SingleThreadTaskRunner* task_runner) { @@ -47,10 +47,10 @@ class FakeDelayBasedTimeSource : public cc::DelayBasedTimeSource { base::TimeTicks now_; }; -class FakeFrameRateController : public cc::FrameRateController { +class FakeFrameRateController : public FrameRateController { public: - explicit FakeFrameRateController(scoped_refptr<cc::TimeSource> timer) - : cc::FrameRateController(timer) {} + explicit FakeFrameRateController(scoped_refptr<TimeSource> timer) + : FrameRateController(timer) {} int NumFramesPending() const { return num_frames_pending_; } }; diff --git a/cc/test/solid_color_content_layer_client.h b/cc/test/solid_color_content_layer_client.h index ad7c0f0..38d32b4 100644 --- a/cc/test/solid_color_content_layer_client.h +++ b/cc/test/solid_color_content_layer_client.h @@ -11,7 +11,7 @@ namespace cc { -class SolidColorContentLayerClient : public cc::ContentLayerClient { +class SolidColorContentLayerClient : public ContentLayerClient { public: explicit SolidColorContentLayerClient(SkColor color) : color_(color) {} diff --git a/cc/test/test_context_provider.h b/cc/test/test_context_provider.h index cea9b35..4290725 100644 --- a/cc/test/test_context_provider.h +++ b/cc/test/test_context_provider.h @@ -20,7 +20,7 @@ namespace cc { class TestWebGraphicsContext3D; class TestGLES2Interface; -class TestContextProvider : public cc::ContextProvider { +class TestContextProvider : public ContextProvider { public: typedef base::Callback<scoped_ptr<TestWebGraphicsContext3D>(void)> CreateCallback; diff --git a/cc/trees/layer_tree_host_client.h b/cc/trees/layer_tree_host_client.h index 7af4c87..2e3023a 100644 --- a/cc/trees/layer_tree_host_client.h +++ b/cc/trees/layer_tree_host_client.h @@ -39,7 +39,7 @@ class LayerTreeHostClient { // If the client provides an OutputSurface bound to a 3d context for direct // rendering, this must return a provider that provides contexts usable from // the same thread as the OutputSurface's context. - virtual scoped_refptr<cc::ContextProvider> OffscreenContextProvider() = 0; + virtual scoped_refptr<ContextProvider> OffscreenContextProvider() = 0; // Requests that the client insert a rate limiting token in the shared main // thread context's command stream that will block if the context gets too far diff --git a/cc/trees/layer_tree_host_common_perftest.cc b/cc/trees/layer_tree_host_common_perftest.cc index 756a5ea..7b63b2a 100644 --- a/cc/trees/layer_tree_host_common_perftest.cc +++ b/cc/trees/layer_tree_host_common_perftest.cc @@ -38,7 +38,7 @@ class LayerTreeHostCommonPerfTest : public LayerTreeTest { void ReadTestFile(const std::string& name) { base::FilePath test_data_dir; - ASSERT_TRUE(PathService::Get(cc::DIR_TEST_DATA, &test_data_dir)); + ASSERT_TRUE(PathService::Get(CCPaths::DIR_TEST_DATA, &test_data_dir)); base::FilePath json_file = test_data_dir.AppendASCII(name + ".json"); ASSERT_TRUE(base::ReadFileToString(json_file, &json_)); } diff --git a/cc/trees/layer_tree_host_perftest.cc b/cc/trees/layer_tree_host_perftest.cc index 4fd2436..e3cf1f7 100644 --- a/cc/trees/layer_tree_host_perftest.cc +++ b/cc/trees/layer_tree_host_perftest.cc @@ -124,7 +124,7 @@ class LayerTreeHostPerfTestJsonReader : public LayerTreeHostPerfTest { void ReadTestFile(const std::string& name) { base::FilePath test_data_dir; - ASSERT_TRUE(PathService::Get(cc::DIR_TEST_DATA, &test_data_dir)); + ASSERT_TRUE(PathService::Get(CCPaths::DIR_TEST_DATA, &test_data_dir)); base::FilePath json_file = test_data_dir.AppendASCII(name + ".json"); ASSERT_TRUE(base::ReadFileToString(json_file, &json_)); } diff --git a/cc/trees/single_thread_proxy.cc b/cc/trees/single_thread_proxy.cc index 57f3557..f1f8a4f 100644 --- a/cc/trees/single_thread_proxy.cc +++ b/cc/trees/single_thread_proxy.cc @@ -121,7 +121,7 @@ void SingleThreadProxy::CreateAndInitializeOutputSurface() { return; } - scoped_refptr<cc::ContextProvider> offscreen_context_provider; + scoped_refptr<ContextProvider> offscreen_context_provider; if (created_offscreen_context_provider_) { offscreen_context_provider = layer_tree_host_->client()->OffscreenContextProvider(); @@ -453,7 +453,7 @@ bool SingleThreadProxy::CommitAndComposite( layer_tree_host_->WillCommit(); - scoped_refptr<cc::ContextProvider> offscreen_context_provider; + scoped_refptr<ContextProvider> offscreen_context_provider; if (renderer_capabilities_for_main_thread_.using_offscreen_context3d && layer_tree_host_->needs_offscreen_context()) { offscreen_context_provider = @@ -489,7 +489,7 @@ void SingleThreadProxy::UpdateBackgroundAnimateTicking() { } bool SingleThreadProxy::DoComposite( - scoped_refptr<cc::ContextProvider> offscreen_context_provider, + scoped_refptr<ContextProvider> offscreen_context_provider, base::TimeTicks frame_begin_time, gfx::Rect device_viewport_damage_rect, bool for_readback, @@ -534,7 +534,7 @@ bool SingleThreadProxy::DoComposite( } if (lost_output_surface) { - cc::ContextProvider* offscreen_contexts = + ContextProvider* offscreen_contexts = layer_tree_host_impl_->offscreen_context_provider(); if (offscreen_contexts) offscreen_contexts->VerifyContexts(); diff --git a/cc/trees/single_thread_proxy.h b/cc/trees/single_thread_proxy.h index 50e6bf2..463141c 100644 --- a/cc/trees/single_thread_proxy.h +++ b/cc/trees/single_thread_proxy.h @@ -92,12 +92,11 @@ class SingleThreadProxy : public Proxy, LayerTreeHostImplClient { bool for_readback, LayerTreeHostImpl::FrameData* frame); void DoCommit(scoped_ptr<ResourceUpdateQueue> queue); - bool DoComposite( - scoped_refptr<cc::ContextProvider> offscreen_context_provider, - base::TimeTicks frame_begin_time, - gfx::Rect device_viewport_damage_rect, - bool for_readback, - LayerTreeHostImpl::FrameData* frame); + bool DoComposite(scoped_refptr<ContextProvider> offscreen_context_provider, + base::TimeTicks frame_begin_time, + gfx::Rect device_viewport_damage_rect, + bool for_readback, + LayerTreeHostImpl::FrameData* frame); void DidSwapFrame(); bool ShouldComposite() const; diff --git a/cc/trees/thread_proxy.cc b/cc/trees/thread_proxy.cc index 9624a2d..6149522 100644 --- a/cc/trees/thread_proxy.cc +++ b/cc/trees/thread_proxy.cc @@ -395,7 +395,7 @@ void ThreadProxy::CheckOutputSurfaceStatusOnImplThread() { TRACE_EVENT0("cc", "ThreadProxy::CheckOutputSurfaceStatusOnImplThread"); if (!layer_tree_host_impl_->IsContextLost()) return; - if (cc::ContextProvider* offscreen_contexts = + if (ContextProvider* offscreen_contexts = layer_tree_host_impl_->offscreen_context_provider()) offscreen_contexts->VerifyContexts(); scheduler_on_impl_thread_->DidLoseOutputSurface(); @@ -892,7 +892,7 @@ void ThreadProxy::BeginMainFrame( SetNeedsAnimate(); } - scoped_refptr<cc::ContextProvider> offscreen_context_provider; + scoped_refptr<ContextProvider> offscreen_context_provider; if (renderer_capabilities_main_thread_copy_.using_offscreen_context3d && layer_tree_host()->needs_offscreen_context()) { offscreen_context_provider = @@ -939,7 +939,7 @@ void ThreadProxy::BeginMainFrame( void ThreadProxy::StartCommitOnImplThread( CompletionEvent* completion, ResourceUpdateQueue* raw_queue, - scoped_refptr<cc::ContextProvider> offscreen_context_provider) { + scoped_refptr<ContextProvider> offscreen_context_provider) { scoped_ptr<ResourceUpdateQueue> queue(raw_queue); TRACE_EVENT0("cc", "ThreadProxy::StartCommitOnImplThread"); diff --git a/cc/trees/thread_proxy.h b/cc/trees/thread_proxy.h index 1e226b2..cf041ed 100644 --- a/cc/trees/thread_proxy.h +++ b/cc/trees/thread_proxy.h @@ -159,7 +159,7 @@ class ThreadProxy : public Proxy, void StartCommitOnImplThread( CompletionEvent* completion, ResourceUpdateQueue* queue, - scoped_refptr<cc::ContextProvider> offscreen_context_provider); + scoped_refptr<ContextProvider> offscreen_context_provider); void BeginMainFrameAbortedOnImplThread(bool did_handle); void RequestReadbackOnImplThread(ReadbackRequest* request); void FinishAllRenderingOnImplThread(CompletionEvent* completion); |