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

Side by Side Diff: tools/viewer/sk_app/android/RasterWindowContext_android.cpp

Issue 2182273002: SW backend for viewer on Windows (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update Created 4 years, 4 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 /* 2 /*
3 * Copyright 2016 Google Inc. 3 * Copyright 2016 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "WindowContextFactory_android.h" 9 #include "WindowContextFactory_android.h"
10 #include "../RasterWindowContext.h" 10 #include "../RasterWindowContext.h"
11 #include "SkSurface.h" 11 #include "SkSurface.h"
12 #include "SkTypes.h" 12 #include "SkTypes.h"
13 13
14 using sk_app::RasterWindowContext; 14 using sk_app::RasterWindowContext;
15 using sk_app::DisplayParams; 15 using sk_app::DisplayParams;
16 16
17 namespace { 17 namespace {
18 class RasterWindowContext_android : public RasterWindowContext { 18 class RasterWindowContext_android : public RasterWindowContext {
19 public: 19 public:
20 RasterWindowContext_android(ANativeWindow*, const DisplayParams& params); 20 RasterWindowContext_android(ANativeWindow*, const DisplayParams& params);
21 21
22 sk_sp<SkSurface> getBackbufferSurface() override; 22 sk_sp<SkSurface> getBackbufferSurface() override;
23 void swapBuffers() override; 23 void swapBuffers() override;
24 24
25 bool isValid() override { return SkToBool(fNativeWindow); } 25 bool isValid() override { return SkToBool(fNativeWindow); }
26 void resize(uint32_t w, uint32_t h) override; 26 void resize(int w, int h) override;
27 void setDisplayParams(const DisplayParams& params) override; 27 void setDisplayParams(const DisplayParams& params) override;
28 28
29 private: 29 private:
30 void setBuffersGeometry(); 30 void setBuffersGeometry();
31 sk_sp<SkSurface> fBackbufferSurface = nullptr; 31 sk_sp<SkSurface> fBackbufferSurface = nullptr;
32 ANativeWindow* fNativeWindow = nullptr; 32 ANativeWindow* fNativeWindow = nullptr;
33 ANativeWindow_Buffer fBuffer; 33 ANativeWindow_Buffer fBuffer;
34 ARect fBounds; 34 ARect fBounds;
35 }; 35 };
36 36
(...skipping 19 matching lines...) Expand all
56 SK_ABORT("Unsupported Android color type"); 56 SK_ABORT("Unsupported Android color type");
57 } 57 }
58 ANativeWindow_setBuffersGeometry(fNativeWindow, fWidth, fHeight, format); 58 ANativeWindow_setBuffersGeometry(fNativeWindow, fWidth, fHeight, format);
59 } 59 }
60 60
61 void RasterWindowContext_android::setDisplayParams(const DisplayParams& params) { 61 void RasterWindowContext_android::setDisplayParams(const DisplayParams& params) {
62 fDisplayParams = params; 62 fDisplayParams = params;
63 this->setBuffersGeometry(); 63 this->setBuffersGeometry();
64 } 64 }
65 65
66 void RasterWindowContext_android::resize(uint32_t w, uint32_t h) { 66 void RasterWindowContext_android::resize(int w, int h) {
67 fWidth = w; 67 fWidth = w;
68 fHeight = h; 68 fHeight = h;
69 this->setBuffersGeometry(); 69 this->setBuffersGeometry();
70 } 70 }
71 71
72 sk_sp<SkSurface> RasterWindowContext_android::getBackbufferSurface() { 72 sk_sp<SkSurface> RasterWindowContext_android::getBackbufferSurface() {
73 if (nullptr == fBackbufferSurface) { 73 if (nullptr == fBackbufferSurface) {
74 ANativeWindow_lock(fNativeWindow, &fBuffer, &fBounds); 74 ANativeWindow_lock(fNativeWindow, &fBuffer, &fBounds);
75 const int bytePerPixel = fBuffer.format == WINDOW_FORMAT_RGB_565 ? 2 : 4 ; 75 const int bytePerPixel = fBuffer.format == WINDOW_FORMAT_RGB_565 ? 2 : 4 ;
76 SkImageInfo info = SkImageInfo::Make(fWidth, fHeight, 76 SkImageInfo info = SkImageInfo::Make(fWidth, fHeight,
(...skipping 20 matching lines...) Expand all
97 WindowContext* ctx = new RasterWindowContext_android(window, params); 97 WindowContext* ctx = new RasterWindowContext_android(window, params);
98 if (!ctx->isValid()) { 98 if (!ctx->isValid()) {
99 delete ctx; 99 delete ctx;
100 return nullptr; 100 return nullptr;
101 } 101 }
102 return ctx; 102 return ctx;
103 } 103 }
104 104
105 } 105 }
106 } // namespace sk_app 106 } // namespace sk_app
OLDNEW
« no previous file with comments | « tools/viewer/sk_app/WindowContext.h ('k') | tools/viewer/sk_app/unix/RasterWindowContext_unix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698