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

Side by Side Diff: examples/ui/noodles/noodles_view.cc

Issue 2011713003: Roll skia to 8cc209111876b7c78b5ec577c9221d8ed5e21024 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 4 years, 7 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 | « examples/ui/noodles/noodles_view.h ('k') | examples/ui/pdf_viewer/pdf_viewer.cc » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "examples/ui/noodles/noodles_view.h" 5 #include "examples/ui/noodles/noodles_view.h"
6 6
7 #include <math.h> 7 #include <math.h>
8 8
9 #include <cstdlib> 9 #include <cstdlib>
10 #include <utility> 10 #include <utility>
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 metadata->presentation_time = frame_info.presentation_time; 102 metadata->presentation_time = frame_info.presentation_time;
103 std::unique_ptr<Frame> frame( 103 std::unique_ptr<Frame> frame(
104 new Frame(size, CreatePicture(), metadata.Pass())); 104 new Frame(size, CreatePicture(), metadata.Pass()));
105 if (frame_queue_->PutFrame(std::move(frame))) { 105 if (frame_queue_->PutFrame(std::move(frame))) {
106 rasterizer_task_runner_->PostTask( 106 rasterizer_task_runner_->PostTask(
107 FROM_HERE, base::Bind(&RasterizerDelegate::PublishNextFrame, 107 FROM_HERE, base::Bind(&RasterizerDelegate::PublishNextFrame,
108 base::Unretained(rasterizer_delegate_.get()))); 108 base::Unretained(rasterizer_delegate_.get())));
109 } 109 }
110 } 110 }
111 111
112 skia::RefPtr<SkPicture> NoodlesView::CreatePicture() { 112 sk_sp<SkPicture> NoodlesView::CreatePicture() {
113 constexpr int count = 4; 113 constexpr int count = 4;
114 constexpr int padding = 1; 114 constexpr int padding = 1;
115 115
116 if (alpha_ > kSecondsBetweenChanges) { 116 if (alpha_ > kSecondsBetweenChanges) {
117 alpha_ = 0.0; 117 alpha_ = 0.0;
118 wx_ = rand() % 9 + 1; 118 wx_ = rand() % 9 + 1;
119 wy_ = rand() % 9 + 1; 119 wy_ = rand() % 9 + 1;
120 } 120 }
121 121
122 const mojo::Size& size = *properties()->view_layout->size; 122 const mojo::Size& size = *properties()->view_layout->size;
(...skipping 10 matching lines...) Expand all
133 SkScalar hsv[3] = {fmod(phase * 120, 360), 1, 1}; 133 SkScalar hsv[3] = {fmod(phase * 120, 360), 1, 1};
134 paint.setColor(SkHSVToColor(hsv)); 134 paint.setColor(SkHSVToColor(hsv));
135 paint.setStyle(SkPaint::kStroke_Style); 135 paint.setStyle(SkPaint::kStroke_Style);
136 paint.setAntiAlias(true); 136 paint.setAntiAlias(true);
137 137
138 SkPath path; 138 SkPath path;
139 Lissajous(&path, cx - padding, cy - padding, wx_, wy_, phase); 139 Lissajous(&path, cx - padding, cy - padding, wx_, wy_, phase);
140 canvas->drawPath(path, paint); 140 canvas->drawPath(path, paint);
141 } 141 }
142 142
143 return skia::AdoptRef(recorder.endRecordingAsPicture()); 143 return recorder.finishRecordingAsPicture();
144 } 144 }
145 145
146 NoodlesView::FrameQueue::FrameQueue() {} 146 NoodlesView::FrameQueue::FrameQueue() {}
147 147
148 NoodlesView::FrameQueue::~FrameQueue() {} 148 NoodlesView::FrameQueue::~FrameQueue() {}
149 149
150 bool NoodlesView::FrameQueue::PutFrame(std::unique_ptr<Frame> frame) { 150 bool NoodlesView::FrameQueue::PutFrame(std::unique_ptr<Frame> frame) {
151 std::lock_guard<std::mutex> lock(mutex_); 151 std::lock_guard<std::mutex> lock(mutex_);
152 bool was_empty = !next_frame_.get(); 152 bool was_empty = !next_frame_.get();
153 next_frame_.swap(frame); 153 next_frame_.swap(frame);
(...skipping 21 matching lines...) Expand all
175 mojo::gfx::composition::ScenePtr::Create(std::move(scene_info)))); 175 mojo::gfx::composition::ScenePtr::Create(std::move(scene_info))));
176 } 176 }
177 177
178 void NoodlesView::RasterizerDelegate::PublishNextFrame() { 178 void NoodlesView::RasterizerDelegate::PublishNextFrame() {
179 std::unique_ptr<Frame> frame(frame_queue_->TakeFrame()); 179 std::unique_ptr<Frame> frame(frame_queue_->TakeFrame());
180 DCHECK(frame); 180 DCHECK(frame);
181 rasterizer_->PublishFrame(std::move(frame)); 181 rasterizer_->PublishFrame(std::move(frame));
182 } 182 }
183 183
184 } // namespace examples 184 } // namespace examples
OLDNEW
« no previous file with comments | « examples/ui/noodles/noodles_view.h ('k') | examples/ui/pdf_viewer/pdf_viewer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698