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

Side by Side Diff: cc/picture.cc

Issue 12184010: skia::AnalysisCanvas: implementation for IsCheapInRect(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
« no previous file with comments | « no previous file | skia/ext/analysis_canvas.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 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 "third_party/skia/include/core/SkCanvas.h" 10 #include "third_party/skia/include/core/SkCanvas.h"
10 #include "third_party/skia/include/core/SkData.h" 11 #include "third_party/skia/include/core/SkData.h"
11 #include "third_party/skia/include/core/SkTileGridPicture.h" 12 #include "third_party/skia/include/core/SkTileGridPicture.h"
12 #include "third_party/skia/include/utils/SkPictureUtils.h" 13 #include "third_party/skia/include/utils/SkPictureUtils.h"
13 #include "ui/gfx/rect_conversions.h" 14 #include "ui/gfx/rect_conversions.h"
14 #include "ui/gfx/skia_util.h" 15 #include "ui/gfx/skia_util.h"
15 16
16 namespace { 17 namespace {
17 // URI label for a lazily decoded SkPixelRef. 18 // URI label for a lazily decoded SkPixelRef.
18 const char labelLazyDecoded[] = "lazy"; 19 const char labelLazyDecoded[] = "lazy";
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 DCHECK(picture_); 102 DCHECK(picture_);
102 103
103 canvas->save(); 104 canvas->save();
104 canvas->clipRect(gfx::RectToSkRect(content_rect)); 105 canvas->clipRect(gfx::RectToSkRect(content_rect));
105 canvas->scale(contents_scale, contents_scale); 106 canvas->scale(contents_scale, contents_scale);
106 canvas->translate(layer_rect_.x(), layer_rect_.y()); 107 canvas->translate(layer_rect_.x(), layer_rect_.y());
107 canvas->drawPicture(*picture_); 108 canvas->drawPicture(*picture_);
108 canvas->restore(); 109 canvas->restore();
109 } 110 }
110 111
111 bool Picture::IsCheapInRect(const gfx::Rect& layer_rect) { 112 bool Picture::IsCheapInRect(const gfx::Rect& layer_rect) {
Sami 2013/02/04 10:57:54 Should we make this a const method?
Tom Hudson 2013/02/05 17:02:00 Done. I also had to add contents_scale to the lis
113 skia::AnalysisCanvas canvas(gfx::RectToSkRect(layer_rect));
114 // If a picture has estimatd cost below this threshold, go ahead and
115 // wait until we have more pictures to draw (to amortize startup costs).
116 // If cost exceeds this threshold, start it now so we aren't blocked
117 // waiting for it.
118 // FIXME: Arbitrary number. Requires tuning & experimentation.
119 // Probably requires per-platform tuning; N10 average draw call takes
120 // 25x as long as Z620.
121 int pictureCostThreshold = 100;
122 canvas.drawPicture(*picture_);
123 if (canvas.getEstimatedCost() <= pictureCostThreshold) {
nduca 2013/02/04 10:34:33 love this. convert this to bool isCheap() and push
Tom Hudson 2013/02/05 17:02:00 Done.
124 return true;
125 }
112 return false; 126 return false;
113 } 127 }
114 128
115 void Picture::GatherPixelRefs(const gfx::Rect& layer_rect, 129 void Picture::GatherPixelRefs(const gfx::Rect& layer_rect,
116 std::list<skia::LazyPixelRef*>& pixel_ref_list) { 130 std::list<skia::LazyPixelRef*>& pixel_ref_list) {
117 DCHECK(picture_); 131 DCHECK(picture_);
118 SkData* pixel_refs = SkPictureUtils::GatherPixelRefs( 132 SkData* pixel_refs = SkPictureUtils::GatherPixelRefs(
119 picture_.get(), SkRect::MakeXYWH(layer_rect.x(), 133 picture_.get(), SkRect::MakeXYWH(layer_rect.x(),
120 layer_rect.y(), 134 layer_rect.y(),
121 layer_rect.width(), 135 layer_rect.width(),
(...skipping 12 matching lines...) Expand all
134 if (*refs && (*refs)->getURI() && !strncmp( 148 if (*refs && (*refs)->getURI() && !strncmp(
135 (*refs)->getURI(), labelLazyDecoded, 4)) { 149 (*refs)->getURI(), labelLazyDecoded, 4)) {
136 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs)); 150 pixel_ref_list.push_back(static_cast<skia::LazyPixelRef*>(*refs));
137 } 151 }
138 refs++; 152 refs++;
139 } 153 }
140 pixel_refs->unref(); 154 pixel_refs->unref();
141 } 155 }
142 156
143 } // namespace cc 157 } // namespace cc
OLDNEW
« no previous file with comments | « no previous file | skia/ext/analysis_canvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698