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

Side by Side Diff: gm/peekpixels.cpp

Issue 1550583002: remove unused SkAutoROCanvasPixels (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 12 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 | « no previous file | gm/xfermodes3.cpp » ('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 /*
2 * Copyright 2011 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8 #include "gm.h"
9 #include "SkCanvas.h"
10 #include "SkPath.h"
11 #include "SkSurface.h"
12 #include "SkPicture.h"
13
14 static void draw_content(SkCanvas* canvas) {
15 SkImageInfo info = canvas->imageInfo();
16 SkPaint paint;
17 paint.setAntiAlias(true);
18 canvas->drawCircle(SkScalarHalf(info.width()), SkScalarHalf(info.height()),
19 SkScalarHalf(info.width()), paint);
20 }
21
22 class PeekPixelsGM : public skiagm::GM {
23 public:
24 PeekPixelsGM() {}
25
26 protected:
27 SkString onShortName() override {
28 return SkString("peekpixels");
29 }
30
31 SkISize onISize() override {
32 return SkISize::Make(360, 120);
33 }
34
35 void onDraw(SkCanvas* canvas) override {
36 SkImageInfo info = SkImageInfo::MakeN32Premul(100, 100);
37 SkAutoTUnref<SkSurface> surface(canvas->newSurface(info));
38 if (surface.get()) {
39 SkCanvas* surfCanvas = surface->getCanvas();
40
41 draw_content(surfCanvas);
42 SkBitmap bitmap;
43
44 // test peekPixels
45 {
46 SkImageInfo info;
47 size_t rowBytes;
48 const void* addr = surfCanvas->peekPixels(&info, &rowBytes);
49 if (addr && bitmap.installPixels(info, const_cast<void*>(addr), rowBytes)) {
50 canvas->drawBitmap(bitmap, 0, 0, nullptr);
51 }
52 }
53
54 // test ROCanvasPixels
55 canvas->translate(120, 0);
56 SkAutoROCanvasPixels ropixels(surfCanvas);
57 if (ropixels.asROBitmap(&bitmap)) {
58 canvas->drawBitmap(bitmap, 0, 0, nullptr);
59 }
60
61 // test Surface
62 canvas->translate(120, 0);
63 surface->draw(canvas, 0, 0, nullptr);
64 }
65 }
66
67 private:
68 typedef skiagm::GM INHERITED;
69 };
70
71 DEF_GM(return new PeekPixelsGM;)
OLDNEW
« no previous file with comments | « no previous file | gm/xfermodes3.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698