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

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

Issue 22796028: Updating Chromium to Skia SkBaseDevice/SkBitmapDevice split (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added TODOs Created 7 years, 3 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 | « skia/ext/bitmap_platform_device_win.cc ('k') | skia/ext/platform_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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "skia/ext/lazy_pixel_ref_utils.h" 5 #include "skia/ext/lazy_pixel_ref_utils.h"
6 6
7 #include "skia/ext/lazy_pixel_ref.h" 7 #include "skia/ext/lazy_pixel_ref.h"
8 #include "third_party/skia/include/core/SkBitmapDevice.h"
8 #include "third_party/skia/include/core/SkCanvas.h" 9 #include "third_party/skia/include/core/SkCanvas.h"
9 #include "third_party/skia/include/core/SkData.h" 10 #include "third_party/skia/include/core/SkData.h"
10 #include "third_party/skia/include/core/SkDevice.h"
11 #include "third_party/skia/include/core/SkDraw.h" 11 #include "third_party/skia/include/core/SkDraw.h"
12 #include "third_party/skia/include/core/SkPixelRef.h" 12 #include "third_party/skia/include/core/SkPixelRef.h"
13 #include "third_party/skia/include/core/SkRRect.h" 13 #include "third_party/skia/include/core/SkRRect.h"
14 #include "third_party/skia/include/core/SkRect.h" 14 #include "third_party/skia/include/core/SkRect.h"
15 #include "third_party/skia/include/core/SkShader.h" 15 #include "third_party/skia/include/core/SkShader.h"
16 #include "third_party/skia/src/core/SkRasterClip.h" 16 #include "third_party/skia/src/core/SkRasterClip.h"
17 17
18 namespace skia { 18 namespace skia {
19 19
20 namespace { 20 namespace {
(...skipping 16 matching lines...) Expand all
37 static_cast<skia::LazyPixelRef*>(pixel_ref); 37 static_cast<skia::LazyPixelRef*>(pixel_ref);
38 position_pixel_ref.pixel_ref_rect = rect; 38 position_pixel_ref.pixel_ref_rect = rect;
39 pixel_refs_->push_back(position_pixel_ref); 39 pixel_refs_->push_back(position_pixel_ref);
40 } 40 }
41 } 41 }
42 42
43 private: 43 private:
44 std::vector<LazyPixelRefUtils::PositionLazyPixelRef>* pixel_refs_; 44 std::vector<LazyPixelRefUtils::PositionLazyPixelRef>* pixel_refs_;
45 }; 45 };
46 46
47 class GatherPixelRefDevice : public SkDevice { 47 class GatherPixelRefDevice : public SkBitmapDevice {
48 public: 48 public:
49 GatherPixelRefDevice(const SkBitmap& bm, LazyPixelRefSet* lazy_pixel_ref_set) 49 GatherPixelRefDevice(const SkBitmap& bm, LazyPixelRefSet* lazy_pixel_ref_set)
50 : SkDevice(bm), lazy_pixel_ref_set_(lazy_pixel_ref_set) {} 50 : SkBitmapDevice(bm), lazy_pixel_ref_set_(lazy_pixel_ref_set) {}
51 51
52 virtual void clear(SkColor color) SK_OVERRIDE {} 52 virtual void clear(SkColor color) SK_OVERRIDE {}
53 virtual void writePixels(const SkBitmap& bitmap, 53 virtual void writePixels(const SkBitmap& bitmap,
54 int x, 54 int x,
55 int y, 55 int y,
56 SkCanvas::Config8888 config8888) SK_OVERRIDE {} 56 SkCanvas::Config8888 config8888) SK_OVERRIDE {}
57 57
58 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) SK_OVERRIDE { 58 virtual void drawPaint(const SkDraw& draw, const SkPaint& paint) SK_OVERRIDE {
59 SkBitmap bitmap; 59 SkBitmap bitmap;
60 if (GetBitmapFromPaint(paint, &bitmap)) { 60 if (GetBitmapFromPaint(paint, &bitmap)) {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 const SkPoint texs[], 308 const SkPoint texs[],
309 const SkColor colors[], 309 const SkColor colors[],
310 SkXfermode* xmode, 310 SkXfermode* xmode,
311 const uint16_t indices[], 311 const uint16_t indices[],
312 int index_count, 312 int index_count,
313 const SkPaint& paint) SK_OVERRIDE { 313 const SkPaint& paint) SK_OVERRIDE {
314 GatherPixelRefDevice::drawPoints( 314 GatherPixelRefDevice::drawPoints(
315 draw, SkCanvas::kPolygon_PointMode, vertex_count, verts, paint); 315 draw, SkCanvas::kPolygon_PointMode, vertex_count, verts, paint);
316 } 316 }
317 virtual void drawDevice(const SkDraw&, 317 virtual void drawDevice(const SkDraw&,
318 SkDevice*, 318 SkBaseDevice*,
319 int x, 319 int x,
320 int y, 320 int y,
321 const SkPaint&) SK_OVERRIDE {} 321 const SkPaint&) SK_OVERRIDE {}
322 322
323 protected: 323 protected:
324 virtual bool onReadPixels(const SkBitmap& bitmap, 324 virtual bool onReadPixels(const SkBitmap& bitmap,
325 int x, 325 int x,
326 int y, 326 int y,
327 SkCanvas::Config8888 config8888) SK_OVERRIDE { 327 SkCanvas::Config8888 config8888) SK_OVERRIDE {
328 return false; 328 return false;
(...skipping 13 matching lines...) Expand all
342 // of bitmaps from gradient shaders, which implement asABitmap. 342 // of bitmaps from gradient shaders, which implement asABitmap.
343 if (SkShader::kNone_GradientType == shader->asAGradient(NULL)) 343 if (SkShader::kNone_GradientType == shader->asAGradient(NULL))
344 return shader->asABitmap(bm, NULL, NULL); 344 return shader->asABitmap(bm, NULL, NULL);
345 } 345 }
346 return false; 346 return false;
347 } 347 }
348 }; 348 };
349 349
350 class NoSaveLayerCanvas : public SkCanvas { 350 class NoSaveLayerCanvas : public SkCanvas {
351 public: 351 public:
352 NoSaveLayerCanvas(SkDevice* device) : INHERITED(device) {} 352 NoSaveLayerCanvas(SkBaseDevice* device) : INHERITED(device) {}
353 353
354 // Turn saveLayer() into save() for speed, should not affect correctness. 354 // Turn saveLayer() into save() for speed, should not affect correctness.
355 virtual int saveLayer(const SkRect* bounds, 355 virtual int saveLayer(const SkRect* bounds,
356 const SkPaint* paint, 356 const SkPaint* paint,
357 SaveFlags flags) SK_OVERRIDE { 357 SaveFlags flags) SK_OVERRIDE {
358 358
359 // Like SkPictureRecord, we don't want to create layers, but we do need 359 // Like SkPictureRecord, we don't want to create layers, but we do need
360 // to respect the save and (possibly) its rect-clip. 360 // to respect the save and (possibly) its rect-clip.
361 int count = this->INHERITED::save(flags); 361 int count = this->INHERITED::save(flags);
362 if (bounds) { 362 if (bounds) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 GatherPixelRefDevice device(empty_bitmap, &pixel_ref_set); 401 GatherPixelRefDevice device(empty_bitmap, &pixel_ref_set);
402 NoSaveLayerCanvas canvas(&device); 402 NoSaveLayerCanvas canvas(&device);
403 403
404 canvas.clipRect(SkRect::MakeWH(picture->width(), picture->height()), 404 canvas.clipRect(SkRect::MakeWH(picture->width(), picture->height()),
405 SkRegion::kIntersect_Op, 405 SkRegion::kIntersect_Op,
406 false); 406 false);
407 canvas.drawPicture(*picture); 407 canvas.drawPicture(*picture);
408 } 408 }
409 409
410 } // namespace skia 410 } // namespace skia
OLDNEW
« no previous file with comments | « skia/ext/bitmap_platform_device_win.cc ('k') | skia/ext/platform_canvas.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698