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

Side by Side Diff: cc/resources/picture.h

Issue 1144693002: cc: Move files out of cc/resources/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: resources: android Created 5 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 | « cc/resources/one_copy_tile_task_worker_pool.cc ('k') | cc/resources/picture.cc » ('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 2012 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 #ifndef CC_RESOURCES_PICTURE_H_
6 #define CC_RESOURCES_PICTURE_H_
7
8 #include "base/basictypes.h"
9 #include "base/containers/hash_tables.h"
10 #include "base/lazy_instance.h"
11 #include "base/logging.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/trace_event/trace_event.h"
15 #include "cc/base/cc_export.h"
16 #include "cc/base/region.h"
17 #include "cc/resources/pixel_ref_map.h"
18 #include "cc/resources/recording_source.h"
19 #include "skia/ext/refptr.h"
20 #include "third_party/skia/include/core/SkPicture.h"
21 #include "ui/gfx/geometry/rect.h"
22
23 class SkPixelRef;
24
25 namespace base {
26 class Value;
27 }
28
29 namespace skia {
30 class AnalysisCanvas;
31 }
32
33 namespace cc {
34
35 class ContentLayerClient;
36
37 class CC_EXPORT Picture
38 : public base::RefCountedThreadSafe<Picture> {
39 public:
40 static scoped_refptr<Picture> Create(
41 const gfx::Rect& layer_rect,
42 ContentLayerClient* client,
43 const gfx::Size& tile_grid_size,
44 bool gather_pixels_refs,
45 RecordingSource::RecordingMode recording_mode);
46 static scoped_refptr<Picture> CreateFromValue(const base::Value* value);
47 static scoped_refptr<Picture> CreateFromSkpValue(const base::Value* value);
48
49 gfx::Rect LayerRect() const { return layer_rect_; }
50
51 // Has Record() been called yet?
52 bool HasRecording() const { return picture_.get() != NULL; }
53
54 bool IsSuitableForGpuRasterization(const char** reason) const;
55 int ApproximateOpCount() const;
56 size_t ApproximateMemoryUsage() const;
57
58 bool HasText() const;
59
60 // Apply this scale and raster the negated region into the canvas.
61 // |negated_content_region| specifies the region to be clipped out of the
62 // raster operation, i.e., the parts of the canvas which will not get drawn
63 // to.
64 int Raster(SkCanvas* canvas,
65 SkPicture::AbortCallback* callback,
66 const Region& negated_content_region,
67 float contents_scale) const;
68
69 // Draw the picture directly into the given canvas, without applying any
70 // clip/scale/layer transformations.
71 void Replay(SkCanvas* canvas, SkPicture::AbortCallback* callback = NULL);
72
73 scoped_ptr<base::Value> AsValue() const;
74
75 void EmitTraceSnapshot() const;
76 void EmitTraceSnapshotAlias(Picture* original) const;
77
78 bool WillPlayBackBitmaps() const { return picture_->willPlayBackBitmaps(); }
79
80 PixelRefMap::Iterator GetPixelRefMapIterator(
81 const gfx::Rect& layer_rect) const;
82
83 private:
84 Picture(const gfx::Rect& layer_rect, const gfx::Size& tile_grid_size);
85 // This constructor assumes SkPicture is already ref'd and transfers
86 // ownership to this picture.
87 Picture(const skia::RefPtr<SkPicture>&,
88 const gfx::Rect& layer_rect,
89 const PixelRefMap& pixel_refs);
90 // This constructor will call AdoptRef on the SkPicture.
91 Picture(SkPicture*, const gfx::Rect& layer_rect);
92 ~Picture();
93
94 // Record a paint operation. To be able to safely use this SkPicture for
95 // playback on a different thread this can only be called once.
96 void Record(ContentLayerClient* client,
97 RecordingSource::RecordingMode recording_mode);
98
99 // Gather pixel refs from recording.
100 void GatherPixelRefs();
101
102 gfx::Rect layer_rect_;
103 skia::RefPtr<SkPicture> picture_;
104
105 PixelRefMap pixel_refs_;
106
107 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
108 AsTraceableRasterData(float scale) const;
109 scoped_refptr<base::trace_event::ConvertableToTraceFormat>
110 AsTraceableRecordData() const;
111
112 friend class base::RefCountedThreadSafe<Picture>;
113 friend class PixelRefMap::Iterator;
114 DISALLOW_COPY_AND_ASSIGN(Picture);
115 };
116
117 } // namespace cc
118
119 #endif // CC_RESOURCES_PICTURE_H_
OLDNEW
« no previous file with comments | « cc/resources/one_copy_tile_task_worker_pool.cc ('k') | cc/resources/picture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698