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

Side by Side Diff: skia/ext/cdl_picture.cc

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years 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 | « skia/ext/cdl_picture.h ('k') | skia/ext/cdl_picture_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
(Empty)
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "skia/ext/cdl_picture.h"
6
7 #if CDL_ENABLED
8
9 #include <stddef.h>
10 #include <stdint.h>
11
12 #include "base/atomicops.h"
13 #include "base/logging.h"
14 #include "third_party/skia/include/core/SkPicture.h"
15 #include "third_party/skia/include/core/SkPictureRecorder.h"
16
17 #include "skia/ext/cdl_picture_buffer.h"
18
19 CdlPicture::CdlPicture(sk_sp<CdlPictureBuffer> picture,
20 SkRect cull_bounds,
21 int start_offset,
22 int end_offset)
23 : picture_(picture),
24 cull_bounds_(cull_bounds),
25 start_offset_(start_offset),
26 end_offset_(end_offset) {}
27
28 CdlPicture::~CdlPicture() {}
29
30 void CdlPicture::draw(CdlCanvas* canvas,
31 const SkMatrix* matrix,
32 const CdlPaint* paint) const {
33 canvas->drawPicture(this, matrix, paint);
34 }
35
36 sk_sp<SkPicture> CdlPicture::toSkPicture() const {
37 SkPictureRecorder recorder;
38 SkCanvas* canvas = recorder.beginRecording(cullRect());
39 picture_->playback(CdlCanvas::Make(canvas).get(), start_offset_, end_offset_);
40
41 return recorder.finishRecordingAsPicture();
42 }
43
44 void CdlPicture::playback(CdlCanvas* canvas,
45 SkPicture::AbortCallback* callback) const {
46 // TODO(cdl): CdlPicture doesn't support AbortCallback.
47 int save_count = canvas->getSaveCount();
48 canvas->save();
49 picture_->playback(canvas, start_offset_, end_offset_);
50 canvas->restoreToCount(save_count);
51 }
52
53 uint32_t CdlPicture::uniqueID() const {
54 if (!unique_id_) {
55 static base::subtle::Atomic32 g_next_id = 1;
56 unique_id_ = base::subtle::Barrier_AtomicIncrement(&g_next_id, 1);
57 }
58 return unique_id_;
59 }
60
61 #endif // CDL_ENABLED
OLDNEW
« no previous file with comments | « skia/ext/cdl_picture.h ('k') | skia/ext/cdl_picture_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698