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

Side by Side Diff: ppapi/cpp/graphics_2d.cc

Issue 12989006: Move HiDPI-related Pepper interfaces to stable (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase after spelling-correction CL Created 7 years, 8 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 | « ppapi/cpp/graphics_2d.h ('k') | ppapi/cpp/view.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "ppapi/cpp/graphics_2d.h" 5 #include "ppapi/cpp/graphics_2d.h"
6 6
7 #include "ppapi/c/pp_errors.h" 7 #include "ppapi/c/pp_errors.h"
8 #include "ppapi/c/ppb_graphics_2d.h" 8 #include "ppapi/c/ppb_graphics_2d.h"
9 #include "ppapi/cpp/completion_callback.h" 9 #include "ppapi/cpp/completion_callback.h"
10 #include "ppapi/cpp/image_data.h" 10 #include "ppapi/cpp/image_data.h"
11 #include "ppapi/cpp/instance_handle.h" 11 #include "ppapi/cpp/instance_handle.h"
12 #include "ppapi/cpp/module.h" 12 #include "ppapi/cpp/module.h"
13 #include "ppapi/cpp/module_impl.h" 13 #include "ppapi/cpp/module_impl.h"
14 #include "ppapi/cpp/point.h" 14 #include "ppapi/cpp/point.h"
15 #include "ppapi/cpp/rect.h" 15 #include "ppapi/cpp/rect.h"
16 16
17 namespace pp { 17 namespace pp {
18 18
19 namespace { 19 namespace {
20 20
21 template <> const char* interface_name<PPB_Graphics2D_1_0>() { 21 template <> const char* interface_name<PPB_Graphics2D_1_0>() {
22 return PPB_GRAPHICS_2D_INTERFACE_1_0; 22 return PPB_GRAPHICS_2D_INTERFACE_1_0;
23 } 23 }
24 24
25 template <> const char* interface_name<PPB_Graphics2D_1_1>() {
26 return PPB_GRAPHICS_2D_INTERFACE_1_1;
27 }
28
25 } // namespace 29 } // namespace
26 30
27 Graphics2D::Graphics2D() : Resource() { 31 Graphics2D::Graphics2D() : Resource() {
28 } 32 }
29 33
30 Graphics2D::Graphics2D(const Graphics2D& other) 34 Graphics2D::Graphics2D(const Graphics2D& other)
31 : Resource(other), 35 : Resource(other),
32 size_(other.size_) { 36 size_(other.size_) {
33 } 37 }
34 38
35 Graphics2D::Graphics2D(const InstanceHandle& instance, 39 Graphics2D::Graphics2D(const InstanceHandle& instance,
36 const Size& size, 40 const Size& size,
37 bool is_always_opaque) 41 bool is_always_opaque)
38 : Resource() { 42 : Resource() {
39 if (!has_interface<PPB_Graphics2D_1_0>()) 43 if (!has_interface<PPB_Graphics2D_1_0>())
40 return; 44 return;
41 PassRefFromConstructor(get_interface<PPB_Graphics2D_1_0>()->Create( 45 PassRefFromConstructor(get_interface<PPB_Graphics2D_1_0>()->Create(
dmichael (off chromium) 2013/04/04 17:16:00 Based on our other discussion here: https://groups
Josh Horwich 2013/04/08 21:08:15 Done. I changed this glue (and view.cc) to try 1_
dmichael (off chromium) 2013/04/08 21:29:36 I was kind of anti-macro in that thread, but got m
42 instance.pp_instance(), 46 instance.pp_instance(),
43 &size.pp_size(), 47 &size.pp_size(),
44 PP_FromBool(is_always_opaque))); 48 PP_FromBool(is_always_opaque)));
45 if (!is_null()) { 49 if (!is_null()) {
46 // Only save the size if allocation succeeded. 50 // Only save the size if allocation succeeded.
47 size_ = size; 51 size_ = size;
48 } 52 }
49 } 53 }
50 54
51 Graphics2D::~Graphics2D() { 55 Graphics2D::~Graphics2D() {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 *image = ImageData(); 101 *image = ImageData();
98 } 102 }
99 103
100 int32_t Graphics2D::Flush(const CompletionCallback& cc) { 104 int32_t Graphics2D::Flush(const CompletionCallback& cc) {
101 if (!has_interface<PPB_Graphics2D_1_0>()) 105 if (!has_interface<PPB_Graphics2D_1_0>())
102 return cc.MayForce(PP_ERROR_NOINTERFACE); 106 return cc.MayForce(PP_ERROR_NOINTERFACE);
103 return get_interface<PPB_Graphics2D_1_0>()->Flush( 107 return get_interface<PPB_Graphics2D_1_0>()->Flush(
104 pp_resource(), cc.pp_completion_callback()); 108 pp_resource(), cc.pp_completion_callback());
105 } 109 }
106 110
111 bool Graphics2D::SetScale(float scale) {
112 if (!has_interface<PPB_Graphics2D_1_1>())
113 return false;
114 return PP_ToBool(get_interface<PPB_Graphics2D_1_1>()->SetScale(pp_resource(),
115 scale));
116 }
117
118 float Graphics2D::GetScale() {
119 if (!has_interface<PPB_Graphics2D_1_1>())
120 return 1.0f;
121 return get_interface<PPB_Graphics2D_1_1>()->GetScale(pp_resource());
122 }
123
107 } // namespace pp 124 } // namespace pp
OLDNEW
« no previous file with comments | « ppapi/cpp/graphics_2d.h ('k') | ppapi/cpp/view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698