OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "cc/resources/resource_update_controller.h" | 5 #include "cc/resources/resource_update_controller.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 | 8 |
9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
10 #include "cc/base/thread.h" | 10 #include "cc/base/thread.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 // Measured in seconds. | 27 // Measured in seconds. |
28 const double kTextureUpdateTickRate = 0.004; | 28 const double kTextureUpdateTickRate = 0.004; |
29 | 29 |
30 // Measured in seconds. | 30 // Measured in seconds. |
31 const double kUploaderBusyTickRate = 0.001; | 31 const double kUploaderBusyTickRate = 0.001; |
32 | 32 |
33 // Number of blocking update intervals to allow. | 33 // Number of blocking update intervals to allow. |
34 const size_t kMaxBlockingUpdateIntervals = 4; | 34 const size_t kMaxBlockingUpdateIntervals = 4; |
35 | 35 |
36 skia::RefPtr<SkCanvas> CreateAcceleratedCanvas( | 36 skia::RefPtr<SkCanvas> CreateAcceleratedCanvas( |
37 GrContext* gr_context, gfx::Size canvasSize, unsigned textureId) { | 37 GrContext* gr_context, gfx::Size canvas_size, unsigned texture_id) { |
38 GrBackendTextureDesc texture_desc; | 38 GrBackendTextureDesc texture_desc; |
39 texture_desc.fFlags = kRenderTarget_GrBackendTextureFlag; | 39 texture_desc.fFlags = kRenderTarget_GrBackendTextureFlag; |
40 texture_desc.fWidth = canvasSize.width(); | 40 texture_desc.fWidth = canvas_size.width(); |
41 texture_desc.fHeight = canvasSize.height(); | 41 texture_desc.fHeight = canvas_size.height(); |
42 texture_desc.fConfig = kSkia8888_GrPixelConfig; | 42 texture_desc.fConfig = kSkia8888_GrPixelConfig; |
43 texture_desc.fTextureHandle = textureId; | 43 texture_desc.fTextureHandle = texture_id; |
44 skia::RefPtr<GrTexture> target = | 44 skia::RefPtr<GrTexture> target = |
45 skia::AdoptRef(gr_context->wrapBackendTexture(texture_desc)); | 45 skia::AdoptRef(gr_context->wrapBackendTexture(texture_desc)); |
46 skia::RefPtr<SkDevice> device = | 46 skia::RefPtr<SkDevice> device = |
47 skia::AdoptRef(new SkGpuDevice(gr_context, target.get())); | 47 skia::AdoptRef(new SkGpuDevice(gr_context, target.get())); |
48 return skia::AdoptRef(new SkCanvas(device.get())); | 48 return skia::AdoptRef(new SkCanvas(device.get())); |
49 } | 49 } |
50 | 50 |
51 } // namespace | 51 } // namespace |
52 | 52 |
53 namespace cc { | 53 namespace cc { |
(...skipping 20 matching lines...) Expand all Loading... |
74 resource_provider_(resource_provider), | 74 resource_provider_(resource_provider), |
75 texture_updates_per_tick_(MaxFullUpdatesPerTick(resource_provider)), | 75 texture_updates_per_tick_(MaxFullUpdatesPerTick(resource_provider)), |
76 first_update_attempt_(true), | 76 first_update_attempt_(true), |
77 thread_(thread), | 77 thread_(thread), |
78 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), | 78 weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)), |
79 task_posted_(false) {} | 79 task_posted_(false) {} |
80 | 80 |
81 ResourceUpdateController::~ResourceUpdateController() {} | 81 ResourceUpdateController::~ResourceUpdateController() {} |
82 | 82 |
83 void ResourceUpdateController::PerformMoreUpdates( | 83 void ResourceUpdateController::PerformMoreUpdates( |
84 base::TimeTicks timeLimit) { | 84 base::TimeTicks time_limit) { |
85 time_limit_ = timeLimit; | 85 time_limit_ = time_limit; |
86 | 86 |
87 // Update already in progress. | 87 // Update already in progress. |
88 if (task_posted_) | 88 if (task_posted_) |
89 return; | 89 return; |
90 | 90 |
91 // Call UpdateMoreTexturesNow() directly unless it's the first update | 91 // Call UpdateMoreTexturesNow() directly unless it's the first update |
92 // attempt. This ensures that we empty the update queue in a finite | 92 // attempt. This ensures that we empty the update queue in a finite |
93 // amount of time. | 93 // amount of time. |
94 if (!first_update_attempt_) | 94 if (!first_update_attempt_) |
95 UpdateMoreTexturesNow(); | 95 UpdateMoreTexturesNow(); |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 if (!uploads) | 266 if (!uploads) |
267 return; | 267 return; |
268 | 268 |
269 while (queue_->FullUploadSize() && uploads--) | 269 while (queue_->FullUploadSize() && uploads--) |
270 UpdateTexture(queue_->TakeFirstFullUpload()); | 270 UpdateTexture(queue_->TakeFirstFullUpload()); |
271 | 271 |
272 resource_provider_->FlushUploads(); | 272 resource_provider_->FlushUploads(); |
273 } | 273 } |
274 | 274 |
275 } // namespace cc | 275 } // namespace cc |
OLD | NEW |