Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(177)

Side by Side Diff: cc/resources/pixel_buffer_raster_worker_pool.cc

Issue 659563002: cc: Replace RasterBuffer::Acquire/ReleaseCanvas with Playback function. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add temporary size variable Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/resources/one_copy_raster_worker_pool.cc ('k') | cc/resources/raster_buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/pixel_buffer_raster_worker_pool.h" 5 #include "cc/resources/pixel_buffer_raster_worker_pool.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/containers/stack_container.h" 9 #include "base/containers/stack_container.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/debug/trace_event_argument.h" 11 #include "base/debug/trace_event_argument.h"
12 #include "base/strings/stringprintf.h" 12 #include "base/strings/stringprintf.h"
13 #include "cc/debug/traced_value.h" 13 #include "cc/debug/traced_value.h"
14 #include "cc/resources/raster_buffer.h" 14 #include "cc/resources/raster_buffer.h"
15 #include "cc/resources/resource.h" 15 #include "cc/resources/resource.h"
16 #include "gpu/command_buffer/client/gles2_interface.h" 16 #include "gpu/command_buffer/client/gles2_interface.h"
17 #include "third_party/skia/include/utils/SkNullCanvas.h"
18 17
19 namespace cc { 18 namespace cc {
20 namespace { 19 namespace {
21 20
22 class RasterBufferImpl : public RasterBuffer { 21 class RasterBufferImpl : public RasterBuffer {
23 public: 22 public:
24 RasterBufferImpl(ResourceProvider* resource_provider, 23 RasterBufferImpl(ResourceProvider* resource_provider,
25 const Resource* resource) 24 const Resource* resource)
26 : resource_provider_(resource_provider), 25 : resource_provider_(resource_provider),
27 resource_(resource), 26 resource_(resource),
28 buffer_(NULL), 27 memory_(NULL),
29 stride_(0) { 28 stride_(0) {
30 resource_provider_->AcquirePixelBuffer(resource_->id()); 29 resource_provider_->AcquirePixelBuffer(resource_->id());
31 buffer_ = resource_provider_->MapPixelBuffer(resource_->id(), &stride_); 30 memory_ = resource_provider_->MapPixelBuffer(resource_->id(), &stride_);
32 } 31 }
33 32
34 virtual ~RasterBufferImpl() { 33 virtual ~RasterBufferImpl() {
35 resource_provider_->ReleasePixelBuffer(resource_->id()); 34 resource_provider_->ReleasePixelBuffer(resource_->id());
36 } 35 }
37 36
38 // Overridden from RasterBuffer: 37 // Overridden from RasterBuffer:
39 virtual skia::RefPtr<SkCanvas> AcquireSkCanvas() override { 38 virtual void Playback(const PicturePileImpl* picture_pile,
40 if (!buffer_) 39 const gfx::Rect& rect,
41 return skia::AdoptRef(SkCreateNullCanvas()); 40 float scale,
42 41 RenderingStatsInstrumentation* stats) override {
43 RasterWorkerPool::AcquireBitmapForBuffer( 42 if (!memory_)
44 &bitmap_, buffer_, resource_->format(), resource_->size(), stride_);
45 return skia::AdoptRef(new SkCanvas(bitmap_));
46 }
47 virtual void ReleaseSkCanvas(const skia::RefPtr<SkCanvas>& canvas) override {
48 if (!buffer_)
49 return; 43 return;
50 44
51 RasterWorkerPool::ReleaseBitmapForBuffer( 45 RasterWorkerPool::PlaybackToMemory(memory_,
52 &bitmap_, buffer_, resource_->format()); 46 resource_->format(),
47 resource_->size(),
48 stride_,
49 picture_pile,
50 rect,
51 scale,
52 stats);
53 } 53 }
54 54
55 private: 55 private:
56 ResourceProvider* resource_provider_; 56 ResourceProvider* resource_provider_;
57 const Resource* resource_; 57 const Resource* resource_;
58 uint8_t* buffer_; 58 uint8_t* memory_;
59 int stride_; 59 int stride_;
60 SkBitmap bitmap_;
61 60
62 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl); 61 DISALLOW_COPY_AND_ASSIGN(RasterBufferImpl);
63 }; 62 };
64 63
65 const int kCheckForCompletedRasterTasksDelayMs = 6; 64 const int kCheckForCompletedRasterTasksDelayMs = 6;
66 65
67 const size_t kMaxScheduledRasterTasks = 48; 66 const size_t kMaxScheduledRasterTasks = 48;
68 67
69 typedef base::StackVector<RasterTask*, kMaxScheduledRasterTasks> 68 typedef base::StackVector<RasterTask*, kMaxScheduledRasterTasks>
70 RasterTaskVector; 69 RasterTaskVector;
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 void PixelBufferRasterWorkerPool::ThrottleStateAsValueInto( 746 void PixelBufferRasterWorkerPool::ThrottleStateAsValueInto(
748 base::debug::TracedValue* throttle_state) const { 747 base::debug::TracedValue* throttle_state) const {
749 throttle_state->SetInteger("bytes_available_for_upload", 748 throttle_state->SetInteger("bytes_available_for_upload",
750 max_bytes_pending_upload_ - bytes_pending_upload_); 749 max_bytes_pending_upload_ - bytes_pending_upload_);
751 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_); 750 throttle_state->SetInteger("bytes_pending_upload", bytes_pending_upload_);
752 throttle_state->SetInteger("scheduled_raster_task_count", 751 throttle_state->SetInteger("scheduled_raster_task_count",
753 scheduled_raster_task_count_); 752 scheduled_raster_task_count_);
754 } 753 }
755 754
756 } // namespace cc 755 } // namespace cc
OLDNEW
« no previous file with comments | « cc/resources/one_copy_raster_worker_pool.cc ('k') | cc/resources/raster_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698