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

Side by Side Diff: src/image/SkSurface.cpp

Issue 551463004: introduce Props to surface (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: address comments from #6 Created 6 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
OLDNEW
1 /* 1 /*
2 * Copyright 2012 Google Inc. 2 * Copyright 2012 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkSurface_Base.h" 8 #include "SkSurface_Base.h"
9 #include "SkImagePriv.h" 9 #include "SkImagePriv.h"
10 #include "SkCanvas.h" 10 #include "SkCanvas.h"
11 11
12 SkSurfaceProps::SkSurfaceProps()
13 : fFlags(0), fPixelGeometry(kLegacyLCD_SkPixelGeometry)
14 {}
15
16 SkSurfaceProps::SkSurfaceProps(uint32_t flags, SkPixelGeometry pg)
17 : fFlags(flags), fPixelGeometry(pg)
18 {
19 SkASSERT(!(flags & kLegacyLCD_SkPixelGeometry));
20 }
21
12 /////////////////////////////////////////////////////////////////////////////// 22 ///////////////////////////////////////////////////////////////////////////////
13 23
14 SkSurface_Base::SkSurface_Base(int width, int height) : INHERITED(width, height) { 24 SkSurface_Base::SkSurface_Base(int width, int height, const Props& props)
25 : INHERITED(width, height, props)
26 {
15 fCachedCanvas = NULL; 27 fCachedCanvas = NULL;
16 fCachedImage = NULL; 28 fCachedImage = NULL;
17 } 29 }
18 30
19 SkSurface_Base::SkSurface_Base(const SkImageInfo& info) : INHERITED(info) { 31 SkSurface_Base::SkSurface_Base(const SkImageInfo& info, const Props& props)
32 : INHERITED(info, props)
33 {
20 fCachedCanvas = NULL; 34 fCachedCanvas = NULL;
21 fCachedImage = NULL; 35 fCachedImage = NULL;
22 } 36 }
23 37
24 SkSurface_Base::~SkSurface_Base() { 38 SkSurface_Base::~SkSurface_Base() {
25 // in case the canvas outsurvives us, we null the callback 39 // in case the canvas outsurvives us, we null the callback
26 if (fCachedCanvas) { 40 if (fCachedCanvas) {
27 fCachedCanvas->setSurfaceBase(NULL); 41 fCachedCanvas->setSurfaceBase(NULL);
28 } 42 }
29 43
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 static int32_t gID; 81 static int32_t gID;
68 return sk_atomic_inc(&gID) + 1; 82 return sk_atomic_inc(&gID) + 1;
69 } 83 }
70 84
71 static SkSurface_Base* asSB(SkSurface* surface) { 85 static SkSurface_Base* asSB(SkSurface* surface) {
72 return static_cast<SkSurface_Base*>(surface); 86 return static_cast<SkSurface_Base*>(surface);
73 } 87 }
74 88
75 /////////////////////////////////////////////////////////////////////////////// 89 ///////////////////////////////////////////////////////////////////////////////
76 90
77 SkSurface::SkSurface(int width, int height) : fWidth(width), fHeight(height) { 91 SkSurface::SkSurface(int width, int height, const Props& props)
92 : fProps(props), fWidth(width), fHeight(height)
93 {
78 SkASSERT(fWidth >= 0); 94 SkASSERT(fWidth >= 0);
79 SkASSERT(fHeight >= 0); 95 SkASSERT(fHeight >= 0);
80 fGenerationID = 0; 96 fGenerationID = 0;
81 } 97 }
82 98
83 SkSurface::SkSurface(const SkImageInfo& info) : fWidth(info.width()), fHeight(in fo.height()) { 99 SkSurface::SkSurface(const SkImageInfo& info, const Props& props)
100 : fProps(props), fWidth(info.width()), fHeight(info.height())
101 {
84 SkASSERT(fWidth >= 0); 102 SkASSERT(fWidth >= 0);
85 SkASSERT(fHeight >= 0); 103 SkASSERT(fHeight >= 0);
86 fGenerationID = 0; 104 fGenerationID = 0;
87 } 105 }
88 106
89 uint32_t SkSurface::generationID() { 107 uint32_t SkSurface::generationID() {
90 if (0 == fGenerationID) { 108 if (0 == fGenerationID) {
91 fGenerationID = asSB(this)->newGenerationID(); 109 fGenerationID = asSB(this)->newGenerationID();
92 } 110 }
93 return fGenerationID; 111 return fGenerationID;
(...skipping 18 matching lines...) Expand all
112 } 130 }
113 131
114 void SkSurface::draw(SkCanvas* canvas, SkScalar x, SkScalar y, 132 void SkSurface::draw(SkCanvas* canvas, SkScalar x, SkScalar y,
115 const SkPaint* paint) { 133 const SkPaint* paint) {
116 return asSB(this)->onDraw(canvas, x, y, paint); 134 return asSB(this)->onDraw(canvas, x, y, paint);
117 } 135 }
118 136
119 const void* SkSurface::peekPixels(SkImageInfo* info, size_t* rowBytes) { 137 const void* SkSurface::peekPixels(SkImageInfo* info, size_t* rowBytes) {
120 return this->getCanvas()->peekPixels(info, rowBytes); 138 return this->getCanvas()->peekPixels(info, rowBytes);
121 } 139 }
OLDNEW
« include/core/SkCanvas.h ('K') | « src/core/SkCanvas.cpp ('k') | src/image/SkSurface_Base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698