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

Side by Side Diff: cc/picture.cc

Issue 12316084: cc: Consolidate the analysis_canvas operations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: reveman's review Created 7 years, 9 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 | Annotate | Revision Log
OLDNEW
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 "base/debug/trace_event.h" 5 #include "base/debug/trace_event.h"
6 #include "cc/content_layer_client.h" 6 #include "cc/content_layer_client.h"
7 #include "cc/picture.h" 7 #include "cc/picture.h"
8 #include "cc/rendering_stats.h" 8 #include "cc/rendering_stats.h"
9 #include "skia/ext/analysis_canvas.h" 9 #include "skia/ext/analysis_canvas.h"
10 #include "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 DCHECK(picture_); 107 DCHECK(picture_);
108 108
109 canvas->save(); 109 canvas->save();
110 canvas->clipRect(gfx::RectToSkRect(content_rect)); 110 canvas->clipRect(gfx::RectToSkRect(content_rect));
111 canvas->scale(contents_scale, contents_scale); 111 canvas->scale(contents_scale, contents_scale);
112 canvas->translate(layer_rect_.x(), layer_rect_.y()); 112 canvas->translate(layer_rect_.x(), layer_rect_.y());
113 canvas->drawPicture(*picture_); 113 canvas->drawPicture(*picture_);
114 canvas->restore(); 114 canvas->restore();
115 } 115 }
116 116
117 bool Picture::IsCheapInRect(const gfx::Rect& layer_rect) const { 117 void Picture::AnalyzeInRect(skia::AnalysisCanvas* canvas,
118 TRACE_EVENT0("cc", "Picture::IsCheapInRect"); 118 const gfx::Rect& content_rect,
119 float contents_scale,
120 Analysis* analysis) {
121 // Verify the output is valid.
122 DCHECK(analysis);
119 123
120 SkBitmap emptyBitmap; 124 canvas->save();
121 emptyBitmap.setConfig(SkBitmap::kNo_Config, layer_rect.width(), 125 canvas->clipRect(gfx::RectToSkRect(content_rect));
122 layer_rect.height()); 126 canvas->scale(contents_scale, contents_scale);
123 skia::AnalysisDevice device(emptyBitmap); 127 canvas->translate(layer_rect_.x(), layer_rect_.y());
124 skia::AnalysisCanvas canvas(&device); 128 canvas->drawPicture(*picture_);
129 canvas->restore();
125 130
126 canvas.drawPicture(*picture_); 131 analysis->is_solid_color = canvas->getColorIfSolid(&analysis->solid_color);
127 return canvas.isCheap(); 132 analysis->is_transparent = canvas->isTransparent();
133 analysis->is_cheap_to_raster = canvas->isCheap();
128 } 134 }
129 135
130 void Picture::GatherPixelRefs(const gfx::Rect& layer_rect, 136 void Picture::GatherPixelRefs(const gfx::Rect& layer_rect,
131 std::list<skia::LazyPixelRef*>& pixel_ref_list) { 137 std::list<skia::LazyPixelRef*>& pixel_ref_list) {
132 DCHECK(picture_); 138 DCHECK(picture_);
133 SkData* pixel_refs = SkPictureUtils::GatherPixelRefs( 139 SkData* pixel_refs = SkPictureUtils::GatherPixelRefs(
134 picture_.get(), SkRect::MakeXYWH(layer_rect.x(), 140 picture_.get(), SkRect::MakeXYWH(layer_rect.x(),
135 layer_rect.y(), 141 layer_rect.y(),
136 layer_rect.width(), 142 layer_rect.width(),
137 layer_rect.height())); 143 layer_rect.height()));
(...skipping 10 matching lines...) Expand all
148 for (unsigned int i = 0; i < pixel_refs->size() / sizeof(SkPixelRef*); ++i) { 154 for (unsigned int i = 0; i < pixel_refs->size() / sizeof(SkPixelRef*); ++i) {
149 if (*refs && (*refs)->getURI() && !strncmp( 155 if (*refs && (*refs)->getURI() && !strncmp(
150 (*refs)->getURI(), labelLazyDecoded, 4)) { 156 (*refs)->getURI(), labelLazyDecoded, 4)) {
151 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); 157 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs));
152 } 158 }
153 refs++; 159 refs++;
154 } 160 }
155 pixel_refs->unref(); 161 pixel_refs->unref();
156 } 162 }
157 163
164 Picture::Analysis::Analysis() :
165 is_solid_color(false),
166 is_transparent(false),
167 is_cheap_to_raster(false) {
168 }
169
158 } // namespace cc 170 } // namespace cc
OLDNEW
« no previous file with comments | « cc/picture.h ('k') | cc/picture_layer_impl.cc » ('j') | cc/picture_pile_impl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698